# `OctaStar.ServerSentEventGenerator`

Plug-based Datastar Server-Sent Event generator.

This module is the Elixir equivalent of the SDK ADR's
`ServerSentEventGenerator` namespace.

# `check_connection`

```elixir
@spec check_connection(Plug.Conn.t()) ::
  {:ok, Plug.Conn.t()} | {:error, Plug.Conn.t()}
```

Checks whether a chunked SSE connection still accepts writes.

# `format_event`

```elixir
@spec format_event(String.t(), [String.t()] | String.t(), keyword()) :: String.t()
```

Formats a raw SSE event.

# `send`

```elixir
@spec send(Plug.Conn.t(), String.t(), [String.t()] | String.t(), keyword()) ::
  {:ok, Plug.Conn.t()} | {:error, term()}
```

Sends a raw SSE event.

# `send!`

```elixir
@spec send!(Plug.Conn.t(), String.t(), [String.t()] | String.t(), keyword()) ::
  Plug.Conn.t()
```

Sends a raw SSE event and raises on failure.

# `start`

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
