Shared Server-Sent Events parsing for Arcanum adapters.
Provides the common SSE stream transform and chunk/line parsing. Adapters supply their own event-to-delta conversion via a callback.
Summary
Functions
Parses a single SSE chunk into a list of events.
Transforms a raw SSE stream into a stream of parsed events.
Functions
Parses a single SSE chunk into a list of events.
@spec stream( Enumerable.t(), keyword() ) :: Enumerable.t()
Transforms a raw SSE stream into a stream of parsed events.
Each chunk is split into SSE lines. Lines matching "data: " prefix
are JSON-decoded and passed to parse_event_fn. The stream halts
when parse_event_fn returns :done or the done_sentinel is encountered.
Options
:parse_event—fn json_map -> {:data, delta} | :done | :skip(required):done_sentinel— string that signals end of stream (e.g."[DONE]"), optional