pkg

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	After(d time.Duration) <-chan time.Time
	AfterFunc(d time.Duration, f func()) Timer
	Now() time.Time
	Since(t time.Time) time.Duration
	Until(t time.Time) time.Duration
	Sleep(d time.Duration)
	Tick(d time.Duration) <-chan time.Time
	Ticker(d time.Duration) Ticker
	Timer(d time.Duration) Timer
	WithDeadline(parent context.Context, d time.Time) (context.Context, context.CancelFunc)
	WithTimeout(parent context.Context, t time.Duration) (context.Context, context.CancelFunc)
}

Clock represents an interface to the functions in the standard library time package. Two implementations are available in the clock package. The first is a real-time clock which simply wraps the time package's functions. The second is a mock clock which will only change when programmatically adjusted.

type Duration

type Duration = time.Duration

Re-export of time.Duration

type Mock

type Mock interface {
	Clock

	Add(duration time.Duration)
	Set(time time.Time)

	WaitForAllTimers() time.Time
}

type Ticker

type Ticker interface {
	Chan() <-chan time.Time

	Stop()
	Reset(duration time.Duration)
}

type Timer

type Timer interface {
	Chan() <-chan time.Time

	Stop() bool
	Reset(duration time.Duration) bool
}

Jump to

Keyboard shortcuts

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