Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConditionalJob ¶
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) 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.