core/limiter/limiter.go
2022-09-05 22:46:53 +08:00

16 lines
307 B
Go

package limiter
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 RateLimiter interface {
In(key string) Limiter
Out(key string) Limiter
}