backoffdelay

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2025 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 Exponential added in v0.3.4

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

func NewExponential

func NewExponential(minimumDelay, maximumDelay time.Duration,
	growthRate uint) *Exponential

NewExponential creates a Sleeper with specified minimum and maximum delays. If minimumDelay is less than or equal to 0, the default is 1 second. If maximumDelay is less than or equal to minimumDelay, the default is 10 times minimumDelay. The Sleep duration will increase by a factor of 2 raised to the power of -growthRate. For example: 0: 1x 1: 0.5x 2: 0.25x

func (*Exponential) RemainingInterval added in v0.4.0

func (e *Exponential) RemainingInterval() time.Duration

RemainingInterval will return the time remaining until the end of the interval that was started when StartInterval was called.

func (*Exponential) Reset added in v0.3.4

func (e *Exponential) Reset()

Reset will set the sleep duration to the minimum delay.

func (*Exponential) SetSleepFunc added in v0.4.0

func (e *Exponential) SetSleepFunc(sleepFunc func(time.Duration))

SetSleepFunc will set the function used to sleep. The default is time.Sleep.

func (*Exponential) Sleep added in v0.3.4

func (e *Exponential) Sleep()

Sleep will sleep and then increase the duration for the next Sleep, until reaching the maximum delay.

func (*Exponential) SleepUntilEnd added in v0.4.0

func (e *Exponential) SleepUntilEnd()

SleepUntilEnd will sleep until the end of the interval that was started when StartInterval was called.

func (*Exponential) StartInterval added in v0.4.0

func (e *Exponential) StartInterval()

StartInterval starts an interval. This may be used to impose a maximum loop duration when iterating over a set of operations with individual timeouts.

type Refresher added in v0.4.0

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

func NewRefresher added in v0.4.0

func NewRefresher(deadline time.Time,
	minimumDelay, maximumDelay time.Duration) *Refresher

NewRefresher creates a Sleeper with a specified deadline to perform a refresh prior to the deadline, with more frequent retries as the deadline approaches. This is useful for scheduling certificate refreshes. The deadline is the time by which a refresh is required. The minimumDelay is the minimum delay between refresh attempts. If less than or equal to 0, the default is 1 second. The maximumDelay is the maximum delay between refresh attempts. If less than or equal to 0, there is no maximum.

func (*Refresher) ResetTimer added in v0.4.0

func (r *Refresher) ResetTimer(timer *time.Timer)

ResetTimer will reset a time.Timer with the time to wait until the next refresh should be attempted. Any previous events are cleared.

func (*Refresher) SetDeadline added in v0.4.0

func (r *Refresher) SetDeadline(deadline time.Time)

SetDeadline will update the refresh deadline.

func (*Refresher) SetSleepFunc added in v0.4.0

func (r *Refresher) SetSleepFunc(sleepFunc func(time.Duration))

SetSleepFunc will set the function used to sleep. The default is time.Sleep.

func (*Refresher) Sleep added in v0.4.0

func (r *Refresher) Sleep()

Sleep will sleep until the next refresh should be attempted.

func (*Refresher) WaitInterval added in v0.4.0

func (r *Refresher) WaitInterval() time.Duration

WaitInterval returns the time to wait until the next refresh should be attempted.

type Resetter added in v0.3.4

type Resetter interface {
	Reset()
}

type Sleeper

type Sleeper interface {
	Sleep()
}

Jump to

Keyboard shortcuts

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