clock

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: Apache-2.0 Imports: 1 Imported by: 1,411

README

Clock

Go Report Card Go Reference

Provides a Clock interface, useful for injecting time dependencies in tests.

[!NOTE]

This repository should be imported as code.cloudfoundry.org/clock.

Contributing

See the Contributing.md for more information on how to contribute.

Working Group Charter

This repository is maintained by App Runtime Platform under Diego area.

[!IMPORTANT]

Content in this file is managed by the CI task sync-readme and is generated by CI following a convention.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

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

	NewTimer(d time.Duration) Timer
	NewTicker(d time.Duration) Ticker
}

func NewClock

func NewClock() Clock

type Ticker

type Ticker interface {
	C() <-chan time.Time
	Stop()
}

type Timer

type Timer interface {
	C() <-chan time.Time
	Reset(d time.Duration) bool
	Stop() bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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