class Synapse::Command::RetryingCallback
Implementation of a callback that will retry the dispatch of a command if execution results in an exception
This callback is not meant to be used directly. Use a command gateway implementation instead.
Public Class Methods
new(delegate, command, retry_scheduler, command_bus)
click to toggle source
@param [CommandCallback] delegate @param [CommandMessage] command @param [RetryScheduler] retry_scheduler @param [CommandBus] command_bus @return [undefined]
# File lib/synapse/command/gateway/retrying_callback.rb, line 13 def initialize(delegate, command, retry_scheduler, command_bus) @command = command @delegate = delegate @retry_scheduler = retry_scheduler @failures = Array.new @dispatcher = proc do command_bus.dispatch_with_callback command, self end end
Public Instance Methods
on_failure(exception)
click to toggle source
@param [Exception] exception The cause of the failure @return [undefined]
# File lib/synapse/command/gateway/retrying_callback.rb, line 32 def on_failure(exception) @failures.push exception begin unless exception.is_a? RuntimeError and @retry_scheduler.schedule @command, @failures, @dispatcher @delegate.on_failure exception end rescue @delegate.on_failure $! end end
on_success(result)
click to toggle source
@param [Object] result The result from the command handler @return [undefined]
# File lib/synapse/command/gateway/retrying_callback.rb, line 26 def on_success(result) @delegate.on_success result end