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 * 24
Instance Method Summary collapse
- #constantize(camel_cased_word) ⇒ Object
- #hostname ⇒ Object
- #logger ⇒ Object
- #process_id ⇒ Object
- #redis(&block) ⇒ Object
- #watchdog(last_words) ⇒ Object
Methods included from ExceptionHandler
Instance Method Details
#constantize(camel_cased_word) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/sidekiq/util.rb', line 13 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 |
#hostname ⇒ Object
42 43 44 |
# File 'lib/sidekiq/util.rb', line 42 def hostname Socket.gethostname end |
#process_id ⇒ Object
38 39 40 |
# File 'lib/sidekiq/util.rb', line 38 def process_id Process.pid end |
#redis(&block) ⇒ Object
34 35 36 |
# File 'lib/sidekiq/util.rb', line 34 def redis(&block) Sidekiq.redis(&block) end |
#watchdog(last_words) ⇒ Object
24 25 26 27 28 |
# File 'lib/sidekiq/util.rb', line 24 def watchdog(last_words) yield rescue Exception => ex handle_exception(ex, { :context => last_words }) end |