limithandler

package
v1.87.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnableAcquireTimeHistogram

func EnableAcquireTimeHistogram(buckets []float64)

EnableAcquireTimeHistogram enables histograms for acquisition times

func SetMaxRepoConcurrency

func SetMaxRepoConcurrency(config map[string]int)

SetMaxRepoConcurrency Configures the max concurrency per repo per RPC

Types

type ConcurrencyLimiter

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

ConcurrencyLimiter contains rate limiter state

func NewLimiter

func NewLimiter(max int, monitor ConcurrencyMonitor) *ConcurrencyLimiter

NewLimiter creates a new rate limiter

func (*ConcurrencyLimiter) Limit

func (c *ConcurrencyLimiter) Limit(ctx context.Context, lockKey string, f LimitedFunc) (interface{}, error)

Limit will limit the concurrency of f

type ConcurrencyMonitor

type ConcurrencyMonitor interface {
	Queued(ctx context.Context)
	Dequeued(ctx context.Context)
	Enter(ctx context.Context, acquireTime time.Duration)
	Exit(ctx context.Context)
}

ConcurrencyMonitor allows the concurrency monitor to be observed

func NewPromMonitor added in v0.98.0

func NewPromMonitor(system string, fullMethod string) ConcurrencyMonitor

NewPromMonitor creates a new ConcurrencyMonitor that tracks limiter activity in Prometheus.

type GetLockKey added in v0.93.0

type GetLockKey func(context.Context) string

GetLockKey function defines the lock key of an RPC invocation based on its context

type LimitedFunc

type LimitedFunc func() (resp interface{}, err error)

LimitedFunc represents a function that will be limited

type LimiterMiddleware

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

LimiterMiddleware contains rate limiter state

func New

func New(getLockKey GetLockKey) LimiterMiddleware

New creates a new rate limiter

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

Directories

Path Synopsis
Package test is a generated protocol buffer package.
Package test is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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