scheduler

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Logger         *slog.Logger
	OnSampleError  func(error)
	InitialBackoff time.Duration
	MaxBackoffCap  time.Duration
}

Config holds optional scheduler behaviour.

type Scheduler

type Scheduler struct {
	Interval time.Duration
	Jitter   time.Duration
	Gate     collector.SampleGate
	Config
}

Scheduler drives periodic sampling with interval, jitter, and an optional gate.

func New

func New(interval, jitter time.Duration, gate collector.SampleGate, cfg Config) *Scheduler

New returns a Scheduler with the given configuration. Gate defaults to collector.AlwaysAllow when nil.

func (*Scheduler) Run

func (s *Scheduler) Run(ctx context.Context, fn func(context.Context) error) error

Run ticks on interval, evaluates the gate, and calls fn when permitted. Transient sample errors are logged and retried with exponential backoff.

Jump to

Keyboard shortcuts

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