Filo.Batch (Filo v0.2.0)

Copy Markdown View Source

A decoded Hrana batch: an ordered list of steps, each a statement with an optional condition. run/3 executes the steps in order, gating each on its condition, and collects a Filo.BatchResult.

Summary

Types

Reports the connection's current autocommit state.

Runs one statement against the underlying connection.

t()

Functions

Decodes a Hrana Batch map into a Filo.Batch struct.

Runs each step in order, gated by its condition, returning a Filo.BatchResult.

Types

autocommit_fun()

@type autocommit_fun() :: (-> boolean())

Reports the connection's current autocommit state.

exec_fun()

@type exec_fun() :: (Filo.Stmt.t() ->
                 {:ok, Filo.StmtResult.t()} | {:error, Filo.Error.t()})

Runs one statement against the underlying connection.

step()

@type step() :: %{condition: Filo.BatchCond.t() | nil, stmt: Filo.Stmt.t()}

t()

@type t() :: %Filo.Batch{steps: [step()]}

Functions

decode(map)

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

Decodes a Hrana Batch map into a Filo.Batch struct.

run(batch, exec_fun, autocommit_fun)

@spec run(t(), exec_fun(), autocommit_fun()) :: Filo.BatchResult.t()

Runs each step in order, gated by its condition, returning a Filo.BatchResult.

exec_fun runs one statement; autocommit_fun reports the connection's current autocommit state, consulted by any is_autocommit conditions. A step whose condition is false is skipped — nil in both result and error positions.