Class: Synapse::Command::DuplicationCleanupInterceptor

Inherits:
DispatchInterceptor show all
Defined in:
lib/synapse/command/duplication.rb

Overview

Interceptor that removes commands from the duplication recorder if their execution results in a transient error (like concurrency error) being raised. This way, the same command can be retried by the client or command gateway

Instance Method Summary collapse

Constructor Details

#initialize(recorder) ⇒ undefined

Parameters:



25
26
27
# File 'lib/synapse/command/duplication.rb', line 25

def initialize(recorder)
  @recorder = recorder
end

Instance Method Details

#intercept(command, unit, chain) ⇒ Object

Returns The result of the execution of the command.

Parameters:

Returns:

  • (Object)

    The result of the execution of the command



33
34
35
36
37
38
39
40
# File 'lib/synapse/command/duplication.rb', line 33

def intercept(command, unit, chain)
  begin
    chain.proceed command
  rescue TransientError
    @recorder.forget command
    raise
  end
end