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.
Click to show internal directories.
Click to hide internal directories.