ticker

package
v0.0.0-...-fb7f86c Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics

type Metrics struct {
	LastTickTime    prometheus.Gauge
	NextTickTime    prometheus.Gauge
	IntervalSeconds prometheus.Gauge
}

func NewMetrics

func NewMetrics(reg prometheus.Registerer, subsystem string) *Metrics

type T

type T struct {
	C chan time.Time
	// contains filtered or unexported fields
}

Ticker emits ticks at regular time intervals. it's like a time.Ticker, except:

  • it doesn't drop ticks for slow receivers, rather, it queues up. so that callers are in control to instrument what's going on.
  • it ticks on interval marks or very shortly after. this provides a predictable load pattern (this shouldn't cause too much load contention issues because the next steps in the pipeline just process at their own pace)
  • the timestamps are used to mark "last datapoint to query for" and as such, are a configurable amount of seconds in the past

func New

func New(c clock.Clock, interval time.Duration, metric *Metrics) *T

NewTicker returns a Ticker that ticks on interval marks (or very shortly after) starting at c.Now(), and never drops ticks. interval should not be negative or zero.

func (*T) Stop

func (t *T) Stop()

Stop stops the ticker. It does not close the C channel

Jump to

Keyboard shortcuts

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