ddd.application.action

The ApplicationService contains one or more functions that implements the actions.

API

ddd.application.action.action(func)

A decorator for the functions of the application service.

Makes sure that the wrapped method is called inside a transaction. It then saves any published events to the database.

If transaction is committed (not rolled back), the events are actually published and then deleted from the database.

The flow described above makes sure state is persisted and events are published atomically (either both happens or nothing). This assures us the overall system state is consistent.

Examples

Decorate a function in the application service:

@action
async def send_tracking_email(self, command, corr_ids=None):
    """
    Send tracking email to recipient.
    """
    ...