Class: Wurk::Batch::ClientMiddleware

Inherits:
Object
  • Object
show all
Includes:
ServerMiddleware
Defined in:
lib/wurk/batch/client_middleware.rb

Overview

Client middleware. When a ‘Job.perform_async` runs inside a `batch.jobs { … }` block, Thread.current holds the active batch — we stamp `bid` onto the payload so the worker can re-open the batch and Client#raw_push can route through BATCH_PUSH for atomic increment+LPUSH.

Auto-registered at the head of the client chain when this file is required.

Instance Method Summary collapse

Instance Method Details

#call(_worker, job, _queue, _redis_pool) ⇒ Object



18
19
20
21
22
# File 'lib/wurk/batch/client_middleware.rb', line 18

def call(_worker, job, _queue, _redis_pool)
  batch = Thread.current[Batch::THREAD_KEY]
  job['bid'] = batch.bid if batch
  yield
end