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

42 lines
811 B
Ruby
Raw Normal View History

require 'sidekiq/exception_handler'
2012-01-22 14:32:38 -05:00
module Sidekiq
2012-02-17 16:39:36 -05:00
##
# This module is part of Sidekiq core and not intended for extensions.
#
2012-01-22 14:32:38 -05:00
module Util
include ExceptionHandler
2012-01-22 14:32:38 -05:00
2012-05-12 17:02:32 -04:00
EXPIRY = 60 * 60
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
2012-01-22 14:32:38 -05:00
def watchdog(last_words)
yield
rescue => ex
handle_exception(ex, { :context => last_words })
2012-01-22 14:32:38 -05:00
end
def logger
Sidekiq.logger
2012-01-22 19:01:46 -05:00
end
def redis(&block)
Sidekiq.redis(&block)
end
def process_id
2012-03-06 23:18:16 -05:00
Process.pid
end
2012-01-22 14:32:38 -05:00
end
end