Help us shape the future of Go! Take the 2026 Go Developer Survey

scheduler

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package scheduler runs the platform's durable background work: firing wake schedules (§9.3), returning expired delivery leases to the queue, recording interrupted connector attempts as unknown, and refreshing the operational gauges (§14).

Index

Constants

View Source
const MinInterval = time.Minute

MinInterval is the shortest recurring wake interval.

View Source
const StaleOperation = 15 * time.Minute

StaleOperation is how long an operation may stay pending before its attempt is presumed interrupted.

Variables

This section is empty.

Functions

func Next

func Next(schedule string, fired, now time.Time) (time.Time, bool)

Next is the store.NextFunc for schedules produced by Parse. Missed intervals are skipped rather than fired in a burst.

func Parse

func Parse(at, every string, now time.Time) (string, time.Time, error)

Parse validates a wake request: either a one-off RFC 3339 time or a recurring interval. It returns the stored schedule text and first trigger.

Types

type Loop

type Loop struct {
	Store    Store
	Metrics  *metrics.Metrics
	Log      *slog.Logger
	Interval time.Duration
}

Loop runs the background work every Interval.

func (*Loop) Run

func (l *Loop) Run(ctx context.Context)

Run loops until ctx is cancelled.

func (*Loop) Tick

func (l *Loop) Tick(ctx context.Context)

Tick performs one round of background work.

type Store

type Store interface {
	FireDue(ctx context.Context, now time.Time, limit int, next store.NextFunc) (int, error)
	RequeueExpired(ctx context.Context) (int, error)
	ExpireStaleOperations(ctx context.Context, olderThan time.Duration) (int64, error)
	Gauges(ctx context.Context) (*store.Gauges, error)
}

Store is the persistence the loop needs.

Jump to

Keyboard shortcuts

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