Class: Chillout::Middleware::SidekiqCreationsMonitor
- Inherits:
-
Object
- Object
- Chillout::Middleware::SidekiqCreationsMonitor
- Defined in:
- lib/chillout/middleware/sidekiq.rb
Instance Method Summary collapse
- #call(_worker, job, queue) ⇒ Object
- #enqueue(_queue, job, started, success) ⇒ Object
-
#initialize(options) ⇒ SidekiqCreationsMonitor
constructor
A new instance of SidekiqCreationsMonitor.
Constructor Details
#initialize(options) ⇒ SidekiqCreationsMonitor
Returns a new instance of SidekiqCreationsMonitor.
44 45 46 |
# File 'lib/chillout/middleware/sidekiq.rb', line 44 def initialize() @client = .fetch(:client) end |
Instance Method Details
#call(_worker, job, queue) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/chillout/middleware/sidekiq.rb', line 48 def call(_worker, job, queue) started = Time.now.utc success = false yield success = true ensure enqueue(queue, job, started, success) end |
#enqueue(_queue, job, started, success) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/chillout/middleware/sidekiq.rb', line 57 def enqueue(_queue, job, started, success) finished = Time.now.utc if creations = Chillout.creations Chillout.creations = nil @client.enqueue(creations) end @client.enqueue(SidekiqJobMeasurement.new( job, _queue, started, finished, success )) end |