Class: Factorix::HTTP::RetryStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/factorix/http/retry_strategy.rb

Overview

Class that manages retry strategy with exponential backoff and randomization

Instance Method Summary collapse

Constructor Details

#initialize(logger: nil, **options) ⇒ RetryStrategy

Initialize a new retry strategy with customizable options

Parameters:

  • options (Hash)

    Options for retry behavior

Options Hash (**options):

  • :tries (Integer)

    Number of attempts (including the initial try)

  • :base_interval (Float)

    Initial interval between retries (seconds)

  • :multiplier (Float)

    Exponential backoff multiplier

  • :rand_factor (Float)

    Randomization factor

  • :on (Array<Class>)

    Exception classes to retry on

  • :on_retry (Proc)

    Callback called on each retry



43
44
45
46
# File 'lib/factorix/http/retry_strategy.rb', line 43

def initialize(logger: nil, **options)
  super(logger:)
  @options = configure_options(options)
end

Instance Method Details

#with_retry { ... } ⇒ Object

Execute the block with automatic retry on specified exceptions. Uses exponential backoff with randomization for retry intervals

Yields:

  • Block to execute

Returns:

  • (Object)

    Return value of the block

Raises:

  • (StandardError)

    If the block fails after all retries



54
# File 'lib/factorix/http/retry_strategy.rb', line 54

def with_retry(&) = Retriable.retriable(**@options, &)