tokenBucket

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2021 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package tokenBucket

*参考了github.com/juju/ratelimit的实现 *但是这种填充方式 需要经常获取当前时间 *改为定时器定时触发填充可能会带来性能提升 (有待测试)

Index

Constants

This section is empty.

Variables

View Source
var (
	ERRNOTOKEN  = errors.New("there dont have any token")
	ERRINTERVAL = errors.New("interval is not reasonable please set it between 10 to 1000")
)

Functions

func NewTokenBucket

func NewTokenBucket(cap, qps int) *tokenBucket

NewTokenBucket 返回一个令牌桶 参数为桶的容量 与每秒填充的令牌数量

Types

This section is empty.

Jump to

Keyboard shortcuts

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