Documentation
¶
Overview ¶
Package job is Atlas's in-process worker harness: it bridges the engine's activatable jobs to worker handlers and feeds their results back as commands (ADR-0007, streaming pull with completion-as-command).
This is the in-process form. Workers register a Handler per job type; the Runner pulls activatable jobs of those types from the state store, runs the handler, and submits CompleteJob back through the processor — the processor never blocks on the handler. A handler that returns an error is routed into the incident model (ADR-0061): the job is failed (retried while retries remain, then an incident parks its token) rather than aborting the whole Drive, so one failing job cannot poison the run loop. The gRPC streaming transport and job leases with timeout/backoff are later milestones.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompletingHandler ¶
type CompletingHandler func(Job) (Completion, error)
CompletingHandler does a job's work and returns its full Completion — outputs plus any decision evaluation. It is the widest handler shape; Handler and OutputHandler are the output-less and decision-less special cases. Returning an error fails the job (retry, then an incident) exactly as for the others.
type Completion ¶
type Completion struct {
Outputs []model.VariableValue
Decision *model.DecisionEvaluationValue
}
Completion is everything a worker hands back when a job succeeds: the output variables to write into the instance and, for a business rule task, the decision evaluation to retain for debugging (ADR-0066). Decision is nil for workers that do not produce one.
type Engine ¶
type Engine interface {
RunUntilIdle() error
CompleteJob(jobKey uint64, outputs ...model.VariableValue)
CompleteJobWithDecision(jobKey uint64, decision *model.DecisionEvaluationValue, outputs ...model.VariableValue)
FailJob(jobKey uint64, retries int32, message string, backoff int64)
}
Engine is the slice of the processor the runner drives: process queued commands, accept job completions with their output variables and (for a decision) the evaluation to retain, and accept job failures (which retry or raise an incident, ADR-0061).
type Handler ¶
Handler does a job's work with no output. Returning nil completes the job; returning an error fails it (retry while retries remain, then an incident, ADR-0061).
type Job ¶
type Job struct {
Key uint64
Type int32 // interned job-type index
ProcessInstanceKey uint64
ElementInstanceKey uint64
Retries int32
}
Job is the unit of work handed to a worker.
type OutputHandler ¶
type OutputHandler func(Job) ([]model.VariableValue, error)
OutputHandler does a job's work and returns the variables to write back into the job's process instance on completion (nil for none) — e.g. a business rule task's decision result. As for Handler, returning an error fails the job (retry, then an incident).
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner dispatches activatable jobs to registered handlers.
func (*Runner) Drive ¶
Drive runs the engine and dispatches jobs alternately until the system is idle: no pending commands and no activatable jobs for registered types. It is the in-process equivalent of workers streaming alongside a running processor.
func (*Runner) Handle ¶
Handle registers an output-less worker for a job type. The type is the interned index the compiler assigned (cross-process, globally consistent job-type interning is a later concern).
func (*Runner) HandleCompleting ¶
func (r *Runner) HandleCompleting(jobType int32, h CompletingHandler)
HandleCompleting registers a worker whose completion carries both output variables and a decision evaluation to retain (the DMN worker, ADR-0066). Same dispatch as the others; its Completion rides along on the CompleteJob command.
func (*Runner) HandleWithOutput ¶
func (r *Runner) HandleWithOutput(jobType int32, h OutputHandler)
HandleWithOutput registers a worker whose completion writes output variables back into the instance (e.g. a service-task worker that returns variables). Same dispatch as Handle; the only difference is that its returned variables ride along on the CompleteJob command.