Class: Synapse::Command::IntervalRetryScheduler
- Inherits:
-
RetryScheduler
- Object
- RetryScheduler
- Synapse::Command::IntervalRetryScheduler
- Defined in:
- lib/synapse/command/gateway/interval_retry_scheduler.rb
Overview
Implementation of a retry scheduler that retries commands at regular intervals
If the last failure is explicitly non-transient exception or the number of failures reaches the maximum number of retries, the command will not be scheduled for retry.
This implementation uses EventMachine to schedule one-shot timers.
Instance Method Summary collapse
- #initialize(interval, maxRetries) ⇒ undefined constructor
- #schedule(command, failures, dispatcher) ⇒ Boolean
Constructor Details
#initialize(interval, maxRetries) ⇒ undefined
13 14 15 16 17 18 |
# File 'lib/synapse/command/gateway/interval_retry_scheduler.rb', line 13 def initialize(interval, maxRetries) @interval = interval @maxRetries = maxRetries @logger = Logging.logger[self.class] end |
Instance Method Details
#schedule(command, failures, dispatcher) ⇒ Boolean
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/synapse/command/gateway/interval_retry_scheduler.rb', line 24 def schedule(command, failures, dispatcher) lastFailure = failures.last if explicitly_non_transient? lastFailure @logger.info 'Dispatch of command [%s] [%s] resulted in non-transient exception' % [command.payload_type, command.id] return false end failureCount = failures.size if failureCount > @maxRetries @logger.info 'Dispatch of command [%s] [%s] resulted in exception [%s] times' % [command.payload_type, command.id, failureCount] return false end if @logger.info? @logger.info 'Dispatch of command [%s] [%s] resulted in exception; will retry up to [%s] more times' % [command.payload_type, command.id, @maxRetries - failureCount] end perform_schedule command, dispatcher true end |