scheduler

package
v0.0.0-...-6428b2c Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package scheduler runs probe cycles on an interval through a bounded worker pool.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

type Checker interface {
	Check(ctx context.Context, t config.Target) probe.Result
}

Checker probes a single target. *probe.Prober is the production implementation; tests substitute a fake to drive scheduling without real network I/O.

type ResultHandler

type ResultHandler func(ctx context.Context, r probe.Result)

ResultHandler consumes each probe result (alerting, metrics, logging).

type Scheduler

type Scheduler struct {

	// OnCycle, when non-nil, is called at the end of each completed cycle with
	// its completion time and wall duration, so the cycle gauges can be exported.
	OnCycle func(completedAt time.Time, d time.Duration)
	// contains filtered or unexported fields
}

func New

func New(cfg *config.Config, p Checker, handle ResultHandler, log *slog.Logger) *Scheduler

func (*Scheduler) LastCycle

func (s *Scheduler) LastCycle() time.Time

LastCycle reports when the most recent probe cycle finished. The zero time means no cycle has completed yet (startup).

func (*Scheduler) Run

func (s *Scheduler) Run(ctx context.Context)

Run blocks until ctx is cancelled, executing one cycle immediately and then one per check_interval. A cycle that overruns the interval is not stacked: the ticker simply fires again after it finishes.

Jump to

Keyboard shortcuts

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