Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LimitConcurrencyByRepo ¶
LimitConcurrencyByRepo implements GetLockKey by using the repository path as lock.
Types ¶
type GetLockKey ¶
GetLockKey function defines the lock key of an RPC invocation based on its context
type LimiterMiddleware ¶
type LimiterMiddleware struct {
// contains filtered or unexported fields
}
LimiterMiddleware contains rate limiter state
func New ¶
func New(cfg config.Cfg, getLockKey GetLockKey, setupMiddleware SetupFunc) *LimiterMiddleware
New creates a new middleware that limits requests. SetupFunc sets up the middlware with a specific kind of limiter.
func (*LimiterMiddleware) Collect ¶
func (c *LimiterMiddleware) Collect(metrics chan<- prometheus.Metric)
Collect is used to collect Prometheus metrics.
func (*LimiterMiddleware) Describe ¶
func (c *LimiterMiddleware) Describe(descs chan<- *prometheus.Desc)
Describe is used to describe Prometheus metrics.
func (*LimiterMiddleware) StreamInterceptor ¶
func (c *LimiterMiddleware) StreamInterceptor() grpc.StreamServerInterceptor
StreamInterceptor returns a Stream Interceptor
func (*LimiterMiddleware) UnaryInterceptor ¶
func (c *LimiterMiddleware) UnaryInterceptor() grpc.UnaryServerInterceptor
UnaryInterceptor returns a Unary Interceptor
type SetupFunc ¶
type SetupFunc func(cfg config.Cfg, middleware *LimiterMiddleware)
SetupFunc set up a middleware to limiting requests
func WithConcurrencyLimiters ¶
WithConcurrencyLimiters sets up middleware to limit the concurrency of requests based on RPC and repository
func WithRateLimiters ¶
WithRateLimiters sets up a middleware with limiters that limit requests based on its rate per second per RPC