Bier.Events.SSE (bier v0.1.0)

Copy Markdown View Source

Pure Server-Sent Events wire encoding for the realtime events endpoint.

Frames map a Postgres NOTIFY onto SSE's native fields: the channel name is the event: field and the payload is carried verbatim in data: lines — no envelope is invented. A payload containing line breaks (\n, \r\n, or a bare \r — all line terminators to an SSE parser) is split across consecutive data: lines, which clients reassemble joined with \n; a raw CR left inside a data: line would instead be treated as a line break by the client's parser, silently truncating the payload after it.

Summary

Functions

One event frame: event: = channel, data: = payload verbatim.

Keepalive comment written after a configured interval of silence.

Opening bytes of every stream: reconnect hint + a comment frame.

Functions

frame(channel, payload)

@spec frame(String.t(), String.t()) :: iodata()

One event frame: event: = channel, data: = payload verbatim.

heartbeat()

@spec heartbeat() :: iodata()

Keepalive comment written after a configured interval of silence.

preamble()

@spec preamble() :: iodata()

Opening bytes of every stream: reconnect hint + a comment frame.