You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
402 B
18 lines
402 B
1 month ago
|
package limit
|
||
|
|
||
|
import (
|
||
|
"github.com/gin-gonic/gin"
|
||
|
"github.com/juju/ratelimit"
|
||
|
)
|
||
|
|
||
|
type LimiterIface interface {
|
||
|
Key(c *gin.Context) string
|
||
|
GetBucket(key string) (*ratelimit.Bucket, bool)
|
||
|
AddBucketsByUri(uri string, fillInterval, capacity, quantum int64) LimiterIface
|
||
|
AddBucketByConf(rules map[string]*LimitOpt) LimiterIface
|
||
|
}
|
||
|
|
||
|
type Limiter struct {
|
||
|
limiterBuckets map[string]*ratelimit.Bucket
|
||
|
}
|