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

Methods included from ExceptionHandler

#handle_exception

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.options[:lifecycle_events][event].each do |block|
    begin
      block.call
    rescue => ex
      handle_exception(ex, { :event => event })
    end
  end
end

#hostnameObject


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

def hostname
  ENV['DYNO'] || Socket.gethostname
end

#identityObject


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

def identity
  @@identity ||= "#{hostname}:#{$$}"
end

#loggerObject


21
22
23
# File 'lib/sidekiq/util.rb', line 21

def logger
  Sidekiq.logger
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