clock

package
v4.38.8 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 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 Fixed

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

Fixed implementation of clock.Provider for tests.

func NewFixed

func NewFixed(t time.Time) *Fixed

NewFixed returns a new clock with an initial time.

func (*Fixed) After

func (c *Fixed) After(d time.Duration) <-chan time.Time

After return a channel receiving the time after duration has elapsed.

func (*Fixed) AfterFunc

func (c *Fixed) AfterFunc(d time.Duration, f func()) *time.Timer

func (*Fixed) Now

func (c *Fixed) Now() time.Time

Now return the stored clock.

func (*Fixed) Set

func (c *Fixed) Set(now time.Time)

Set the time of the clock.

type Provider

type Provider interface {
	Now() time.Time
	After(d time.Duration) <-chan time.Time
	AfterFunc(d time.Duration, f func()) *time.Timer
}

Provider is an interface for a clock.

type Real

type Real struct{}

Real is the implementation of a clock.Provider for production.

func New

func New() *Real

New returns a new real clock.

func (Real) After

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

After return a channel receiving the time after the defined duration.

func (Real) AfterFunc

func (Real) AfterFunc(d time.Duration, f func()) *time.Timer

func (Real) Now

func (Real) Now() time.Time

Now return the current time.

Jump to

Keyboard shortcuts

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