1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00
mperham--sidekiq/lib/sidekiq/util.rb
Mike Perham f9af66edd7 Rework redis connections so that the manager and
the client use separate pools.

This is so the Rails app Sidekiq::Client and 
Sidekiq::Manager can use different configurations.

Also, fix issue where workers were not unregistered
in Redis upon shutdown.
2012-02-11 13:14:03 -08:00

39 lines
733 B
Ruby

module Sidekiq
module Util
def constantize(camel_cased_word)
names = camel_cased_word.split('::')
names.shift if names.empty? || names.first.empty?
constant = Object
names.each do |name|
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
end
constant
end
def watchdog(last_words)
yield
rescue => ex
err last_words
err ex
err ex.backtrace.join("\n")
end
def err(msg)
STDERR.puts(msg)
end
def log(msg)
STDOUT.puts(msg) unless $TESTING
end
def verbose(msg)
STDOUT.puts(msg) if $DEBUG
end
def redis
Sidekiq::Manager.redis
end
end
end