ratelimit

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrLimitExceed

func ErrLimitExceed() error

ErrLimitExceed returns an error indicates an exceeding of rate limitation.

func IsErrLimitExceed

func IsErrLimitExceed(err error) bool

IsErrLimitExceed checks whether an error is indicating an exceeding of rate limitation. This function supports wrapped errors.

func StreamInterceptor

func StreamInterceptor(opts ...Option) grpc.StreamServerInterceptor

func UnaryInterceptor

func UnaryInterceptor(opts ...Option) grpc.UnaryServerInterceptor

Types

type Option

type Option func(*options)

Option is rate limit option.

func WithId

func WithId(f func(ctx context.Context, api string) string) Option

WithId set id extract function. The default function use just the api as request id.

func WithLimiter

func WithLimiter(limiter limiter.Limiter) Option

WithLimiter set Limiter implementation.

Jump to

Keyboard shortcuts

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