Glossary
The terms of @sekhmet/job's ubiquitous language, each named the way the code names it. The concepts guide explains how they fit together. Terms Sekhmet's packages share, such as Result, Option, enum and variant, Struct, Panic and main and mini, live in the root glossary and aren't redefined here.
Jobs and the graph
- Job (
Job<T, M>): a named unit of work in a job graph, pairing a plan with a run. A job is a value: its identity is itsJobId, and its name is for display, unique within a run. - Job kit (
JobKit): whatdefineJobsreturns,jobandfamily, bound to one metadata type and one context factory. - Identity (
JobId): a job's family and its key within it. The runner runs each identity once per run, however many plans need it. - Family (
family({ key, define })): a maker of jobs on the fly that gives the same job for the same key, so a graph generated from data dedupes with no cache. A plainjobis a family of one. - Name: a job's display name, used in reports, events and
Blocked. Two identities sharing a name are aDuplicateNamegraph error. - Roots (
Roots): the record of jobs a run or dry run starts from; every job reachable from them runs, and each root's outcome comes back under its key. - Once per run: within one run each identity runs once, and every dependent gets the same result; a separate run shares nothing.
Plan and run
- Plan (
plan(p)): a job's pure, synchronous dependency list, needs in plain records and arrays at any depth. A job that needs nothing omits it. - Planner (
Planner, thepa plan receives): makes needs withp.needsandp.needsIf, and reads the run'smeta. - Plan record (
PlanRecord): the plain data a plan returns. Plain values beside needs pass through untouched, a second-class escape hatch. - Need (
Need): a declared dependency on another job. Inrunit is resolved in place: to the job's value undersuccess(), or to itsJobEndunder any other condition. - Conditional need (
p.needsIf({ job, when })): a need pulled into the graph only when its guard holds,undefinedinrunotherwise. - Guard (
Guard): the condition on a conditional need, as data: a description, the needs itreads, and a test over anEndView. Made withsucceeded,failedorsucceededWith. A guard may read only its own plan's unconditional needs. - Run (
run(r, needs)): a job's body, anyasyncfunction, given its needs resolved. Its throw or rejection becomesFailed, never a rethrow. - Job run (
JobRun, thera run receives): the run'smeta, the job'sctxandcleanup, itssignal, andstep. - Step (
r.step({ name, run })): a reported sub-step of a run, which emits step events; calling it after the body finished panics.
Metadata, context and cleanup
- Metadata (
meta): the caller's value for the whole run, read by every plan,runIf, factory and body. The caller owns its resources. - Context factory (
ContextFactory): the function given todefineJobsthat builds each job'sctxfrommetajust before its run. A job that never starts, and a dry run, never call it. - Context (
ctx): a job's own value from the context factory, unseen by other jobs. - Cleanup (
Cleanup): a job's cleanup stack,defer,useandadopt, shared by its factory and run and disposed last in first out once the run settles, before the job's terminal event. A cleanup that throws fails its job, keeping an earlier error asSuppressedErrordoes.
Conditions
- Condition (
Condition, a job'srunIf): whetherrunis called once the needs settle. It also typesrun: see condition kind. success(): the default condition: every need succeeded and the run isn't cancelled.failure(): some need is unhealthy.cancelled(): the run was cancelled.always(): whatever happened.- Hand-written
runIf: a predicate over{ meta, cancelled, needs }. - Condition kind (
ConditionKind):"success", whererungets the needs' values, or"any", where it gets theirJobEnds.
Outcomes
- Job end (
JobEnd<T>): how a job ended, exactly one of five variants:Succeeded: with whatrunreturned;Failed: with whatrunthrew, or what its factory or cleanup threw;Skipped: itsrunIfwas false, or under the default a need was skipped;Blocked: a need failed or was blocked, so the body never started; it names those needs;Cancelled: the run was cancelled before or while the job ran.
- Passing / failing (
isPassing,isFailing): whether the job did what the run needed.SucceededandSkippedpass; the rest fail. - Healthy / unhealthy (
isHealthy,isUnhealthy): whether something broke.FailedandBlockedare unhealthy.Cancelledis the one variant that is healthy yet failing. all: folds a record of outcomes into one, asPromise.allfolds promises:Succeededwith every value, or else the worst:Blocked, thenCancelled, thenSkipped. It is the default rule undersuccess().continueOnError: lets a job's failure keep the run passing and out offailFast; a job blocked by it still fails the run.- Run report (
RunReport): what a run that formed a valid graph returns:outcomes, each root'sJobEndunder its key, typed;all, every job reached by name; andpassed. - Verdict (
passed): every job reached is passing, orFailedwithcontinueOnError.
Running and planning
runJobs: runs every job reachable from the roots once, returning aResultof a run report or a graph error.- Dry run (
planJobs): calls every plan, and no factory or body, and returns the wholeJobGraph, guards and conditions included. - Job graph (
JobGraph,PlannedJob): what a dry run finds: each job's needs with their guards' descriptions, itsrunIf, itscontinueOnErrorand its plan's data. - Graph error (
GraphError): a graph that can't run, returned asErrbefore any job starts:DuplicateName: two identities share a name;DuplicateKey: a family built two differently named jobs for one key;UndeclaredGuardRead: a guard reads something other than an unconditional need of its own plan;Cycle: jobs need each other, through needs or conditional needs.
- Cancellation: a run's
signalaborting, orfailFast; every body'sr.signalaborts, and a job that hasn't started runs only if itsrunIfholds for a cancelled run. failFast: cancels the run when a job fails withoutcontinueOnError.- Job event (
JobEvent, given toonEvent):Started,StepStarted,StepSucceeded,StepFailed,Finished,Skipped,BlockedandCancelled, each naming its job, for a front end to watch a run. - Misuse panic: a bug in calling code, which panics rather than returning an error: a plan that isn't plain data (
NonPlainPlan), a guard reading outside itsreads(UndeclaredGuardRead),r.stepafter the body finished (StepAfterFinish), and a cleanup registered after disposal (CleanupAfterDispose) or given a value it can't dispose (NotDisposable).