OctaStar. ServerSentEventGenerator
(octa_star v0.2.0)
Copy Markdown
Plug-based Datastar Server-Sent Event generator.
This module is the Elixir equivalent of the SDK ADR's
ServerSentEventGenerator namespace.
Summary
Functions
Checks whether a chunked SSE connection still accepts writes.
Formats a raw SSE event.
Sends a raw SSE event.
Sends a raw SSE event and raises on failure.
Starts an SSE response.
Functions
@spec check_connection(Plug.Conn.t()) :: {:ok, Plug.Conn.t()} | {:error, Plug.Conn.t()}
Checks whether a chunked SSE connection still accepts writes.
Formats a raw SSE event.
@spec send(Plug.Conn.t(), String.t(), [String.t()] | String.t(), keyword()) :: {:ok, Plug.Conn.t()} | {:error, term()}
Sends a raw SSE event.
@spec send!(Plug.Conn.t(), String.t(), [String.t()] | String.t(), keyword()) :: Plug.Conn.t()
Sends a raw SSE event and raises on failure.
@spec start(Plug.Conn.t()) :: Plug.Conn.t()
Starts an SSE response.
It sets the required Datastar/SSE headers and starts a chunked 200 response.
Connection: keep-alive is only set for HTTP/1.1 connections when the Plug
adapter exposes the request protocol.