clock

package
v1.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package clock implements a standard clock interface that can be used in place of the time package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	Now() time.Time
	Sleep(time.Duration)
	NewTicker(time.Duration) Ticker
	NewTimer(time.Duration) Timer
}

Interface represents a clock with the same core functionality available as in the stdlib time package

func System

func System() Interface

System returns a clock backed by the time package

type Ticker

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

func WrapTicker

func WrapTicker(t *time.Ticker) Ticker

type Timer

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

Timer represents an event source triggered at a particular time. It is the analog of time.Timer.

func WrapTimer

func WrapTimer(t *time.Timer) Timer

WrapTimer wraps a time.Timer in a clock.Timer. A typical usage would be WrapTimer(time.NewTimer(time.Second)).

Directories

Path Synopsis
Package clocktest provides a testable clock implementation
Package clocktest provides a testable clock implementation

Jump to

Keyboard shortcuts

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