page

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package page implements bounded keyset-pagination cursors.

Index

Constants

View Source
const (
	DefaultLimit    = 100
	MaxLimit        = 500
	MaxCursorLength = 512
)

Variables

View Source
var (
	// ErrInvalidCursor reports malformed, mismatched, or unsupported cursor input.
	ErrInvalidCursor = errors.New("page: invalid cursor")
	// ErrInvalidLimit reports a collection limit outside the supported range.
	ErrInvalidLimit = errors.New("page: invalid limit")
)

Functions

func EncodeCursor

func EncodeCursor(resource, filters string, key Key) (string, error)

EncodeCursor encodes a versioned cursor bound to a resource and filter set.

func NormalizeLimit

func NormalizeLimit(value int) (int, error)

NormalizeLimit applies the documented default and maximum collection size.

Types

type Key

type Key struct {
	CreatedAt time.Time
	ID        string
}

Key is the descending created-at/resource-ID keyset position.

func DecodeCursor

func DecodeCursor(value, resource, filters string) (Key, error)

DecodeCursor verifies a cursor for the current resource and exact filters.

Jump to

Keyboard shortcuts

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