Module: SidekiqIteration::Throttling

Defined in:
lib/sidekiq_iteration/throttling.rb

Defined Under Namespace

Classes: ThrottleCondition

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#throttle_conditionsObject



29
30
31
# File 'lib/sidekiq_iteration/throttling.rb', line 29

def throttle_conditions
  @throttle_conditions ||= []
end

Instance Method Details

#throttle_on(backoff: 30) {|job| ... } ⇒ Object

Add a condition under which this job will be throttled.

Parameters:

  • backoff (Numeric, #call) (defaults to: 30)

    (30) a custom backoff (in seconds). This is the time to wait before retrying the job.

Yield Parameters:

  • job (Sidekiq::Job)

    current sidekiq job that is yielded to ‘condition` proc

Yield Returns:

  • (Boolean)

    whether the throttle condition is being met, indicating that the job should throttle.



41
42
43
# File 'lib/sidekiq_iteration/throttling.rb', line 41

def throttle_on(backoff: 30, &condition)
  throttle_conditions << ThrottleCondition.new(condition, backoff)
end