timeutil

package
v2.23.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Future

func Future(duration time.Duration) time.Time

Future provides a time.Time duration into the future from now

func Past

func Past(duration time.Duration) time.Time

Past provides a time.Time duration into the past from now

Types

type RunStop

type RunStop interface {
	Run()
	Running() bool
	Stop()
}

RunStop exposes a functions for running, stopping, and querying status of presumably a background job.

func RunEvery

func RunEvery(f func(), wait time.Duration) RunStop

RunEvery wait duration. Use returned channel to stop.

type Ticker

type Ticker interface {
	// Start this ticker sending time on it's channel.
	Start() Ticker
	// Reset this ticker by creating a new channel and sending time on it.
	Reset()
	// Stop this ticker and release underlying resources.
	Stop()
	// SetPeriod of this ticker to the passed duration. The ticker must be restarted
	// after this change.
	SetPeriod(period time.Duration)
	// Channel that is used to send the 'ticks'
	Channel() <-chan time.Time
}

Ticker sends the time, after a period, on it's channel once started.

func NewTicker

func NewTicker(period time.Duration) Ticker

NewTicker returns a new Ticker containing a channel that will send the time with a period specified by the duration argument once Started. It adjusts the intervals or drops ticks to make up for slow receivers. The duration d must be greater than zero; if not, NewTicker will panic. Stop the ticker to release associated resources.

Jump to

Keyboard shortcuts

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