clock

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2025 License: MIT Imports: 2 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 provides a clock interface. clock package is a adapter class for k8s.io/utils/clock.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	PassiveClock
	// After returns the channel of a new Timer.
	// This method does not allow to free/GC the backing timer before it fires. Use
	// NewTimer instead.
	After(d time.Duration) <-chan time.Time
	// NewTimer returns a new Timer.
	NewTimer(d time.Duration) k8sclock.Timer
	// Sleep sleeps for the provided duration d.
	// Consider making the sleep interruptible by using 'select' on a context channel and a timer channel.
	Sleep(d time.Duration)
	// Tick returns the channel of a new Ticker.
	// This method does not allow to free/GC the backing ticker. Use
	// NewTicker from WithTicker instead.
	Tick(d time.Duration) <-chan time.Time
}

Clock is from k8s.io/utils/clock.

type PassiveClock

type PassiveClock interface {
	Now() time.Time
	Since(at time.Time) time.Duration
}

PassiveClock is a passive clock interface.

type RealClock added in v0.1.18

type RealClock struct {
	k8sclock.RealClock
}

RealClock implements Clock using the system clock.

func NewRealClock added in v0.1.18

func NewRealClock() *RealClock

NewRealClock returns a new RealClock using the system clock.

func (*RealClock) After added in v0.1.18

func (c *RealClock) After(d time.Duration) <-chan time.Time

After waits for the duration to elapse and then sends the current time on the returned channel.

func (*RealClock) NewTimer added in v0.1.18

func (c *RealClock) NewTimer(d time.Duration) k8sclock.Timer

NewTimer returns a new Timer that will send the current time on its channel after at least duration d.

func (*RealClock) Now added in v0.1.18

func (c *RealClock) Now() time.Time

Now returns the current local time.

func (*RealClock) Since added in v0.1.18

func (c *RealClock) Since(t time.Time) time.Duration

Since returns the time elapsed since t.

func (*RealClock) Sleep added in v0.1.18

func (c *RealClock) Sleep(d time.Duration)

Sleep pauses the current goroutine for at least the duration d.

func (*RealClock) Tick added in v0.1.18

func (c *RealClock) Tick(d time.Duration) <-chan time.Time

Tick returns a channel that will send the time with a period specified by the duration argument.

Jump to

Keyboard shortcuts

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