clock

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package clock provides a decorator around gotd/td/clock to control and suppress native timers safely.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interceptor

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

Interceptor decorates a base clock.Clock, selectively neutralizing timers matching a specified duration (such as the default gotd ping loop interval).

func NewInterceptor

func NewInterceptor(base clock.Clock, targetInterval time.Duration) *Interceptor

NewInterceptor constructs a new Interceptor. If base is nil, clock.System is used. If targetInterval is zero or negative, it defaults to 1 minute.

func (*Interceptor) Now

func (i *Interceptor) Now() time.Time

Now returns the current time from the underlying base clock.

func (*Interceptor) Ticker

func (i *Interceptor) Ticker(d time.Duration) clock.Ticker

Ticker returns a dormant ticker if d matches the target interval; otherwise, delegates to the base clock.

func (*Interceptor) Timer

func (i *Interceptor) Timer(d time.Duration) clock.Timer

Timer returns a dormant timer if d matches the target interval; otherwise, delegates to the base clock.

Jump to

Keyboard shortcuts

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