Issho.Transaction (Issho v0.1.0)

Copy Markdown View Source

The envelope of a change to a document, the same for every engine:

%{
  "id" => "4f1c…",          # unique, chosen by the author; a retry reuses it
  "epoch" => "9a0b…",       # the document's epoch the author saw
  "base_revision" => 41,    # the revision the author saw
  "ops" => [...]            # the engine's operations, opaque to Issho
}

The authority gives each accepted transaction the next revision and its author, and keeps a receipt of its id: the same transaction sent again (after a lost reply, or from an offline queue) is answered with its revision and applied once. A different transaction with an id already used is refused.

Summary

Functions

Checks a transaction's envelope against the document's epoch and revision.

A digest of what a transaction does and who made it, to tell a retry from a different transaction that reuses an id.

A new random id, for epochs and transactions.

The most operations in one transaction.

Types

t()

@type t() :: %{required(String.t()) => term()}

Functions

check(arg1, current_epoch, revision)

@spec check(term(), String.t(), non_neg_integer()) :: :ok | {:error, atom()}

Checks a transaction's envelope against the document's epoch and revision.

digest(transaction, author)

@spec digest(t(), String.t()) :: String.t()

A digest of what a transaction does and who made it, to tell a retry from a different transaction that reuses an id.

id()

@spec id() :: String.t()

A new random id, for epochs and transactions.

max_ops()

@spec max_ops() :: pos_integer()

The most operations in one transaction.