Module: Sidekiq::Util

Overview

This module is part of Sidekiq core and not intended for extensions.

Constant Summary collapse

EXPIRY =
60 * 60

Instance Method Summary collapse

Instance Method Details

#constantize(camel_cased_word) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/sidekiq/util.rb', line 9

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

#loggerObject



28
29
30
# File 'lib/sidekiq/util.rb', line 28

def logger
  Sidekiq.logger
end

#process_idObject



36
37
38
# File 'lib/sidekiq/util.rb', line 36

def process_id
  Process.pid
end

#redis(&block) ⇒ Object



32
33
34
# File 'lib/sidekiq/util.rb', line 32

def redis(&block)
  Sidekiq.redis(&block)
end

#watchdog(last_words) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/sidekiq/util.rb', line 20

def watchdog(last_words)
  yield
rescue => ex
  logger.error last_words
  logger.error ex
  logger.error ex.backtrace.join("\n")
end