sse

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 27, 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, body io.ReadCloser, handler Handler) error

Decode reads one SSE stream from body until EOF, context cancellation, or a handler error. Decode closes body only when ctx is canceled so a blocked Read can unblock and observe the cancellation.

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