sse

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: BSD-2-Clause Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sse reads Server-Sent Events streams.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Scan

func Scan(r io.Reader, fn func(data string) error) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL