default_event_options : EventOptions
Sse
Sse :: # (opaque)
Typed server-sent event sources.
Applications describe one finite transition at a time. The platform host owns scheduling, backpressure, framing buffers, compression, cancellation, and the lifetime of the retained source between transitions.
Validate an SSE event ID. IDs become Last-Event-ID request header
values on reconnect, so NUL and line endings are rejected rather than
normalized.
clear_event_id : EventId
Emit an empty id: field, clearing the client's retained reconnect ID.
retry_after : U64 -> Retry
Ask the client to use a new reconnect delay, in milliseconds.
Retain typed application state behind a private affine source. Every invocation returns the next source owner; the host never copies or reconstructs application state.
advance_for_host! : Source, U64 => StepToHost
Platform ABI operation; not an application API.
drop_source_for_host! : Source => { }
Platform ABI operation; consuming the value lets ARC release the complete retained application state graph.
drop_step_for_host! : StepToHost => { }
Platform ABI operation used when a returned step cannot be installed.
Source
:= [Source(Box(U64 => StepToHost))]
EventId
:= [AbsentEventId, ClearEventId, SetEventId(Str)]
Retry
:= [NoRetry, RetryAfter(U64)]
EventOptions
:= {
id : EventId,
retry : Retry,
}
Event
:= [Event(List(U8))]
Return the canonical framed bytes for a finite response. Applications normally pass events to an SSE response helper instead of inspecting this representation directly.
Construct a named SSE event containing one keyed data value. The common single-line path creates the complete frame once; multiline values fall back to canonical repeated keyed fields.
Construct one named SSE event from already-keyed data fields. Event
names have line endings removed so they cannot create a second SSE
field. Every logical line in a data field is emitted as its own
data: line.
named_with : Str, List(Str), EventOptions -> Event
Construct a named event with optional reconnect ID and retry metadata.
The ID is already validated by event_id; all data
values remain canonical data: fields.
Construct one SSE data event. Embedded CR, LF, and CRLF line endings
are normalized and emitted as one data: field per logical line.
Wake
:= [Immediately, After(U64)]
Step
:= [
Emit({ event : Event, state : state, wake : Wake }),
Wait({ state : state, wake : Wake }),
End,
]
StepToHost
:= [
EmitToHost({ item : List(U8), source : Source, wait_millis : U64 }),
WaitToHost({ source : Source, wait_millis : U64 }),
EndToHost,
ErrorToHost(Str),
]