Class: Desiru::Jobs::RetryStrategies::LinearBackoff

Inherits:
Object
  • Object
show all
Defined in:
lib/desiru/jobs/retry_strategies.rb

Overview

Linear backoff strategy

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_delay: 1, max_delay: 60, increment: 5) ⇒ LinearBackoff

Returns a new instance of LinearBackoff.



38
39
40
41
42
# File 'lib/desiru/jobs/retry_strategies.rb', line 38

def initialize(base_delay: 1, max_delay: 60, increment: 5)
  @base_delay = base_delay
  @max_delay = max_delay
  @increment = increment
end

Instance Attribute Details

#base_delayObject (readonly)

Returns the value of attribute base_delay.



36
37
38
# File 'lib/desiru/jobs/retry_strategies.rb', line 36

def base_delay
  @base_delay
end

#incrementObject (readonly)

Returns the value of attribute increment.



36
37
38
# File 'lib/desiru/jobs/retry_strategies.rb', line 36

def increment
  @increment
end

#max_delayObject (readonly)

Returns the value of attribute max_delay.



36
37
38
# File 'lib/desiru/jobs/retry_strategies.rb', line 36

def max_delay
  @max_delay
end

Instance Method Details

#delay_for(retry_count) ⇒ Object



44
45
46
# File 'lib/desiru/jobs/retry_strategies.rb', line 44

def delay_for(retry_count)
  [base_delay + (increment * retry_count), max_delay].min
end