limit

package
v0.0.0-...-cca27e0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StopErr = errors.New("stop limit.Every")

Functions

This section is empty.

Types

type Counter

type Counter interface {
	Add(int64) int64
	Count() int64
	Reset()
}

Counter 计数器接口

func LoadCounter

func LoadCounter(base int64) Counter

LoadCounter 基数计数器

func NewCounter

func NewCounter() Counter

NewCounter 计数器

type Every

type Every struct {
	// contains filtered or unexported fields
}

Every every

func NewEvery

func NewEvery(wait time.Duration, fn func() error) *Every

NewEvery newEvery

func (*Every) Exit

func (v *Every) Exit(exit func(error) bool) *Every

func (Every) Name

func (v Every) Name() string

func (*Every) Run

func (v *Every) Run(ctx context.Context) error

Run 每隔every秒开始执行下一次,如果一次任务的运行时长超过了every,那么下一次直接发起

type Limit

type Limit struct {
	Err chan error
	// contains filtered or unexported fields
}

Limit limit

func NewLimit

func NewLimit(max int) *Limit

NewLimit newLimit

func (*Limit) Add

func (limit *Limit) Add(delta int)

func (*Limit) Done

func (limit *Limit) Done()

func (*Limit) Go

func (limit *Limit) Go(fc func() error)

func (*Limit) Len

func (limit *Limit) Len() int

Len len

func (*Limit) Wait

func (limit *Limit) Wait() error

Wait wait all groutine close

Jump to

Keyboard shortcuts

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