grpc

package
v1.32.0 Latest Latest
Warning

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

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

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

Jump to

Keyboard shortcuts

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