更改目录结构

This commit is contained in:
bjdgyc
2021-03-01 15:46:08 +08:00
parent 3464d1d10e
commit 0f91c779e3
105 changed files with 29099 additions and 96 deletions

View File

@@ -0,0 +1,23 @@
package sessdata
import (
"context"
"golang.org/x/time/rate"
)
type LimitRater struct {
limit *rate.Limiter
}
// lim: 令牌产生速率
// burst: 允许的最大爆发速率
func NewLimitRater(lim, burst int) *LimitRater {
limit := rate.NewLimiter(rate.Limit(lim), burst)
return &LimitRater{limit: limit}
}
// bt 不能超过burst大小
func (l *LimitRater) Wait(bt int) error {
return l.limit.WaitN(context.Background(), bt)
}