track

package
v0.0.0-...-514fb8c Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Delayer

type Delayer interface {
	Delay() time.Duration
}

Delayer is used to delay some action

type ExpBackoff

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

ExpBackoff is used as delayer, implements exponential backoff algorithm

func NewExpBackoff

func NewExpBackoff(base int) *ExpBackoff

NewExpBackoff returns pointer to new ExpBackoff base is meant to be seconds

func (*ExpBackoff) Delay

func (e *ExpBackoff) Delay() time.Duration

Delay returns seconds

type TimeTracker

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

TimeTracker is used to keep track of something

func NewTracker

func NewTracker(delayer Delayer) *TimeTracker

NewTracker returns pointer to new TimeTracker and sets its Delayer

func (*TimeTracker) HasBeenRan

func (t *TimeTracker) HasBeenRan() bool

HasBeenRan checks how many times has time delayer and returns true if ever ran

func (*TimeTracker) IsReady

func (t *TimeTracker) IsReady() bool

IsReady checks if current time is after nextTime On first check before calling SetNext, always true due to nextTime having zero value

func (*TimeTracker) SetNext

func (t *TimeTracker) SetNext() (time.Duration, time.Time)

SetNext updates nextTime based on delayer implementation Returns delay and time at which will current time be after it

Jump to

Keyboard shortcuts

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