WardrikHTTP. EventStream
(wardrik_http v0.1.0-rc.1)
Copy Markdown
Sends a streamed operation's events as server-sent events.
id: eyJhY21lL3RyaWFnZSI6NDF9
data: {"specversion":"1.0","type":"wardrik.run.completed",...}- An event that moves the cursor is sent with the new cursor as its
id. A client'sLast-Event-IDthen resumes after it. - An event that doesn't move the cursor, like a delta, has no
id. - While idle, a comment is sent every
:keepalivemilliseconds. This keeps proxies from closing the stream and detects clients that have gone. - Before each comment,
:alive?is called. The stream ends if it returnsfalse.
The stream also ends when the client disconnects.
Summary
Functions
Streams events, as {event, cursor} pairs, on conn.
Functions
@spec serve(Plug.Conn.t(), Enumerable.t(), keyword()) :: Plug.Conn.t()
Streams events, as {event, cursor} pairs, on conn.
Options
:after- the cursor the events are read after, ornil.:keepalive- required. Milliseconds of quiet before a comment is sent.:alive?- required. A zero-arity function. The stream ends when it returnsfalse.