Documentation
¶
Index ¶
- type Attempt
- type BusWatcher
- type ConditionalJob
- type Dispatcher
- type DynamicScheduler
- type GenericJob
- func (g *GenericJob) Name() string
- func (g *GenericJob) Reconcile(ctx context.Context, previous Run) (Outcome, error)
- func (g *GenericJob) Run(ctx context.Context) (Outcome, error)
- func (g *GenericJob) Schedule(ctx context.Context) string
- func (g *GenericJob) ShouldSchedule(ctx context.Context) bool
- type Job
- type JobController
- type JobRuntimeState
- type JobScheduler
- type Outcome
- type OutcomeError
- type QueueRecord
- type Reconciler
- type Request
- type RetryValidator
- type Run
- type RunList
- type RunObserver
- type RunResolution
- type RunStatus
- type StoppableBusWatcher
- type TargetOutcome
- type WorkerController
- type WorkerHealth
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 ¶
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 Dispatcher ¶ added in v2.11.0
type Dispatcher interface {
Submit(ctx context.Context, request Request) (Run, error)
Checkpoint(ctx context.Context, jobID, schedule string, nextRun time.Time) error
}
Dispatcher owns durable admission and execution. Cron only submits work.
type DynamicScheduler ¶ added in v2.7.0
type DynamicScheduler interface {
Submit(ctx context.Context, request Request) (Run, error)
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) (Outcome, error)
ReconcileFn func(ctx context.Context, previous Run) (Outcome, error)
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) 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 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
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 {
SetDispatcher(dispatcher Dispatcher)
ListRegisteredJobs() []Job
WorkerController
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 Outcome ¶ added in v2.11.0
type Outcome struct {
Status RunStatus `json:"status"`
Message string `json:"message,omitempty"`
ActivityID string `json:"activityId,omitempty"`
Targets []TargetOutcome `json:"targets,omitempty"`
}
type OutcomeError ¶ added in v2.11.0
OutcomeError carries partial results through error-only watcher contracts.
func (*OutcomeError) Error ¶ added in v2.11.0
func (e *OutcomeError) Error() string
func (*OutcomeError) Unwrap ¶ added in v2.11.0
func (e *OutcomeError) Unwrap() error
type QueueRecord ¶ added in v2.11.0
type QueueRecord struct {
JobID string `json:"jobId"`
EnvironmentID string `json:"environmentId"`
Schedule string `json:"schedule"`
LastEnqueuedAt time.Time `json:"lastEnqueuedAt"`
NextRun time.Time `json:"nextRun"`
Runs []Run `json:"runs"`
Receipts map[string]Run `json:"receipts,omitempty"`
}
QueueRecord holds atomic admission, claims, and checkpoints for one job and target.
type Reconciler ¶ added in v2.11.0
Reconciler consults domain state before repeating interrupted work.
type RetryValidator ¶ added in v2.11.0
RetryValidator rejects retries without safe persisted target evidence.
type Run ¶ added in v2.11.0
type Run struct {
ActivityEnvironmentID string `json:"activityEnvironmentId,omitempty"`
ActivityID string `json:"activityId,omitempty"`
Resolution *RunResolution `json:"resolution,omitempty"`
RequestedWithKey string `json:"requestedWithKey,omitempty"`
ID string `json:"id"`
JobID string `json:"jobId"`
EnvironmentID string `json:"environmentId"`
Trigger string `json:"trigger"`
RequestedBy string `json:"requestedBy,omitempty"`
Status RunStatus `json:"status"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
StartedAt *time.Time `json:"startedAt,omitempty"`
FinishedAt *time.Time `json:"finishedAt,omitempty"`
NextAttempt *time.Time `json:"nextAttempt,omitempty"`
AttemptCount int `json:"attemptCount"`
Owner string `json:"owner,omitempty"`
Outcome Outcome `json:"outcome"`
Attempts []Attempt `json:"attempts,omitempty"`
RemoteDeliveryAttempted bool `json:"remoteDeliveryAttempted"`
RemoteOutcome *Outcome `json:"remoteOutcome,omitempty"`
RemoteRetryRequested bool `json:"remoteRetryRequested,omitempty"`
RemoteRetryAttempted bool `json:"remoteRetryAttempted,omitempty"`
RemoteAttemptCount int `json:"remoteAttemptCount,omitempty"`
RemoteAccepted bool `json:"remoteAccepted"`
RemoteSettled bool `json:"remoteSettled"`
LastConfirmedAt *time.Time `json:"lastConfirmedAt,omitempty"`
}
type RunObserver ¶ added in v2.11.0
type RunObserver interface {
ActivityID(run Run) string
SyncRunActivity(ctx context.Context, run Run) error
}
RunObserver projects persisted runs into operator-facing activity records. ActivityID must be deterministic and empty for runs that should stay quiet.
type RunResolution ¶ added in v2.11.0
type RunStatus ¶ added in v2.11.0
type RunStatus string
RunStatus describes durable execution, independently of the configured schedule.
const ( Queued RunStatus = "queued" Waiting RunStatus = "waiting" Running RunStatus = "running" Retrying RunStatus = "retrying" Succeeded RunStatus = "succeeded" Partial RunStatus = "partial" Skipped RunStatus = "skipped" Failed RunStatus = "failed" NeedsAttention RunStatus = "needs_attention" Canceled RunStatus = "canceled" )
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.
type TargetOutcome ¶ added in v2.11.0
type WorkerController ¶ added in v2.11.0
type WorkerController interface {
RestartWatcher(ctx context.Context, watcherID string) error
WatcherHealth(watcherID string) (WorkerHealth, bool)
}
WorkerController exposes continuous-worker health and recovery operations.