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

schedule

package
v0.2.39 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package schedule provides wall-clock deadlines for periodic background work. Playback timeouts and rate limiting should continue to use elapsed time.

Index

Constants

View Source
const MaxWait = time.Minute

MaxWait bounds how long a suspended machine can take to notice overdue work after resuming, even where monotonic timers exclude time spent asleep.

Variables

This section is empty.

Functions

func Due

func Due(now, last time.Time, interval time.Duration) bool

Due checks a persisted last-attempt timestamp. A future timestamp from a corrected clock gets one new attempt; the caller records the current time.

func Wait

func Wait(ctx context.Context, now func() time.Time, interval time.Duration) bool

Wait waits one interval with bounded wall-clock rechecks. It owns no goroutine and returns false on cancellation, including when already overdue.

Types

type Deadline

type Deadline struct {
	// contains filtered or unexported fields
}

Deadline is owned by a single scheduler goroutine. Reset after a completed attempt coalesces missed intervals instead of replaying a backlog.

func New

func New(now time.Time, interval time.Duration) Deadline

func (*Deadline) Remaining

func (d *Deadline) Remaining(now time.Time) time.Duration

Remaining uses wall time. A backwards clock correction rebases the deadline once, limiting postponement to one interval without creating a retry storm.

Jump to

Keyboard shortcuts

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