Class: SidekiqBatch::ClientMiddleware

Inherits:
Object
  • Object
show all
Defined in:
app/models/sidekiq_batch/client_middleware.rb

Instance Method Summary collapse

Instance Method Details

#call(_worker_class, _job, _queue, _redis_pool) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'app/models/sidekiq_batch/client_middleware.rb', line 5

def call(_worker_class, _job, _queue, _redis_pool)
  result  = yield
  context = ::SidekiqBatch::BatchEnrollmentContext.current

  # Enroll the hash the chain returned, not the one we were handed. That
  # return value is what Sidekiq pushes, so it is the one whose jid must be
  # recorded and the one our batch-id stamp has to land on.
  context.enroll(result) if result.is_a?(Hash) && context

  result
end