Documentation
¶
Overview ¶
Package sse reads Server-Sent Events streams.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Scan ¶
Scan reads a Server-Sent Events stream from r, invoking fn for each non-empty "data:" payload until the stream ends or fn returns an error. The OpenAI "[DONE]" sentinel and empty payloads are skipped, so fn only sees JSON chunks.
Called from a task (see package tasks), Scan holds the session's loop while it parses and while fn runs, and lets go of it only while it waits for the next bytes of r: each read of r goes through tasks.Await. So a streamed response holds its session up for the handling of each chunk and never for the network, and fn may push frames. Called from a goroutine that is not a task, it reads plainly.
Types ¶
This section is empty.