scheduler

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsExpired

func IsExpired(s types.Schedule, now time.Time) bool

IsExpired returns true if a schedule's EndsAt has passed.

func MissedFirings

func MissedFirings(s types.Schedule, from time.Time, until time.Time, maxFirings int) ([]time.Time, error)

MissedFirings returns all firing times between `from` (exclusive) and `until` (inclusive) for the given schedule, capped at `maxFirings`. Only returns firings within the schedule's CatchupWindow relative to `until`. Returns nil if CatchupWindow is not set.

func NextRunTime

func NextRunTime(s types.Schedule, after time.Time) (time.Time, error)

NextRunTime calculates the next run time for a schedule relative to `after`. For first-time calculation, pass time.Now() as `after`.

Types

type Config

type Config struct {
	Store        *store.RedisStore
	Dispatcher   Dispatcher
	TickInterval time.Duration
	Logger       gochainedlog.Logger

	// OrphanCheckInterval controls how often orphan run detection runs.
	// Defaults to 30s. Set to 0 to disable.
	OrphanCheckInterval time.Duration
}

Config holds scheduler configuration.

type Dispatcher

type Dispatcher interface {
	Dispatch(ctx context.Context, job *types.Job, attempt int) error
	PublishEvent(event types.JobEvent)
}

Dispatcher is the interface the scheduler uses to dispatch work.

type Scheduler

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

Scheduler runs on the leader node and periodically checks for due jobs.

func New

func New(cfg Config) *Scheduler

New creates a new scheduler. Call Start() to begin the tick loop.

func (*Scheduler) Start

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

Start begins the scheduler tick loop. Safe to call multiple times (idempotent).

func (*Scheduler) Stop

func (s *Scheduler) Stop()

Stop halts the scheduler tick loop. Safe to call multiple times.

Jump to

Keyboard shortcuts

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