grpc

package
v1.28.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL