sseutil

package
v0.37.4 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package sseutil provides shared utilities for SSE stream handling across LLM provider implementations.

Index

Constants

This section is empty.

Variables

View Source
var ErrIdleTimeout = fmt.Errorf("stream idle timeout: no data received")

ErrIdleTimeout is returned when no data is received within the timeout.

Functions

This section is empty.

Types

type IdleTimeoutReader

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

IdleTimeoutReader wraps an io.Reader and returns an error if no data is received within the timeout duration. The timer resets on every successful Read that returns data. This protects against stalled SSE streams where the connection stays open but stops sending events.

func NewIdleTimeoutReader

func NewIdleTimeoutReader(r io.Reader, timeout time.Duration) *IdleTimeoutReader

NewIdleTimeoutReader creates a reader that errors after timeout of inactivity. A timeout of 0 disables the idle check (passes reads through directly).

func (*IdleTimeoutReader) Read

func (itr *IdleTimeoutReader) Read(p []byte) (int, error)

Read implements io.Reader. Returns ErrIdleTimeout if the underlying reader doesn't produce data within the timeout.

Jump to

Keyboard shortcuts

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