store, err := memstore.New(65535)
if err != nil {
log.Fatal(err)
}
f := NewFilter(store)
quota := RateQuota{MaxRate: PerSec(5), MaxBurst: 1}
key := "limit key"
f.AddKey(key, quota)
// when request :
if limited, e := f.RateLimit(key);e == nil{
if limited {
// be limited
} else {
// adopt
}
}
-
Notifications
You must be signed in to change notification settings - Fork 1
pantianying/miser
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
令牌桶算法的限流器
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published