tick

package
v0.15.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: BSD-2-Clause Imports: 9 Imported by: 1 module, 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics

type Metrics interface {
	// IncPublished is called once per Publish attempt with the outcome
	// ("success" | "error") and the recurrence kind of the task.
	IncPublished(result string, recurrence string)

	// SetLastTickTimestamp is called at the start of every tick with the
	// wall-clock time of that tick start as Unix seconds (float).
	SetLastTickTimestamp(seconds float64)
}

Metrics records observability events for the hourly tick loop.

func NewPrometheusMetrics

func NewPrometheusMetrics() Metrics

NewPrometheusMetrics returns a Metrics backed by the package-level Prometheus counter and gauge. The counter is pre-initialized in init() so the first call into the metrics surface is just an Inc/Add.

type Tick

type Tick interface {
	// Run performs an initial tick synchronously, then enters a 1-hour loop
	// that fires on time.NewTicker. Returns nil on clean context cancellation.
	Run(ctx context.Context) error
	// RunOnce performs a single tick (publish every entry in the inventory)
	// and returns. Intended for local smoke-testing via cmd/run-once.
	RunOnce(ctx context.Context) error
}

Tick runs the hourly cron loop. Run blocks until ctx is cancelled.

func NewTick

func NewTick(
	ctx context.Context,
	scheduleStore store.ScheduleStore,
	pub publisher.Publisher,
	clock libtime.CurrentDateTimeGetter,
	metrics Metrics,
) (Tick, error)

NewTick builds the hourly cron loop. store supplies the recurring-task definitions per tick via its List method; pub sends one CreateCommand per entry per tick; clock is the wall-clock source; metrics records per-publish outcomes and the tick-start timestamp. Returns a wrapped error if time.LoadLocation("Europe/Berlin") fails at struct init.

Jump to

Keyboard shortcuts

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