scheduler

package
v1.5.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Scheduler

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

Scheduler manages a set of scheduled jobs. Register jobs with Schedule, then call Start once to launch all goroutines.

Expected call ordering: all Schedule calls must precede Start; Stop must be called after Start and at most once. The scheduler is a one-shot object: once stopped it cannot be restarted because the internal channels are closed during shutdown. Individual methods are protected by an internal mutex, but calling them out of order returns an error.

func New

func New() *Scheduler

New creates a new Scheduler.

func (*Scheduler) Schedule

func (s *Scheduler) Schedule(
	job types.Job,
	trigger types.Trigger,
	policy types.Policy,
) error

Schedule registers a job with its trigger and overlap policy. If job is nil, Schedule is a no-op and returns nil. Returns an error if called after Start.

func (*Scheduler) Start

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

Start launches all scheduled jobs in the background and returns immediately. Returns an error if called more than once or after Stop.

func (*Scheduler) Stop

func (s *Scheduler) Stop(force bool) error

Stop shuts down the scheduler and waits for all goroutines to exit. If force is false, the run context is cancelled and each dispatcher exits according to its policy: QueueAll flushes remaining queued events before returning; Skip, Queue, and Replace exit immediately without draining. If force is true, each relay clears its queue, cancels the in-flight job, and signals all dispatchers to exit immediately via forceCh before the run context is cancelled. Returns an error if called before Start.

Directories

Path Synopsis
jobs
Package taskschedule manages user-defined task schedules (task_schedule table).
Package taskschedule manages user-defined task schedules (task_schedule table).

Jump to

Keyboard shortcuts

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