paginator

package
v0.0.0-...-89f4574 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNilPageToken is returned when a PageToken is nil
	ErrNilPageToken = errors.New("nil PageToken")
)

Functions

func DecodePageToken

func DecodePageToken(req string) (*drghs_v1.PageToken, error)

DecodePageToken translates a token from a drghs_v1 api call to Go

func GetPageSize

func GetPageSize(reqPageSize int) int

GetPageSize returns the page size, setting a maximum page size of 100

func MakeFirstPageToken

func MakeFirstPageToken(t time.Time, idx int) (string, error)

MakeFirstPageToken creates a new string page token for the given key/time

func MakeNextPageToken

func MakeNextPageToken(prev *drghs_v1.PageToken, idx int) (string, error)

MakeNextPageToken creates a new string page token at the given index, based on prev

Types

type Slo

type Slo struct {
	Log *logrus.Logger
	// contains filtered or unexported fields
}

Slo is a paginator for SLO rules

func (*Slo) CreatePage

func (p *Slo) CreatePage(withItems []*leif.SLORule) (time.Time, error)

CreatePage makes a new page in the paginator It uses the current time as key and add the items to that key

func (*Slo) GetPage

func (p *Slo) GetPage(key time.Time, numItems int) ([]*leif.SLORule, int, error)

GetPage gets the next numItems number of items from the given page/key Key should be the key returned by a call to CreatePage GetPage returns the items and the current index in the total items in the page

func (*Slo) Init

func (p *Slo) Init() error

Init must be the first call to the paginator

func (*Slo) PurgeOldRecords

func (p *Slo) PurgeOldRecords()

PurgeOldRecords removes all pages that are more than 2 hours old

type Strings

type Strings struct {
	Log *logrus.Logger
	// contains filtered or unexported fields
}

Strings is a paginator for strings

func (*Strings) CreatePage

func (p *Strings) CreatePage(withItems []string) (time.Time, error)

CreatePage makes a new page in the paginator It uses the current time as key and add the items to that key

func (*Strings) GetPage

func (p *Strings) GetPage(key time.Time, numItems int) ([]string, int, error)

GetPage gets the next numItems number of items from the given page/key Key should be the key returned by a call to CreatePage GetPage returns the items and the current index in the total items in the page

func (*Strings) Init

func (p *Strings) Init() error

Init must be the first call to the paginator

func (*Strings) PurgeOldRecords

func (p *Strings) PurgeOldRecords()

PurgeOldRecords removes all pages that are more than 2 hours old

Jump to

Keyboard shortcuts

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