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

The action specification.

An action defines the business logic that is executed in a two-phase-commit approch. A module providing the busness logic must export the following two functions:

  • prepare/2 function that prepares the execution of the businses logic;
  • commit/2 function that executes the business logic.

    Calling the two functions after each other will run the business logic and return the result.

    with {:ok, transaction} <- prepare(state, args),
         {:ok, new_state, result} <- commit(state, transaction) do
      {:ok, new_state, result}
    end

Link to this section Summary

Types

Specific arguments required to apply an action to an entity

Action error

Data resulting from commiting an action that is not included in the entity state

The state of an entity at a specific revision

t()

Module implementing the Traktor.Action behaviour

A transaction contains all the information required to commit an action

Link to this section Types

Specific arguments required to apply an action to an entity.

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

Action error.

Data resulting from commiting an action that is not included in the entity state.

The state of an entity at a specific revision.

Module implementing the Traktor.Action behaviour.

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

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

Link to this section Callbacks

Link to this callback commit(state, transaction) View Source
commit(state(), transaction()) :: {:ok, state(), result()} | on_error()
Link to this callback prepare(state, args) View Source
prepare(state(), args()) :: {:ok, transaction()} | on_error()