ticker

package
v1.5.10 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 3 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

Overview

Package ticker runs a function at a fixed interval until its context is cancelled, logging tick errors instead of stopping.

Index

Constants

View Source
const DefaultInterval = time.Minute

DefaultInterval is the fallback when a configured interval is not positive.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, interval time.Duration, logger *slog.Logger, label string, tick func(context.Context) error) error

Run calls tick on interval until ctx is done. A tick error is logged under label, never fatal: one failed tick must not stop the loop.

func Safe

func Safe(d, fallback time.Duration) time.Duration

Safe returns d, or fallback when d is zero or negative, because time.NewTicker panics on a non positive interval.

Types

This section is empty.

Jump to

Keyboard shortcuts

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