externalclock

package
v0.11.5 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package externalclock provides a clock implementation for external time sources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock struct {
	Logger logr.Logger
	// contains filtered or unexported fields
}

func New

func New(logger logr.Logger, initialTime time.Time) *Clock

func (*Clock) After

func (g *Clock) After(duration time.Duration) <-chan time.Time

func (*Clock) AfterFunc

func (g *Clock) AfterFunc(d time.Duration, f func()) clock.Timer

func (*Clock) NewTicker

func (g *Clock) NewTicker(d time.Duration) clock.Ticker

func (*Clock) NewTimer

func (g *Clock) NewTimer(d time.Duration) *Timer

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

func (*Clock) Now

func (g *Clock) Now() time.Time

func (*Clock) NowProto

func (g *Clock) NowProto() *timestamppb.Timestamp

func (*Clock) NumberOfTriggers

func (g *Clock) NumberOfTriggers() int

func (*Clock) Run deprecated

func (g *Clock) Run(ctx context.Context) error

Deprecated: Calling Run is not necessary anymore. The method only blocks until context is cancelled.

func (*Clock) SetTimestamp

func (g *Clock) SetTimestamp(t time.Time)

func (*Clock) Since

func (g *Clock) Since(t time.Time) time.Duration

func (*Clock) Sleep

func (g *Clock) Sleep(d time.Duration)

type Timer

type Timer struct {
	clock.Ticker
}

The Timer type represents a single event. When the Timer expires, the current time will be sent on C, unless the Timer was created by AfterFunc. A Timer must be created with NewTimer or AfterFunc.

func (*Timer) Stop

func (t *Timer) Stop() bool

Stop prevents the Timer from firing. It returns true if the call stops the timer, false if the timer has already expired or been stopped.

Jump to

Keyboard shortcuts

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