sse

package
v0.3.0-beta.32 Latest Latest
Warning

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

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

Documentation

Overview

Package sse provides shared server-sent event decoding helpers.

Index

Constants

This section is empty.

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.

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