timex

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: MIT Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package timex provides a Ticker abstraction with a fake implementation for deterministic, clock-injectable tests of periodic logic.

Index

Constants

This section is empty.

Variables

View Source
var ErrTimeout = errors.New("timex: wait timeout")

ErrTimeout is returned by FakeTicker.Wait when the deadline elapses first.

Functions

This section is empty.

Types

type FakeTicker

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

FakeTicker is a manually-driven Ticker for tests.

func NewFakeTicker

func NewFakeTicker() *FakeTicker

NewFakeTicker returns a FakeTicker that must be advanced with Tick.

func (*FakeTicker) Chan

func (ft *FakeTicker) Chan() <-chan time.Time

Chan returns the tick channel.

func (*FakeTicker) Done

func (ft *FakeTicker) Done() <-chan struct{}

Done returns a channel closed when Stop is called.

func (*FakeTicker) Stop

func (ft *FakeTicker) Stop()

Stop closes the Done channel; it is safe to call multiple times.

func (*FakeTicker) Tick

func (ft *FakeTicker) Tick()

Tick emits a single tick.

func (*FakeTicker) Wait

func (ft *FakeTicker) Wait(d time.Duration) error

Wait blocks until Stop is called or the duration elapses, whichever first.

type Ticker

type Ticker interface {
	// Chan returns the tick channel.
	Chan() <-chan time.Time
	// Stop stops the ticker.
	Stop()
}

Ticker emits periodic ticks.

func NewTicker

func NewTicker(d time.Duration) Ticker

NewTicker returns a real Ticker with the given interval.

Jump to

Keyboard shortcuts

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