Class: Chronos::Integrations::Sidekiq::ClientMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/chronos/integrations/sidekiq.rb

Overview

Adds a small allowlisted Chronos context to the Sidekiq job envelope.

Examples:

ClientMiddleware.new.call(MyWorker, job, "default") { push(job) }

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ClientMiddleware

Returns a new instance of ClientMiddleware.



81
82
83
84
# File 'lib/chronos/integrations/sidekiq.rb', line 81

def initialize(options = {})
  @notifier = options[:notifier] || Chronos
  @clock = options[:clock] || proc { Time.now.to_f }
end

Instance Method Details

#call(_worker_class, job, _queue, _redis_pool = nil) ⇒ Object



86
87
88
89
# File 'lib/chronos/integrations/sidekiq.rb', line 86

def call(_worker_class, job, _queue, _redis_pool = nil)
  add_context(job)
  yield
end