Class: Fractor::Workflow::RetryStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/fractor/workflow/retry_strategy.rb

Overview

Base class for retry strategies

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(max_attempts: 3, max_delay: nil) ⇒ RetryStrategy

Returns a new instance of RetryStrategy.



9
10
11
12
# File 'lib/fractor/workflow/retry_strategy.rb', line 9

def initialize(max_attempts: 3, max_delay: nil)
  @max_attempts = max_attempts
  @max_delay = max_delay
end

Instance Attribute Details

#max_attemptsObject (readonly)

Returns the value of attribute max_attempts.



7
8
9
# File 'lib/fractor/workflow/retry_strategy.rb', line 7

def max_attempts
  @max_attempts
end

#max_delayObject (readonly)

Returns the value of attribute max_delay.



7
8
9
# File 'lib/fractor/workflow/retry_strategy.rb', line 7

def max_delay
  @max_delay
end

Instance Method Details

#delay_for(attempt) ⇒ Numeric

Calculate delay for the given attempt number

Parameters:

  • attempt (Integer)

    The attempt number (1-based)

Returns:

  • (Numeric)

    Delay in seconds

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/fractor/workflow/retry_strategy.rb', line 17

def delay_for(attempt)
  raise NotImplementedError, "Subclasses must implement delay_for"
end