A single Hrana-over-HTTP stream: one GenServer owning one executor
connection and the stream's baton sequence number.
In libsql's server a stream is a passive struct guarded by a mutex; each HTTP
request acquires it, runs its pipeline, then releases it with a fresh
baton. Filo collapses that into a process: the connection lives in the
GenServer, and the mailbox serializes requests for free.
Sequence numbers
Every request must present the seq the server last handed out. A successful
run advances seq by one, so each baton is single-use and requests on a
stream are strictly serial. A request that presents the wrong seq is
rejected as {:error, :baton_reused} without touching the connection.
Lifecycle
start_link/1opens the connection through the executor; if the executor cannot open one, the start fails with{:open_failed, error}.- A
closerequest releases the connection (viaFilo.Request) and the process stops normally. - After
:idle_timeoutof inactivity the stream expires: it closes its connection and stops. Every successful run resets the timer.
The process is :temporary — a dead stream is not restarted; the client must
open a new one.
Summary
Functions
Runs a pipeline of decoded Hrana requests against the stream.
Runs a decoded Hrana batch map against the stream for a cursor, returning the
raw Filo.BatchResult (which the caller streams as cursor entries) and the
rotated sequence. Like run/3, a mismatched seq is {:error, :baton_reused}.
The stream stays open.
Starts a stream.
Functions
@spec run(GenServer.server(), non_neg_integer(), [map()], keyword()) :: {:ok, Filo.Request.status(), [map()], non_neg_integer() | nil} | {:error, :baton_reused}
Runs a pipeline of decoded Hrana requests against the stream.
seq must match the sequence the stream currently expects. On success returns
{:ok, status, results, next_seq} where status is :open (the stream
continues, next_seq is the rotated sequence) or :closed (a close request
released the connection, next_seq is nil). A mismatched seq returns
{:error, :baton_reused}.
opts pass through to Filo.Request.handle/4's result encoders (rows: :json for the
JSON transports' pre-encoded row fragments; default :maps for protobuf).
@spec run_cursor(GenServer.server(), non_neg_integer(), map()) :: {:ok, Filo.BatchResult.t(), non_neg_integer()} | {:error, :baton_reused}
Runs a decoded Hrana batch map against the stream for a cursor, returning the
raw Filo.BatchResult (which the caller streams as cursor entries) and the
rotated sequence. Like run/3, a mismatched seq is {:error, :baton_reused}.
The stream stays open.
@spec start_link(keyword()) :: GenServer.on_start()
Starts a stream.
Options:
:executor(required) — theFilo.Executormodule.:open_arg— host context passed toexecutor.open(defaultnil).:open_context— the:authorizecontext threaded toexecutor.open/2(defaultnil). SeeFilo.Executor.open/2.:seq(required) — the initial sequence number.:idle_timeout— inactivity timeout in ms (default10000).:name— a standardGenServername (e.g. aRegistryvia-tuple).