pagination

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package pagination provides primitives for implementing AIP pagination.

See: https://google.aip.dev/158 (Pagination).

Index

Constants

This section is empty.

Variables

View Source
var Generator = NewTokenGenerator()
View Source
var InvalidTokenErr = status.Errorf(
	codes.InvalidArgument,
	"The field `page_token` is invalid.")

InvalidTokenErr is the error returned if the token provided is not parseable by the TokenGenerator.

Functions

func ForIndex

func ForIndex(i int32) string

func GetIndex

func GetIndex(s string) (int32, error)

Types

type TokenGenerator

type TokenGenerator interface {
	ForIndex(int32) string
	GetIndex(string) (int32, error)
}

TokenGenerator generates a page token for a given index.

func NewTokenGenerator

func NewTokenGenerator() TokenGenerator

NewTokenGenerator provides a new instance of a TokenGenerator.

func TokenGeneratorWithSalt

func TokenGeneratorWithSalt(salt string) TokenGenerator

TokenGeneratorWithSalt provieds an instance of a TokenGenerator which uses the given salt.

Jump to

Keyboard shortcuts

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