sse

package
v0.3.0-beta.31 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package sse provides shared server-sent event decoding helpers.

Index

Constants

View Source
const MemoryContextRedaction = "[memory-context redacted]"

MemoryContextRedaction is emitted when prompt-only memory fences are removed.

Variables

View Source
var ErrStop = errors.New("sse: stop stream")

ErrStop stops SSE decoding without surfacing an error.

Functions

func Decode

func Decode(ctx context.Context, reader io.Reader, handler Handler) error

Decode reads one SSE stream from reader until EOF, context cancellation, or a handler error.

Decode never closes reader; the caller owns its lifecycle. Context cancellation interrupts a blocked Read only when the underlying reader is context-aware, such as an HTTP response body whose request carries ctx. The handler runs synchronously and must return before Decode can continue or stop.

func ScrubMemoryContextBytes

func ScrubMemoryContextBytes(raw []byte) []byte

ScrubMemoryContextBytes removes prompt-only memory fences from raw SSE bytes.

func ScrubMemoryContextString

func ScrubMemoryContextString(value string) string

ScrubMemoryContextString removes literal and JSON-escaped memory context fences.

Types

type Event

type Event struct {
	ID    string
	Event string
	Data  json.RawMessage
}

Event is one parsed server-sent event frame.

type Handler

type Handler func(Event) error

Handler consumes parsed SSE frames.

Jump to

Keyboard shortcuts

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