add conn limiter

This commit is contained in:
ginuerzh
2022-09-14 00:14:20 +08:00
parent e7a104651a
commit 45b7ac2021
4 changed files with 34 additions and 16 deletions

10
limiter/conn/limiter.go Normal file
View File

@ -0,0 +1,10 @@
package conn
type Limiter interface {
Allow(n int) bool
Limit() int
}
type ConnLimiter interface {
Limiter(key string) Limiter
}

View File

@ -1,4 +1,4 @@
package limiter
package traffic
import "context"
@ -9,7 +9,7 @@ type Limiter interface {
Limit() int
}
type RateLimiter interface {
type TrafficLimiter interface {
In(key string) Limiter
Out(key string) Limiter
}