Class: Sidekiq::Status::ClientMiddleware
- Inherits:
-
Object
- Object
- Sidekiq::Status::ClientMiddleware
- Includes:
- Storage
- Defined in:
- lib/sidekiq-status/client_middleware.rb
Overview
Should be in the client middleware chain
Constant Summary
Constants included from Storage
Storage::BATCH_LIMIT, Storage::RESERVED_FIELDS
Instance Method Summary collapse
-
#call(worker_class, msg, queue, redis_pool = nil) ⇒ Object
Uses msg id and puts :queued status in the job’s Redis hash.
-
#initialize(opts = {}) ⇒ ClientMiddleware
constructor
Parameterized initialization, use it when adding middleware to client chain chain.add Sidekiq::Status::ClientMiddleware, :expiration => 60 * 5.
Constructor Details
#initialize(opts = {}) ⇒ ClientMiddleware
Parameterized initialization, use it when adding middleware to client chain chain.add Sidekiq::Status::ClientMiddleware, :expiration => 60 * 5
10 11 12 |
# File 'lib/sidekiq-status/client_middleware.rb', line 10 def initialize(opts = {}) @expiration = opts[:expiration] end |
Instance Method Details
#call(worker_class, msg, queue, redis_pool = nil) ⇒ Object
Uses msg id and puts :queued status in the job’s Redis hash
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sidekiq-status/client_middleware.rb', line 19 def call(worker_class, msg, queue, redis_pool=nil) = { jid: msg['jid'], status: :queued, worker: worker_class, args: msg['args'].to_a.empty? ? nil : msg['args'].to_json } store_for_id msg['jid'], , @expiration, redis_pool yield end |