clock

package
v0.0.0-...-d2438c5 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultSleeper = sleeper{}

DefaultSleeper exports a sleeper so that the retrier can backoff at the right times. The reason for it's inclusion as a dependency is to allow mocking to work in the correct way, without any delays.

Functions

This section is empty.

Types

type Clock

type Clock interface {

	// Now returns the current local time.
	Now() time.Time

	// UTC returns the time now as UTC
	UTC() time.Time

	// After waits for the duration to elapse and then sends the current time
	// on the returned channel.
	// It is equivalent to NewTimer(d).C.
	// The underlying Timer is not recovered by the garbage collector
	// until the timer fires. If efficiency is a concern, use NewTimer
	// instead and call Timer.Stop if the timer is no longer needed.
	After(d time.Duration) <-chan time.Time
}

Clock defines an interface for Clocks

type Sleeper

type Sleeper interface {

	// Sleep pauses the current goroutine for at least the duration d.
	// A negative or zero duration causes Sleep to return immediately.
	Sleep(time.Duration)
}

Sleeper defines a interface that handles sleeping at the right times

type WallClock

type WallClock struct{}

WallClock represents an implementation of Clock, that uses the wall time.

func New

func New() WallClock

New creates a new Clock

func (WallClock) After

func (WallClock) After(d time.Duration) <-chan time.Time

After waits for the duration to elapse and then sends the current time on the returned channel. It is equivalent to NewTimer(d).C. The underlying Timer is not recovered by the garbage collector until the timer fires. If efficiency is a concern, use NewTimer instead and call Timer.Stop if the timer is no longer needed.

func (WallClock) Now

func (WallClock) Now() time.Time

Now returns the current local time.

func (WallClock) UTC

func (WallClock) UTC() time.Time

UTC returns the current utc time.

Jump to

Keyboard shortcuts

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