Class: Synapse::UnitOfWork::UnitOfWorkListener Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/synapse/uow/listener.rb

Overview

This class is abstract.

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

Instance Method Summary collapse

Instance Method Details

#after_commit(unit) ⇒ undefined

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.

Parameters:

Returns:

  • (undefined)


56
# File 'lib/synapse/uow/listener.rb', line 56

def after_commit(unit); end

#on_cleanup(unit) ⇒ undefined

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.

Parameters:

Returns:

  • (undefined)


76
# File 'lib/synapse/uow/listener.rb', line 76

def on_cleanup(unit); end

#on_event_registered(unit, event) ⇒ EventMessage

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.

Parameters:

Returns:

  • (EventMessage)


21
22
23
# File 'lib/synapse/uow/listener.rb', line 21

def on_event_registered(unit, event)
  event
end

#on_prepare_commit(unit, aggregates, events) ⇒ undefined

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.

Parameters:

Returns:

  • (undefined)


34
# File 'lib/synapse/uow/listener.rb', line 34

def on_prepare_commit(unit, aggregates, events); end

#on_prepare_transaction_commit(unit, transaction) ⇒ undefined

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.

Parameters:

Returns:

  • (undefined)


46
# File 'lib/synapse/uow/listener.rb', line 46

def on_prepare_transaction_commit(unit, transaction); end

#on_rollback(unit, cause = nil) ⇒ undefined

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.

Parameters:

  • unit (UnitOfWork)
  • cause (Error) (defaults to: nil)

Returns:

  • (undefined)


66
# File 'lib/synapse/uow/listener.rb', line 66

def on_rollback(unit, cause = nil); end

#on_start(unit) ⇒ undefined

Invoked when the unit of work has been started

Parameters:

Returns:

  • (undefined)


10
# File 'lib/synapse/uow/listener.rb', line 10

def on_start(unit); end