add conn limiter

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

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
package traffic
import "context"
type Limiter interface {
// Wait blocks with the requested n and returns the result value,
// the returned value is less or equal to n.
Wait(ctx context.Context, n int) int
Limit() int
}
type TrafficLimiter interface {
In(key string) Limiter
Out(key string) Limiter
}