adjust

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adjust

type Adjust struct {
	CurrentTimeout time.Duration
	// contains filtered or unexported fields
}

Adjust is not concurrency safe.

func NewAdjust

func NewAdjust(ac *AdjustConfig) *Adjust

NewAdjust creates a new Adjust with constraints.

func (*Adjust) Adjust

func (a *Adjust) Adjust()

func (*Adjust) Close

func (a *Adjust) Close()

func (*Adjust) Count

func (a *Adjust) Count()

func (*Adjust) IncOverloaded

func (a *Adjust) IncOverloaded()

func (*Adjust) IncTimeout

func (a *Adjust) IncTimeout()

func (*Adjust) Stats

func (a *Adjust) Stats(r map[string]interface{})

type AdjustConfig

type AdjustConfig struct {
	// Max is the maximum timeout that can be used.
	Max time.Duration

	// Min is the minimum timeout that can be used. Will be [1, Max].
	// If Min >= Max, then adjustment will be turned off.
	Min time.Duration

	// Recalculation is the time.Duration that the Adjust will wait to calculate a new timeout.
	Recalculation time.Duration

	// Target is the the ratio of timeouts within the recalculation duration
	// that will trigger a timeout adjustment.
	// If the ratio of timeouts is greater than the Target, then the timeout
	// duration will be shortened linearly.
	// If the ratio of timeouts is less than the Target, then the timeout
	// duration will be lengthened geometrically.
	// Must be between [0, 1].
	// If Target is 1 then adjustments will be disabled.
	// If Target is 0 then the Min timeout will be used and adjustments disabled.
	// Any value out of bounds will be set to the closest bound.
	Target float64

	// Factor is the ratio of adjustment to the timeout duration.
	// If shortening, it is determined as a ratio of the max time.Duration, and is fixed
	// on Adjust instantiation.
	// If lengthening, it is determined as the ratio of the current timeout plus one.
	// Must be between (0, 1].
	// Use <= 0 for default of 0.05.
	Factor float64

	// MinCount is the minimum number of samples required before making
	// an adjustment.
	// Use 0 for default of 10.
	MinCount uint
}

func (*AdjustConfig) Init

func (a *AdjustConfig) Init()

Jump to

Keyboard shortcuts

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