scheduler

package
v2.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BusWatcher added in v2.5.0

type BusWatcher interface {
	Name() string
	Start(ctx context.Context) error
	RunNow(ctx context.Context) error
}

BusWatcher is a continuous event consumer owned by the application scheduler lifecycle.

type ConditionalJob

type ConditionalJob interface {
	ShouldSchedule(ctx context.Context) bool
}

ConditionalJob allows a job to opt out of cron registration when it is disabled. Jobs that do not implement this interface are always scheduled.

type DynamicScheduler added in v2.7.0

type DynamicScheduler interface {
	AddJob(ctx context.Context, job Job) error
	RemoveJob(ctx context.Context, name string)
	HasJob(name string) bool
}

DynamicScheduler owns jobs registered and removed while the application is running.

type GenericJob

type GenericJob struct {
	JobName     string
	ScheduleFn  func(ctx context.Context) string
	RunFn       func(ctx context.Context)
	ShouldRunFn func(ctx context.Context) bool
}

GenericJob is a reusable Job built from closures. It lets a service register a per-entity dynamic job (e.g. one per GitOps sync or one per environment) without importing the scheduler package: the service constructs a GenericJob and hands it to the scheduler through the types/scheduler.Job interface.

JobName must be unique per logical job; per-entity jobs use a "<subsystem>:<entityID>" scheme (e.g. "gitops-sync:abc123"). ShouldRunFn is optional — when nil the job is always scheduled, matching the behavior of a Job that does not implement ConditionalJob.

func (*GenericJob) Name

func (g *GenericJob) Name() string

func (*GenericJob) Run

func (g *GenericJob) Run(ctx context.Context)

func (*GenericJob) Schedule

func (g *GenericJob) Schedule(ctx context.Context) string

func (*GenericJob) ShouldSchedule

func (g *GenericJob) ShouldSchedule(ctx context.Context) bool

ShouldSchedule satisfies ConditionalJob. A GenericJob without a ShouldRunFn is always scheduled; the scheduler treats a ConditionalJob returning false as "do not schedule", so nil must map to true rather than a nil-func panic.

type Job

type Job interface {
	Name() string
	Schedule(ctx context.Context) string
	Run(ctx context.Context)
}

type JobController added in v2.7.0

type JobController interface {
	GetJob(jobID string) (Job, bool)
	GetJobRuntimeState(jobID string) (JobRuntimeState, bool)
	RescheduleJob(ctx context.Context, job Job) error
	RunBusWatcherNow(ctx context.Context, watcherID string) error
}

JobController exposes scheduler operations used by job-management services.

type JobRuntimeState added in v2.4.0

type JobRuntimeState struct {
	Schedule  string
	NextRun   *time.Time
	Scheduled bool
}

JobRuntimeState describes the schedule currently installed in a scheduler. It intentionally exposes only read-only state needed by job-management APIs.

type JobScheduler added in v2.7.0

type JobScheduler interface {
	DynamicScheduler
	JobController

	RegisterJob(job Job) error
	RegisterBusWatcher(watcher BusWatcher, canRunManually bool) error
	StartScheduler() error
	GetLocation() *time.Location
	Stop(ctx context.Context) error
}

JobScheduler is the shared public contract for the actor-owned scheduler. Concrete cron and actor state remains private to the backend implementation.

type StoppableBusWatcher added in v2.7.0

type StoppableBusWatcher interface {
	BusWatcher
	Stop(ctx context.Context) error
}

StoppableBusWatcher lets a continuous watcher perform explicit shutdown work before its actor runner is joined.

Jump to

Keyboard shortcuts

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