middlewares

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRateLimit = errors.New("rate limit exceeded")
)

Functions

func MakeClientOptions

func MakeClientOptions(
	logger *zap.Logger,
) []grpc.DialOption

func MakeServerOptions

func MakeServerOptions(
	logger *zap.Logger,
	authClient siface.IAuthMiddleware,
	deployments utility.Deployments,
	rateLimit int32,
	opts ...grpc.ServerOption,
) []grpc.ServerOption

MakeServerOptions creates a set of grpc server options options include: rate limit, auth, logging, recovery, and opentelemetry etc.

Types

type RateLimiter

type RateLimiter struct {
	// contains filtered or unexported fields
}

RateLimiter rate limit

func CreateRateLimiter

func CreateRateLimiter(num int) *RateLimiter

CreateRateLimiter creates a rate limiter here we use golang.org/x/time/rate

func (*RateLimiter) Limit

func (rl *RateLimiter) Limit(_ context.Context) error

Jump to

Keyboard shortcuts

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