sse

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package sse is a real Server-Sent Events event framer (WHATWG event stream model), not an OpenAI-only "data: " line stripper. It accumulates consecutive `data:` field values (joined with newlines), dispatches one frame per blank line, carries an `event:` name onto the frame, and ignores `:`-comment lines and unknown fields. It deliberately does NOT interpret API sentinels such as `[DONE]`: that is a semantic StreamDecoder's job, so `[DONE]` is emitted as an ordinary frame's Data. It is byte-level wire framing only and knows nothing about LLM semantics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeStreamFrames

func DecodeStreamFrames(body io.ReadCloser) (*stream.StreamReader[stream.StreamFrame], error)

DecodeStreamFrames frames an SSE body into raw stream.StreamFrames. It owns body: the returned reader's Close closes body; on an early error (nil body) there is no body to close. Framing itself is lazy — each Next() reads lines until it completes a frame (blank line) or reaches EOF; a trailing unterminated event with buffered data is flushed once at EOF rather than discarded.

func Framer

func Framer() codec.StreamFramer

Framer returns the package's StreamFramer as an interface value, for callers that inject an codec.StreamFramer.

Types

type FramerError

type FramerError struct {
	Reason string
	Err    error
}

FramerError wraps a stream read failure surfaced while framing. Typed per the repo rule so callers can errors.As it and Unwrap the underlying I/O cause.

func (*FramerError) Error

func (e *FramerError) Error() string

func (*FramerError) Unwrap

func (e *FramerError) Unwrap() error

Jump to

Keyboard shortcuts

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