Two Phase Commit v0.1.0 Traktor.Store behaviour View Source

The store specification.

The store is responsible for persisting the state and transactions of an entity and enforces the constraints to apply transactions sequentially.

A store used in the two-phase-commit approch must export hte following three functions:

  • prepare/4 function which persists the prepared transaction;
  • commit/3 function which persit the updated state;
  • get/2 function which retrieves the current state of an entity with an optional pending transaction.

Link to this section Summary

Types

Module implementing the Traktor.Action behaviour

Store error

Unique reference of an entity

The revision of the state of an entity

The state of an entity at a specific revision

t()

Module implementing the Traktor.Store behaviour

A transaction contains all the information required to commit an action

Unique reference of a transaction

Link to this section Types

Module implementing the Traktor.Action behaviour.

Link to this type on_error() View Source
on_error() :: {:error, any()}

Store error.

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.

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 Callbacks

Link to this callback commit(ref, transaction_ref, state) View Source
commit(ref(), transaction_ref(), state()) :: {:ok, revision()} | on_error()
Link to this callback get(ref) View Source
get(ref()) ::
  {:ok, revision(), state()}
  | {:pending, state(), action(), transaction(), transaction_ref()}
Link to this callback prepare(ref, revision, module, transaction) View Source
prepare(ref(), revision(), module(), transaction()) ::
  {:ok, transaction_ref()} | on_error()