resumablestream

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package resumablestream reconnects resource-level SSE streams after retryable failures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Child

type Child[T any] interface {
	Next() bool
	Current() T
	Err() error
	LastEventID() string
	Close() error
}

Child is one connection in a resumable stream.

type Open

type Open[T any] func(context.Context, string, bool) Child[T]

Open starts a child stream at the supplied event cursor. resume is true once the cursor came from a yielded event rather than the initial request.

type Stream

type Stream[T any] struct {
	// contains filtered or unexported fields
}

Stream reconnects child streams while retaining the latest yielded event cursor.

func New

func New[T any](ctx context.Context, lastEventID string, open Open[T], terminal func(T) bool) *Stream[T]

New creates a resumable stream. Connections are opened lazily by Next.

func NewError

func NewError[T any](ctx context.Context, err error) *Stream[T]

NewError creates a stream that has already failed.

func (*Stream[T]) Close

func (s *Stream[T]) Close() error

Close cancels pending work and closes the active child stream.

func (*Stream[T]) Current

func (s *Stream[T]) Current() T

Current returns the most recently yielded event.

func (*Stream[T]) Err

func (s *Stream[T]) Err() error

Err returns the terminal non-retryable or context error, if any.

func (*Stream[T]) LastEventID

func (s *Stream[T]) LastEventID() string

LastEventID returns the latest non-empty cursor from a yielded child event.

func (*Stream[T]) Next

func (s *Stream[T]) Next() bool

Next advances to the next decoded event, reconnecting as needed.

Jump to

Keyboard shortcuts

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