Class JobTracking
java.lang.Object
com.kingsrook.qqq.backend.core.jobs.progress.JobTracking
Tracking jobs for work that no durable plan runs (for example an assistant
turn): a jobs_job row the owner sees in the Jobs tray, with the same live
progress and log as a durable job. The work itself is not durable: if this
pod goes away, the reaper fails the row with an honest message.
Integer jobId = JobTracking.start(new TrackedJobRequest().withUserId(user)
.withLabel("Assistant answer").withProcessName("assistant.turn"));
JobTracking.onCancel(jobId, () -> cancelTurn());
JobTracking.progress(jobId).phases(...).phase("thinking").message("...");
JobTracking.finish(jobId, JobStatus.COMPLETED, "Answered.");
Requires the durable jobs runtime to be running on this pod.-
Method Summary
Modifier and TypeMethodDescriptionstatic voidFinalize with COMPLETED, FAILED or CANCELLED (the first final status wins).static voidRecord that the work is alive (progress flushes do this too).static voidRegister a listener run on this pod when a client cancels the job; it must stop the work and call finish(..., CANCELLED).static JobProgressA progress reporter for the tracking job (phases, counts, message, log).static Integerstart(TrackedJobRequest request) Start a RUNNING tracking job; returns its jobs_job id.
-
Method Details
-
start
Start a RUNNING tracking job; returns its jobs_job id.- Throws:
QException
-
progress
A progress reporter for the tracking job (phases, counts, message, log). Keep and reuse one reporter per job: it holds the phase state.- Throws:
QException
-
heartbeat
Record that the work is alive (progress flushes do this too).- Throws:
QException
-
finish
Finalize with COMPLETED, FAILED or CANCELLED (the first final status wins).- Throws:
QException
-
onCancel
Register a listener run on this pod when a client cancels the job; it must stop the work and call finish(..., CANCELLED).- Throws:
QException
-