Documentation ¶
Index ¶
Constants ¶
This section is empty.
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(serviceName string, qps, burstTokens int32) grpc.ServerOption
WithRateLimiter creates new rate limiter with unary interceptor.
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.