Class: EventSourcery::EventProcessing::ErrorHandlers::ExponentialBackoffRetry
- Inherits:
-
Object
- Object
- EventSourcery::EventProcessing::ErrorHandlers::ExponentialBackoffRetry
- Includes:
- ErrorHandler
- Defined in:
- lib/event_sourcery/event_processing/error_handlers/exponential_backoff_retry.rb
Constant Summary collapse
- DEFAULT_RETRY_INTERVAL =
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_INTERVAL =
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
-
#initialize(processor_name:) ⇒ ExponentialBackoffRetry
constructor
A new instance of ExponentialBackoffRetry.
-
#with_error_handling ⇒ Object
Will yield the block and attempt to retry in an exponential backoff.
Constructor Details
#initialize(processor_name:) ⇒ ExponentialBackoffRetry
Returns a new instance of ExponentialBackoffRetry.
17 18 19 20 21 |
# 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_INTERVAL @error_event_uuid = nil end |
Instance Method Details
#with_error_handling ⇒ Object
Will yield the block and attempt to retry in an exponential backoff.
24 25 26 27 28 29 30 31 32 |
# File 'lib/event_sourcery/event_processing/error_handlers/exponential_backoff_retry.rb', line 24 def with_error_handling yield rescue => error report_error(error) update_retry_interval(error) sleep(@retry_interval) EventSourcery.logger.info { "Retrying #{@processor_name} with error: #{error.message} at interval=#{@retry_interval}" } retry end |