Documentation ¶
Index ¶
Constants ¶
View Source
const ( // DefaultQPS is determined by empirically reviewing known consumers of the API. // It's at least unlikely that there is a legitimate need to query podresources // more than 100 times per second, the other subsystems are not guaranteed to react // so fast in the first place. DefaultQPS = 100 // DefaultBurstTokens is determined by empirically reviewing known consumers of the API. // See the documentation of DefaultQPS, same caveats apply. DefaultBurstTokens = 10 )
Variables ¶
View Source
var (
ErrorLimitExceeded = status.Error(codes.ResourceExhausted, "rejected by rate limit")
)
Functions ¶
func LimiterUnaryServerInterceptor ¶
func LimiterUnaryServerInterceptor(limiter Limiter) grpc.UnaryServerInterceptor
LimiterUnaryServerInterceptor returns a new unary server interceptors that performs request rate limiting.
func WithRateLimiter ¶
func WithRateLimiter(qps, burstTokens int32) grpc.ServerOption
Types ¶
type Limiter ¶
type Limiter interface { // Allow reports whether an event may happen now. Allow() bool }
Limiter defines the interface to perform request rate limiting, based on the interface exposed by https://pkg.go.dev/golang.org/x/time/rate#Limiter
Click to show internal directories.
Click to hide internal directories.