Class: Sidekiq::Batch::Middleware::ServerMiddleware
- Inherits:
-
Object
- Object
- Sidekiq::Batch::Middleware::ServerMiddleware
- Defined in:
- lib/sidekiq/batch/middleware.rb
Instance Method Summary collapse
Instance Method Details
#call(_worker, msg, _queue) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sidekiq/batch/middleware.rb', line 16 def call(_worker, msg, _queue) if (bid = msg['bid']) begin Thread.current[:batch] = Sidekiq::Batch.new(bid) yield Thread.current[:batch] = nil Batch.process_successful_job(bid, msg['jid']) rescue Batch.process_failed_job(bid, msg['jid']) raise ensure Thread.current[:batch] = nil end else yield end end |