Filo.BatchCond (Filo v0.2.0)

Copy Markdown View Source

Hrana batch step conditions.

Each batch step may carry a condition gating whether it runs, expressed over the outcomes of earlier steps and the connection's autocommit state. This is how libsql clients build transactional batches: BEGIN, then statements guarded by ok of the previous step, a COMMIT guarded by ok of the last statement, and a ROLLBACK guarded by not ok of the commit.

Decoded form (tagged terms):

{:ok, step} | {:error, step} | {:not, cond} | {:and, [cond]} |
{:or, [cond]} | :is_autocommit

Summary

Functions

Decodes a Hrana BatchCond map into a tagged condition term.

Evaluates a condition. outcomes is the list of earlier step outcomes indexed by step number; autocommit? is the connection's current autocommit state.

Types

outcome()

@type outcome() :: :ok | :error | :skipped

t()

@type t() ::
  {:ok, non_neg_integer()}
  | {:error, non_neg_integer()}
  | {:not, t()}
  | {:and, [t()]}
  | {:or, [t()]}
  | :is_autocommit

Functions

decode(map)

@spec decode(map()) :: t()

Decodes a Hrana BatchCond map into a tagged condition term.

eval(arg1, outcomes, autocommit?)

@spec eval(t(), [outcome()], boolean()) :: boolean()

Evaluates a condition. outcomes is the list of earlier step outcomes indexed by step number; autocommit? is the connection's current autocommit state.