pagination

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeToken

func DecodeToken(token string) (name, filter string, err error)

DecodeToken decodes an opaque page token into its name and filter parts.

func EncodeToken

func EncodeToken(name, filter string) (token string, err error)

EncodeToken encodes a name + filter to an opaque page token

Types

type Batcher

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

Batcher suggests dynamic batch sizes for list queries.

func NewBatcher

func NewBatcher(want, min, max int) *Batcher

NewBatcher creates a new batcher for the given requested page size.

func (*Batcher) Next

func (b *Batcher) Next() int

Next returns the recommended next batch size to query.

func (*Batcher) Update

func (b *Batcher) Update(matched, total int)

Update updates the Batcher based on the results of the last batch. `matched` is the number of items successfully matched by filters. `total` is the total number of rows last fetched. This calculates a new value to be used for calls to Next.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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