TCC.Transaction (toccata v0.1.0)

Copy Markdown View Source

Core transaction coordinator for TCC protocol.

Manages the lifecycle of a distributed transaction, coordinating the Try, Confirm, and Cancel phases across multiple services.

Summary

Functions

Adds an action to the transaction.

Executes the transaction following the TCC protocol.

Creates a new transaction.

Types

t()

@type t() :: %TCC.Transaction{
  actions: [TCC.Action.t()],
  final_hooks: MapSet.t(),
  on_cancel_error: :raise | module(),
  opts: map(),
  tracers: MapSet.t(),
  transaction_id: String.t()
}

Functions

add_action(transaction, action)

@spec add_action(t(), TCC.Action.t()) :: t()

Adds an action to the transaction.

execute(transaction, params)

@spec execute(t(), any()) :: {:ok, map(), any()} | {:error, atom(), any(), map()}

Executes the transaction following the TCC protocol.

new(opts \\ [])

@spec new(keyword()) :: t()

Creates a new transaction.