Registry of live Filo.Stream processes — the find-or-start layer between the
HTTP plug and the per-stream processes.
A Filo.Streams supervisor owns a Registry (mapping stream_id to the
stream process) and a DynamicSupervisor (the streams themselves). The plug:
- calls
create/2when a request arrives with no baton, getting back a freshstream_idand initialseqto mint the first baton; - calls
lookup/2with thestream_iddecoded from a baton to find the stream for the next request.
Stream ids and initial sequence numbers are drawn from
:crypto.strong_rand_bytes/1, so they are unguessable across the full 64-bit
range, matching libsql.
Summary
Functions
Returns a specification to start this module under a supervisor.
Starts a new stream and registers it under a fresh, random stream_id.
Finds the stream process for stream_id, or :error if there is none.
Starts the streams supervisor.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec create( Supervisor.supervisor(), keyword() ) :: {:ok, non_neg_integer(), non_neg_integer(), pid()} | {:error, term()}
Starts a new stream and registers it under a fresh, random stream_id.
stream_opts are forwarded to Filo.Stream.start_link/1 (:executor,
:open_arg, :idle_timeout); the :seq and registry :name are supplied
here. Returns {:ok, stream_id, seq, pid}, or {:error, reason} if the
executor cannot open a connection.
@spec lookup(Supervisor.supervisor(), non_neg_integer()) :: {:ok, pid()} | :error
Finds the stream process for stream_id, or :error if there is none.
@spec start_link(keyword()) :: Supervisor.on_start()
Starts the streams supervisor.
Required option :name is the supervisor's registered name; the Registry and
DynamicSupervisor are registered under names derived from it.