Module: Sidekiq::Util
- Includes:
- ExceptionHandler
- Included in:
- CLI, Fetcher, Launcher, 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
- #fire_event(event) ⇒ Object
- #hostname ⇒ Object
- #identity ⇒ Object
- #logger ⇒ Object
- #redis(&block) ⇒ Object
- #watchdog(last_words) ⇒ Object
Methods included from ExceptionHandler
Instance Method Details
#fire_event(event) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/sidekiq/util.rb', line 37 def fire_event(event) Sidekiq.[:lifecycle_events][event].each do |block| begin block.call rescue => ex handle_exception(ex, { :event => event }) end end end |
#hostname ⇒ Object
29 30 31 |
# File 'lib/sidekiq/util.rb', line 29 def hostname ENV['DYNO'] || Socket.gethostname end |
#identity ⇒ Object
33 34 35 |
# File 'lib/sidekiq/util.rb', line 33 def identity @@identity ||= "#{hostname}:#{$$}" end |
#redis(&block) ⇒ Object
25 26 27 |
# File 'lib/sidekiq/util.rb', line 25 def redis(&block) Sidekiq.redis(&block) end |
#watchdog(last_words) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/sidekiq/util.rb', line 14 def watchdog(last_words) yield rescue Exception => ex handle_exception(ex, { :context => last_words }) raise ex end |