throttler

package
v0.0.0-...-f7df13b Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DialWithBackOff = NewBackoffDialer(backOffTemplate)
View Source
var ErrRequestQueueFull = errors.New("request queue is full! This request is dropped")
View Source
var ErrTimeoutDialing = errors.New("timed out dialing")

Errors

Functions

func NewBackoffDialer

func NewBackoffDialer(backoffConfig wait.Backoff) func(context.Context, string, string) (net.Conn, error)

func NewProxyAutoTransport

func NewProxyAutoTransport(maxIdleProxyConns, maxIdleProxyConnsPerHost int) http.RoundTripper

Types

type Breaker

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

Breaker enforces a concurrency limit on the execution of a function. Function call attempts beyond the limit of the max-concurrency are failed immediately.

func NewBreaker

func NewBreaker(params BreakerParams) *Breaker

func (*Breaker) Maybe

func (b *Breaker) Maybe(ctx context.Context, thunk func()) error

Maybe conditionally executes thunk based on the Breaker concurrency and queue parameters.

type BreakerParams

type BreakerParams struct {
	QueueDepth      int
	MaxConcurrency  int
	InitialCapacity int
	Logger          *zap.Logger
}

type Params

type Params struct {
	QueueRetryDuration      time.Duration
	TrafficReEnableDuration time.Duration
	K8sUtil                 *k8shelper.Ops
	QueueDepth              int
	MaxConcurrency          int
	InitialCapacity         int
	Logger                  *zap.Logger
}

type RoundTripperFunc

type RoundTripperFunc func(*http.Request) (*http.Response, error)

func (RoundTripperFunc) RoundTrip

func (rt RoundTripperFunc) RoundTrip(r *http.Request) (*http.Response, error)

type Throttler

type Throttler struct {
	TrafficReEnableDuration time.Duration
	// contains filtered or unexported fields
}

func NewThrottler

func NewThrottler(param *Params) *Throttler

func (*Throttler) GetQueueSize

func (t *Throttler) GetQueueSize(namespace, service string) int

func (*Throttler) Try

func (t *Throttler) Try(ctx context.Context, host *messages.Host, resolve func(int) error, tryErrCallback func()) error

Jump to

Keyboard shortcuts

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