mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 21:10:59 +00:00
Since the lab staging reads a long report in parts, one auto-index could make the transcription plus up to twenty reads of two calls each at the person's response timeout, hours past pg-boss's fifteen-minute default, which failed the job and retried it beside the reads still running. The staging now takes the run's deadline as a schedule and plans only the reads that fit before it. The index job is long, with an expiry above the calls that run before the plan can say no, a stop on jobDeadline and a lock per document; the document run hands the same staging its own deadline, which moves the run's expiry as the reads are planned. The document summary, one call and its reasoning repeat, gets an expiry above that worst case. ocrReadCallMs in the read core is the one per-call timeout both deadlines divide by. The expiry guard now names every importer of the document and lab read entry points with the queues that reach it. The runtime guard's planted cases stripped every file's comments again on each rescan, which took over a second alone and timed out under a full parallel run; the stripped text is now memoised. Refs #1274
36 lines
1.4 KiB
TypeScript
36 lines
1.4 KiB
TypeScript
/**
|
|
* The queue facts of `document-index.ts`: its name and, where it has them, its
|
|
* schedule and concurrency. They live apart from the handler so the worker
|
|
* registry and every sender can read them without loading the job.
|
|
*/
|
|
import {
|
|
COMPLETION_CEILING_MS,
|
|
expireAboveModelTime,
|
|
} from "@/lib/jobs/model-time";
|
|
|
|
export const DOCUMENT_INDEX_QUEUE = "document-index";
|
|
|
|
/**
|
|
* The completions that run before the job's deadline can turn a read away:
|
|
* the transcription, and the first lab-staging read with its corrective
|
|
* retry (`1 + OCR_EXTRACT_MODEL_CALLS`; the staging plans at least one read).
|
|
* Every further read is planned against the deadline.
|
|
*/
|
|
export const DOCUMENT_INDEX_UNPLANNED_COMPLETIONS = 3;
|
|
|
|
/**
|
|
* The job's expiry. Since the lab staging reads a long report in parts, one
|
|
* index could make the transcription plus up to twenty reads of two calls
|
|
* each at the person's timeout, hours past pg-boss's fifteen-minute default,
|
|
* which then failed the job and retried it beside the reads still running
|
|
* (#1274). The staging now plans its reads to end before three quarters of
|
|
* this (`jobDeadline`); what runs before that plan, at the largest setting,
|
|
* still ends below it.
|
|
*/
|
|
export const DOCUMENT_INDEX_EXPIRE_SECONDS = expireAboveModelTime(
|
|
DOCUMENT_INDEX_UNPLANNED_COMPLETIONS * COMPLETION_CEILING_MS,
|
|
);
|
|
|
|
/** Serial concurrency — provider calls + PDF parse, kept off the request pool. */
|
|
export const DOCUMENT_INDEX_CONCURRENCY = 1;
|