class Synapse::Command::AsynchronousCommandBus

Command bus that uses a thread pool to asynchronously execute commands, invoking the given callback when execution is completed or resulted in an error

@todo Look into non-blocking circular buffers or LMAX Disruptor

Attributes

thread_pool[RW]

Pool of worker threads that dispatch commands from a queue @return [Contender::Pool::ThreadPoolExecutor]

Public Instance Methods

dispatch_with_callback(command, callback) click to toggle source

@api public @param [CommandMessage] command @param [CommandCallback] callback @return [undefined]

Calls superclass method
# File lib/synapse/command/async_command_bus.rb, line 16
def dispatch_with_callback(command, callback)
  @thread_pool.execute do
    super command, callback
  end
end
shutdown() click to toggle source

Shuts down the command bus, waiting until all tasks are finished

@api public @return [undefined]

# File lib/synapse/command/async_command_bus.rb, line 26
def shutdown
  @thread_pool.shutdown
end
shutdown!() click to toggle source

Shuts down the command bus without waiting for tasks to finish

@api public @return [undefined]

# File lib/synapse/command/async_command_bus.rb, line 34
def shutdown!
  @thread_pool.shutdown!
end