package grpc

import "k8s.io/kubernetes/pkg/kubelet/apis/podresources/grpc"

Index

Constants

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

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

Source Files

ratelimit.go

Version
v1.27.6
Published
Sep 13, 2023
Platform
js/wasm
Imports
6 packages
Last checked
1 minute ago

Tools for package owners.