clock

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventTime

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

EventTime is the controlled fake time.

func NewEventTimeSource

func NewEventTimeSource() *EventTime

NewEventTimeSource returns a fake controlled time source.

func (*EventTime) Now

func (ts *EventTime) Now() time.Time

Now returns the fake current time.

func (*EventTime) Since

func (ts *EventTime) Since(t time.Time) time.Duration

Since returns the time elapsed since t.

func (*EventTime) Update

func (ts *EventTime) Update(now time.Time) *EventTime

Update sets the fake current time.

type SystemTime

type SystemTime struct{}

SystemTime is the real wall-clock time.

func NewSystemTimeSource

func NewSystemTimeSource() *SystemTime

NewSystemTimeSource returns a real wall clock time source.

func (*SystemTime) Now

func (ts *SystemTime) Now() time.Time

Now returns the real current time.

func (*SystemTime) Since

func (ts *SystemTime) Since(t time.Time) time.Duration

Since returns the time elapsed since t.

type TimeSource

type TimeSource interface {
	Now() time.Time
	Since(t time.Time) time.Duration
}

TimeSource is an interface for any entity that provides the current time. Its primarily used to mock out timesources in unit test.

Jump to

Keyboard shortcuts

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