pager

package
v1.8.10 Latest Latest
Warning

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

Go to latest
Published: May 29, 2022 License: MIT Imports: 2 Imported by: 44

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasePager

type BasePager struct {
	PageSize    int64
	PageNumber  int64
	HasNext     bool
	TokenBucket *tokenbucket.Bucket
}

func NewBasePager

func NewBasePager() *BasePager

func (*BasePager) IncrPageNumber

func (p *BasePager) IncrPageNumber(pn int64)

func (*BasePager) Next

func (p *BasePager) Next() bool

func (*BasePager) Offset

func (p *BasePager) Offset() int64

func (*BasePager) SetPageSize

func (p *BasePager) SetPageSize(ps int64)

func (*BasePager) SetRate

func (p *BasePager) SetRate(r float64)

type Pager

type Pager interface {
	// 判断是否还有下一页
	Next() bool
	// 获取当前页面的数据, 注意必须先调用Next, 从而判断是否存在下一页
	Scan(context.Context, any) error
	// 设置页面打小, 默认20, 一页数据20条
	SetPageSize(ps int64)
	// 设置读取速率, 默认1, 每秒发起一次请求
	SetRate(r float64)
}

分页迭代器

for p.Next() {
	p.Scan(ctx, dst);
}

Jump to

Keyboard shortcuts

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