Class: EventSourcery::EventProcessing::ErrorHandlers::ExponentialBackoffRetry

Inherits:
Object
  • Object
show all
Includes:
ErrorHandler
Defined in:
lib/event_sourcery/event_processing/error_handlers/exponential_backoff_retry.rb

Constant Summary collapse

DEFAULT_RETRY_INVERAL =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The starting value for the retry interval used with #with_error_handling.

1
MAX_RETRY_INVERVAL =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

The maximum retry interval value to be used with #with_error_handling.

64

Instance Method Summary collapse

Constructor Details

#initialize(processor_name:) ⇒ ExponentialBackoffRetry

Returns a new instance of ExponentialBackoffRetry.


17
18
19
20
# File 'lib/event_sourcery/event_processing/error_handlers/exponential_backoff_retry.rb', line 17

def initialize(processor_name:)
  @processor_name = processor_name
  @retry_interval = DEFAULT_RETRY_INVERAL
end

Instance Method Details

#with_error_handlingObject

Will yeild the black and attempt to retry in an exponential backoff.


23
24
25
26
27
28
29
30
# File 'lib/event_sourcery/event_processing/error_handlers/exponential_backoff_retry.rb', line 23

def with_error_handling
  yield
rescue => error
  report_error(error)
  update_retry_interval(error)
  sleep(@retry_interval)
  retry
end