Module: Sidekiq::Util

Includes:
ExceptionHandler
Included in:
CLI, Fetcher, Manager, Middleware::Server::RetryJobs, Processor, Scheduled::Poller
Defined in:
lib/sidekiq/util.rb

Overview

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

Constant Summary collapse

EXPIRY =
60 * 60

Instance Method Summary collapse

Methods included from ExceptionHandler

#handle_exception

Instance Method Details

#constantize(camel_cased_word) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/sidekiq/util.rb', line 12

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



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

def logger
  Sidekiq.logger
end

#process_idObject



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

def process_id
  Process.pid
end

#redis(&block) ⇒ Object



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

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

#watchdog(last_words) ⇒ Object



23
24
25
26
27
# File 'lib/sidekiq/util.rb', line 23

def watchdog(last_words)
  yield
rescue => ex
  handle_exception(ex, { :context => last_words })
end