clock

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 4 Imported by: ? modules, 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 clock defines the application's time dependency. time.Time and time.Duration remain value types; reading time and scheduling work use Clock.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wait

func Wait(ctx context.Context, c Clock, d time.Duration) error

Wait waits for d on c or context cancellation. Cancellation takes precedence if ctx is already done when the timer completion is observed, including when both signals are ready. It returns ctx.Err() in that case, otherwise nil.

func WithDeadline

func WithDeadline(parent context.Context, c Clock, deadline time.Time) (context.Context, context.CancelFunc)

WithDeadline preserves both parent Err and Cause. Clockwork's fake-context helper intentionally ignores parent deadline cancellation, which differs from the application's production cancellation contract.

func WithTimeout

func WithTimeout(parent context.Context, c Clock, d time.Duration) (context.Context, context.CancelFunc)

Types

type Clock

type Clock interface {
	Now() time.Time
	NewTimer(time.Duration) clockwork.Timer
	AfterFunc(time.Duration, func()) clockwork.Timer
}

func New

func New() Clock

Jump to

Keyboard shortcuts

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