SSE Codec
Server-Sent Events codec — event-record stream ↔ byte iterables. The encoder produces one SSE frame per item (event: <type>\ndata: <json>\n\n).
Why use this
- Drop-in for
text/event-stream— registerSse.Encoderon anHttp.Serverto expose any async iterable as an SSE stream. - Typed event records — items carry
{ event, data }, so producers stay schema-checked. - Implements the
Codec.Encoderabstract — consumers that depend onCodec.Encoderget SSE for free at the import boundary.
Kinds
| Kind | Purpose |
|---|---|
Sse.Encoder | Encode an async iterable of event records into SSE frames. |
Example
kind: Telo.Application
metadata: { name: sse-stream, version: 1.0.0 }
imports:
Sse: std/sse-codec@latest
---
kind: Http.Server
metadata: { name: Stream }
encoders:
text/event-stream: { kind: Sse.Encoder, name: Out }