scheduler

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 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)
}

Jump to

Keyboard shortcuts

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