pagination

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPageSize uint32 = 20
	MaximumPageSize uint32 = 1000
	CursorDuration         = 12 * time.Hour
)

Variables

View Source
var (
	ErrMissingExpiration  = errors.New("cursor does not have an expires timestamp")
	ErrCursorExpired      = errors.New("cursor has expired and is no longer useable")
	ErrUnparsableToken    = errors.New("could not parse the next page token")
	ErrTokenQueryMismatch = errors.New("cannot change query parameters during pagination")
	ErrPageSizeTooLarge   = errors.New("page size is greater than the maximum allowed page size")
)

Functions

This section is empty.

Types

type Cursor

type Cursor struct {
	Start int64
	End   int64
	Size  uint32
	Exp   int64
}

func New

func New(startIndex, endIndex int64, pageSize uint32) *Cursor

func Parse

func Parse(token string) (cursor *Cursor, err error)

func (Cursor) Expires

func (c Cursor) Expires() time.Time

func (*Cursor) GobDecode

func (c *Cursor) GobDecode(data []byte) error

func (Cursor) GobEncode

func (c Cursor) GobEncode() ([]byte, error)

func (Cursor) HasExpired

func (c Cursor) HasExpired() (bool, error)

func (Cursor) IsZero

func (c Cursor) IsZero() bool

func (Cursor) MarshalText

func (c Cursor) MarshalText() ([]byte, error)

func (Cursor) PageToken

func (c Cursor) PageToken() (_ string, err error)

func (Cursor) PrevPage

func (c Cursor) PrevPage() *Cursor

func (*Cursor) UnmarshalText

func (c *Cursor) UnmarshalText(data []byte) (err error)

Jump to

Keyboard shortcuts

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