module Sidekiq::Util
Public Instance Methods
fire_event(event, options = {})
click to toggle source
# File lib/sidekiq/util.rb, line 80 def fire_event(event, options = {}) reverse = options[:reverse] reraise = options[:reraise] arr = Sidekiq.options[:lifecycle_events][event] arr.reverse! if reverse arr.each do |block| block.call rescue => ex handle_exception(ex, {context: "Exception during Sidekiq lifecycle event.", event: event}) raise ex if reraise end arr.clear end
hostname()
click to toggle source
# File lib/sidekiq/util.rb, line 68 def hostname ENV["DYNO"] || Socket.gethostname end
identity()
click to toggle source
# File lib/sidekiq/util.rb, line 76 def identity @@identity ||= "#{hostname}:#{::Process.pid}:#{process_nonce}" end
logger()
click to toggle source
# File lib/sidekiq/util.rb, line 56 def logger Sidekiq.logger end
process_nonce()
click to toggle source
# File lib/sidekiq/util.rb, line 72 def process_nonce @@process_nonce ||= SecureRandom.hex(6) end
redis(&block)
click to toggle source
# File lib/sidekiq/util.rb, line 60 def redis(&block) Sidekiq.redis(&block) end
safe_thread(name, &block)
click to toggle source
# File lib/sidekiq/util.rb, line 49 def safe_thread(name, &block) Thread.new do Thread.current.name = name watchdog(name, &block) end end
tid()
click to toggle source
# File lib/sidekiq/util.rb, line 64 def tid Thread.current["sidekiq_tid"] ||= (Thread.current.object_id ^ ::Process.pid).to_s(36) end
watchdog(last_words) { || ... }
click to toggle source
# File lib/sidekiq/util.rb, line 42 def watchdog(last_words) yield rescue Exception => ex handle_exception(ex, {context: last_words}) raise ex end