stream

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClosedSession  = errors.New("stream session is closed")
	ErrUnknownSession = errors.New("unknown stream session")
)

Functions

func Finish

func Finish(sessionID string) error

func Register

func Register(h Handler) string

func Unregister

func Unregister(sessionID string)

Types

type Handler

type Handler func(ctx context.Context, event *llm.StreamEvent) error

Handler is invoked for every event in the session. Returning an error can be used to signal processing problems.

func New

func New(ctx context.Context, sessionID string) (Handler, error)

func PrepareStreamHandler

func PrepareStreamHandler(ctx context.Context, id string) (Handler, func(), error)

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

func NewProvider

func NewProvider() *Registry

func (*Registry) Finish

func (p *Registry) Finish(sessionID string) error

Finish marks the session as closed and unregisters it. Idempotent: calling multiple times is safe.

func (*Registry) New

func (p *Registry) New(ctx context.Context, sessionID string) (Handler, error)

New returns a safe event handler for the given sessionID. After Finish(sid) is called, the returned handler will reject further events with ErrClosedSession.

func (*Registry) Register

func (p *Registry) Register(h Handler) string

Register stores a session handler and returns a sessionID.

func (*Registry) Unregister

func (p *Registry) Unregister(sessionID string)

Jump to

Keyboard shortcuts

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