stream

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 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 stream follows a session's events live: the WebSocket with the bearer token, resumed from the last sequence number after a drop, with a fall back to polling the events endpoint when WebSockets are blocked.

Index

Constants

This section is empty.

Variables

View Source
var ErrStop = errors.New("stop following")

ErrStop is returned by a handler to end the follow cleanly.

Functions

func Follow

func Follow(ctx context.Context, c *api.Client, id string, o Options, handle func(api.Event) error) error

Follow delivers every event after o.Since to handle, in order, until handle returns an error (ErrStop ends it cleanly: Follow then returns nil), ctx ends, or a failure that retrying can't fix (not signed in, no access) happens.

func History

func History(ctx context.Context, c *api.Client, id string, since int) ([]api.Event, error)

History reads every event after since, page by page. A server that ignores `limit` answers the whole log in one page.

func Tail

func Tail(ctx context.Context, c *api.Client, id string, n int) ([]api.Event, error)

Tail reads the last n events. It asks the server for `tail=n`, and keeps the last n client side in case the server ignores it and answers the whole log.

Types

type Options

type Options struct {
	// Since is the last sequence number already seen; only later events are delivered.
	Since int
	// Backoff is the wait before reconnect attempt n (0-based). Default 0.5 s doubling to 15 s.
	Backoff func(n int) time.Duration
	// Sleep waits d or until ctx ends. Default api.SleepContext.
	Sleep func(context.Context, time.Duration) error
	// MaxDialFailures is how many connections in a row may fail before polling takes over.
	MaxDialFailures int
	// PollInterval is the polling fall back's period. Default 3 s.
	PollInterval time.Duration
	// Notice reports reconnects and the fall back (one line, no newline).
	Notice func(string)
	// PingEvery keeps an idle connection honest. Zero: 25 s.
	PingEvery time.Duration
}

Options tune a Follow.

Jump to

Keyboard shortcuts

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