H.HTTP.SSE (H v0.3.0)

Copy Markdown View Source

Chunked Server-Sent Events (text/event-stream) transport loop.

Handles:

  • Optional Last-Event-ID header / last_event_id query parameter parsing.
  • Initial atomic snapshot or missed commit ring replay.
  • Zero-copy ProcBin {:commit_frame, seq, bin} and ID-less {:ephemeral_frame, bin} streaming.
  • Bounded slow-client backpressure via mailbox drain and fresh snapshot replacement.
  • Periodic : keepalive comments and clean exit on socket write error or {:close_sse, reason}.

Summary

Functions

Subscribes the current request process to (sid, cid) via daemon and streams SSE frames until the client disconnects or {:close_sse, reason} is received.

Subscribes the current request process to catalog session events via daemon and streams initial snapshot + live catalog SSE frames until the client disconnects or {:close_sse, reason} is received.

Functions

stream(conn, sid, cid, opts \\ [])

@spec stream(Plug.Conn.t(), String.t(), String.t(), keyword()) :: Plug.Conn.t()

Subscribes the current request process to (sid, cid) via daemon and streams SSE frames until the client disconnects or {:close_sse, reason} is received.

stream_sessions(conn, opts \\ [])

@spec stream_sessions(Plug.Conn.t(), keyword()) :: Plug.Conn.t()

Subscribes the current request process to catalog session events via daemon and streams initial snapshot + live catalog SSE frames until the client disconnects or {:close_sse, reason} is received.