Two Phase Commit v0.1.0 Traktor View Source

Traktor is a library to execute actions in a traceable manner by applying a two-phase-commit pattern.

It is mainly defined by two behaviours:

Entity

An action or a group of actions can be applied to an entity. The action is a behaviour that transforms an entity from one version to another. Eg. booking and payment actions are applied to the Checkout entity.

Link to this section Summary

Types

Module implementing the Traktor.Action behaviour

Specific arguments required to apply an action to an entity

Unique reference of an entity

The revision of the state of an entity

The state of an entity at a specific revision

Module implementing the Traktor.Store behaviour. An in memory store is provided with the package

A transaction contains all the information required to commit an action

Unique reference of a transaction

Functions

Runs both phases of the two phase commit: prepare/6 and commit/6

Executes the business logic and persists the result

Prepares the execution of the businses logic and persists it

Link to this section Types

Module implementing the Traktor.Action behaviour.

Specific arguments required to apply an action to an entity.

Link to this type error_reason() View Source
error_reason() ::
  {:conflict, revision()} | {:pending, transaction_ref()} | term()
Link to this type on_error() View Source
on_error() :: {:error, error_reason()}

Unique reference of an entity.

Link to this type revision() View Source
revision() :: term()

The revision of the state of an entity.

The state of an entity at a specific revision.

Module implementing the Traktor.Store behaviour. An in memory store is provided with the package.

Link to this type transaction() View Source
transaction() :: term()

A transaction contains all the information required to commit an action.

Link to this type transaction_ref() View Source
transaction_ref() :: term()

Unique reference of a transaction.

Link to this section Functions

Link to this function apply(action, state, args, store, ref, revision) View Source
apply(action(), state(), args(), store(), ref(), revision()) ::
  {:ok, state(), revision(), result :: any()} | on_error()

Runs both phases of the two phase commit: prepare/6 and commit/6.

Link to this function commit(action, state, transaction, store, ref, transaction_ref) View Source
commit(action(), state(), transaction(), store(), ref(), transaction_ref()) ::
  {:ok, state(), revision(), result :: any()} | on_error()

Executes the business logic and persists the result.

Link to this function prepare(action, state, args, store, ref, revision) View Source
prepare(action(), state(), args(), store(), ref(), revision()) ::
  {:ok, transaction(), transaction_ref()} | on_error()

Prepares the execution of the businses logic and persists it.