ticker

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

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 added in v0.9.1

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