scheduler

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package scheduler delivers durable Timebox messages when they become due

Index

Constants

View Source
const (
	// DefaultRescanInterval controls discovery of changes from other processes
	DefaultRescanInterval = time.Second

	// DefaultRetryDelay controls local retry after scheduler errors
	DefaultRetryDelay = time.Second
)

Variables

View Source
var (
	// ErrStoreRequired indicates a Scheduler has no Store
	ErrStoreRequired = errors.New("scheduler store is required")

	// ErrProcessorRequired indicates a Scheduler has no Processor
	ErrProcessorRequired = errors.New("scheduler processor is required")

	// ErrRetry leaves a due message active without logging the attempt
	ErrRetry = errors.New("retry scheduled message")

	// ErrInvalidRescanInterval indicates a non-positive rescan interval
	ErrInvalidRescanInterval = errors.New(
		"scheduler rescan interval must be positive",
	)

	// ErrInvalidRetryDelay indicates a non-positive retry delay
	ErrInvalidRetryDelay = errors.New("scheduler retry delay must be positive")
)

Functions

This section is empty.

Types

type Clock

type Clock func() time.Time

Clock provides the current scheduler time

type Config

type Config struct {
	Store            *timebox.Store
	Processor        Processor
	Clock            Clock
	TimerConstructor TimerConstructor
	RescanInterval   time.Duration
	RetryDelay       time.Duration
}

Config configures a disposable schedule runner

type Processor

type Processor func(*timebox.Transaction, *timebox.Message) error

Processor changes state in response to one due message

type Scheduler

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

Scheduler maintains a disposable heap over durable schedule aggregates

func New

func New(cfg Config) (*Scheduler, error)

New constructs a disposable schedule runner

func (*Scheduler) Run

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

Run delivers due messages until ctx ends

func (*Scheduler) Wake

func (s *Scheduler) Wake()

Wake requests prompt reconciliation with the durable schedule index

type Timer

type Timer interface {
	Channel() <-chan time.Time
	Reset(time.Duration) bool
	Stop() bool
}

Timer provides the resettable wakeup used by Scheduler

type TimerConstructor

type TimerConstructor func(time.Duration) Timer

TimerConstructor creates a Timer for a delay

Jump to

Keyboard shortcuts

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