Class: EventSourcery::EventProcessing::ErrorHandlers::ConstantRetry

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

Overview

Strategies for error handling.

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 retry interval used with #with_error_handling.

1

Instance Method Summary collapse

Constructor Details

#initialize(processor_name:) ⇒ ConstantRetry

Returns a new instance of ConstantRetry.



13
14
15
16
# File 'lib/event_sourcery/event_processing/error_handlers/constant_retry.rb', line 13

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

Instance Method Details

#with_error_handlingObject

Will yield the block and attempt to retry after a defined retry interval DEFAULT_RETRY_INTERVAL.



19
20
21
22
23
24
25
26
# File 'lib/event_sourcery/event_processing/error_handlers/constant_retry.rb', line 19

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

  retry
end