pagination

package
v1.0.90 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package pagination owns the bounded cursor walk shared by built-in and externally assembled commands.

Index

Constants

View Source
const CollectAllHardPageBound = 100

CollectAllHardPageBound caps complete-set collections. It is deliberately tighter than the user-facing --page-limit maximum (1000): such a collection holds every page in memory before the caller's writes run, so its upper bound is a host resource decision, not a display preference. Value from the extension design's Phase 0 (owner plan §8.3).

It lives here because the production host adapter and the commandtest recorder must enforce the same bound: a business command whose tests pass at 300 pages but fails in production at 101 is worse than one that fails in both.

Variables

This section is empty.

Functions

func WaitContext

func WaitContext(ctx context.Context, delay time.Duration) error

WaitContext waits for one inter-page delay and observes cancellation.

Types

type CursorError

type CursorError struct {
	Kind  CursorErrorKind
	Page  int
	Token string
}

CursorError reports an invalid cursor transition.

func (*CursorError) Error

func (e *CursorError) Error() string

type CursorErrorKind

type CursorErrorKind uint8

CursorErrorKind identifies an invalid cursor transition returned by an API.

const (
	// CursorMissing means the API reported another page without a cursor.
	CursorMissing CursorErrorKind = iota + 1
	// CursorRepeated means the API returned a cursor already observed by the walk.
	CursorRepeated
)

type Fetch

type Fetch func(ctx context.Context, pageNumber int, pageToken string) (hasMore bool, nextToken string, err error)

Fetch obtains and consumes one page, then returns its cursor state.

type Options

type Options struct {
	InitialToken string
	MaxPages     int
	Delay        time.Duration
	Fetch        Fetch
	Wait         func(context.Context, time.Duration) error
}

Options configures one bounded cursor walk.

type State

type State struct {
	Complete  bool
	Pages     int
	NextToken string
}

State describes the completed portion of a cursor walk.

func Walk

func Walk(ctx context.Context, options Options) (State, error)

Walk follows page tokens until exhaustion or MaxPages is reached.

type WaitError

type WaitError struct{ Err error }

WaitError reports cancellation or failure while delaying between pages.

func (*WaitError) Error

func (e *WaitError) Error() string

func (*WaitError) Unwrap

func (e *WaitError) Unwrap() error

Jump to

Keyboard shortcuts

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