internal

package
v2.5.1-clf-20230912 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidToken = errors.New("invalid page token")
	ErrOutOfRange   = errors.New("out of range")
)

Functions

func ListNodeStatuses

func ListNodeStatuses(pageSize int, pageToken string, listFn ListNodeStatusFn) (stats []types.NodeStatus, nextPageToken string, total int, err error)

func ValidatePageToken

func ValidatePageToken(pageSize int, token string) (page int, err error)

Types

type ListNodeStatusFn

type ListNodeStatusFn = func(start, end int) (stats []types.NodeStatus, total int, err error)

if start is out of range, must return ErrOutOfRange

type PageToken

type PageToken struct {
	Page int
	Size int
}

PageToken is simple internal representation for coordination requests and responses in a paginated API It is inspired by the Google API Design patterns https://cloud.google.com/apis/design/design_patterns#list_pagination https://google.aip.dev/158

func NewPageToken

func NewPageToken(b64enc string) (*PageToken, error)

b64enc must be the base64 encoded token string, corresponding to [PageToken.Encode()]

func (*PageToken) Encode

func (pr *PageToken) Encode() string

Encode the token in base64 for transmission for the wire

Jump to

Keyboard shortcuts

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