limiter

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StreamServerInterceptor

func StreamServerInterceptor(limiter Limiter, matchers ...selector.Matcher) grpc.StreamServerInterceptor

StreamServerInterceptor returns a new streaming server interceptor that performs rate limiting on the request. If no matchers are provided, the limiter will apply to all requests. If matchers are provided, the limiter will only apply to requests that match at least one of the matchers.

func UnaryServerInterceptor

func UnaryServerInterceptor(limiter Limiter, matchers ...selector.Matcher) grpc.UnaryServerInterceptor

UnaryServerInterceptor returns a new unary server interceptor that performs rate limiting on the request. If no matchers are provided, the limiter will apply to all requests. If matchers are provided, the limiter will only apply to requests that match at least one of the matchers.

Types

type Limiter

type Limiter func(ctx context.Context) error

Limiter is a function that returns a context and error

func Chain added in v0.0.1

func Chain(limiters ...Limiter) Limiter

Chain returns a Limiter that executes each limiter in sequence. If any of the limiters returns an error, the chain stops executing and returns that error.

Jump to

Keyboard shortcuts

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