tokenbucket

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TokenBucket

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

func New

func New(name string, capacity uint64, tw time.Duration) *TokenBucket

New 创建 TokenBucket 实例

func (*TokenBucket) Limit

func (rl *TokenBucket) Limit() bool

Limit 判断是否超过限制

func (*TokenBucket) Undo

func (rl *TokenBucket) Undo()

Undo 重置上一次调用Limit(),返回没有使用过的限额

func (*TokenBucket) UpdateCapacity

func (rl *TokenBucket) UpdateCapacity(capacity uint64)

UpdateRate 更新速率值

Jump to

Keyboard shortcuts

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