Class: Cutoff::Sidekiq::ServerMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/cutoff/sidekiq.rb

Overview

Add an option cutoff for sidekiq workers

Examples:

class MyWorker
  include Sidekiq::Worker

  sidekiq_options cutoff: 6.0

  def perform
    # ...
  end
end

Instance Method Summary collapse

Instance Method Details

#call(_worker, job, _queue) { ... } ⇒ void

This method returns an undefined value.

Parameters:

  • _worker (Object)

    the worker instance

  • job (Hash)

    the full job payload

  • _queue (String)

    queue the name of the queue the job was pulled from

Yields:

  • the next middleware in the chain or worker perform method



27
28
29
30
31
32
# File 'lib/cutoff/sidekiq.rb', line 27

def call(_worker, job, _queue)
  allowed_seconds = job['cutoff']
  return yield if allowed_seconds.nil?

  Cutoff.wrap(allowed_seconds) { yield }
end