util

package
v0.0.0-...-f91e577 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Unlicense Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Delay

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

Delay is not goroutine-safe.

func NewDelay

func NewDelay(targetPercentile float64, increaseRate float64, initialDelay, minDelay, maxDelay time.Duration) (*Delay, error)

NewDelay returns a Delay.

targetPercentile is the desired percentile to be computed. For example, a targetPercentile of 0.99 computes the delay at the 99th percentile. Must be in the range [0, 1].

increaseRate (must be > 0) determines how many Increase calls it takes for Value to double.

Decrease can never lower the delay past minDelay, Increase can never raise the delay past maxDelay.

func (*Delay) Decrease

func (d *Delay) Decrease()

Decrease notes that the RPC completed before the delay returned by Value.

func (*Delay) Increase

func (d *Delay) Increase()

Increase notes that the RPC took longer than the delay returned by Value.

func (*Delay) PrintDelay

func (d *Delay) PrintDelay()

PrintDelay prints the state of Delay object.

func (*Delay) Update

func (d *Delay) Update(latency time.Duration)

Update notes that the RPC either took longer than the delay or completed before the delay, depending on the specified latency.

func (*Delay) Value

func (d *Delay) Value() time.Duration

Value returns the desired delay to wait before hedging the RPC call.

Jump to

Keyboard shortcuts

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