class Synapse::UnitOfWork::UnitOfWorkListener

Listener that is registered to a unit of work and is notified of state changes @abstract

Public Instance Methods

after_commit(unit) click to toggle source

Invoked when the unit of work is committed

At this point, any registered aggregates have been stored and any registered events have been scheduled for publication. When processing of this method causes an exception, the unit of work may choose to rollback.

@param [UnitOfWork] unit @return [undefined]

# File lib/synapse/uow/listener.rb, line 56
def after_commit(unit); end
on_cleanup(unit) click to toggle source

Invoked while a unit of work is being cleaned up

This gives listeners the opportunity to release resources that might have been acquired during commit or rollback operations, such as locks. This method is always called after all listeners have been notified of a commit or rollback operation.

@param [UnitOfWork] unit @return [undefined]

# File lib/synapse/uow/listener.rb, line 76
def on_cleanup(unit); end
on_event_registered(unit, event) click to toggle source

Invoked when an event is registered for publication when the unit of work is committed

Listeners may alter event information. Note that the listener must ensure the functional meaning of the message does not change. Typically, this is done only by modifying the metadata of the message.

@param [UnitOfWork] unit @param [EventMessage] event @return [EventMessage]

# File lib/synapse/uow/listener.rb, line 21
def on_event_registered(unit, event)
  event
end
on_prepare_commit(unit, aggregates, events) click to toggle source

Invoked before aggregates are committed, and before any events are published

This phase can be used to do validation or any other activity that should be able to prevent event publication in certain circumstances.

@param [UnitOfWork] unit @param [Array<AggregateRoot>] aggregates @param [Hash<EventBus, Array>] events @return [undefined]

# File lib/synapse/uow/listener.rb, line 34
def on_prepare_commit(unit, aggregates, events); end
on_prepare_transaction_commit(unit, transaction) click to toggle source

Invoked before the transaction bound to this unit of work is committed, but after all other commit activities (publication of events and storage of aggregates) are performed

This gives a resource manager the opportunity to take actions that must be part of the same transaction. Note that this method is only invoked if the unit of work is bound to a transaction.

@param [UnitOfWork] unit @param [Object] transaction @return [undefined]

# File lib/synapse/uow/listener.rb, line 46
def on_prepare_transaction_commit(unit, transaction); end
on_rollback(unit, cause = nil) click to toggle source

Invoked when the unit of work is rolled back

Alternatively, the unit of work may choose to invoke this method when the commit of the unit of work failed as well.

@param [UnitOfWork] unit @param [Error] cause @return [undefined]

# File lib/synapse/uow/listener.rb, line 66
def on_rollback(unit, cause = nil); end
on_start(unit) click to toggle source

Invoked when the unit of work has been started

@param [UnitOfWork] unit @return [undefined]

# File lib/synapse/uow/listener.rb, line 10
def on_start(unit); end