Class: Synapse::Command::SerializationOptimizingInterceptor

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

Overview

Interceptor that registers a unit of work listener that wraps each event message in a serialization-aware message. This provides optimization in cases where storage (in an event store) and publication (on the event bus) use the same serialization mechansim.

Instance Method Summary collapse

Constructor Details

#initializeSerializationOptimizingInterceptor

Returns a new instance of SerializationOptimizingInterceptor.



7
8
9
# File 'lib/synapse/command/interceptors/serialization.rb', line 7

def initialize
  @listener = SerializationOptimizingListener.new
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



15
16
17
18
# File 'lib/synapse/command/interceptors/serialization.rb', line 15

def intercept(command, unit, chain)
  unit.register_listener @listener
  chain.proceed command
end