api: NewBatchRunner — the batch fetch adapter, retry on busy, outcome metrics

Wire the batch runner to fetchTarget and feed the sift_batch_* metrics.
New internal/api/batch.go: NewBatchRunner overwrites cfg.Hooks (Job, Target,
JobSeconds, Depth, Inflight → s.Prom) and sets the runner's FetchFunc to
batchFetch, which tags the context as a batch fetch, runs under requestDeadline,
and maps fetchTarget's errors to what the runner retries (429/503 →
ErrRetryLater) and what the metrics classify (batchOutcome). Added the Batch
field to Server (nil → task 07 answers 503 "batch disabled") and, in
extractPDF, charged the PDF pool to c.Name+"/batch" under the batch mark so a
batch never takes a caller's interactive slot while the single-flight key is
unchanged. No HTTP endpoints.

Co-Authored-By: ornith-1.5-35b-a3b <ornith-1.5-35b-a3b@llama.cpp.invalid>
This commit is contained in:
2026-09-26 22:43:28 -07:00
co-authored by ornith-1.5-35b-a3b
parent 0d923bc366
commit 72e0828360
5 changed files with 325 additions and 1 deletions
+4
View File
@@ -73,6 +73,10 @@ type Server struct {
pdfPoolOnce sync.Once
// Batch is the batch runner; nil means the /v1/batch endpoints (task 07) answer 503
// "batch disabled".
Batch *batch.Runner
// uploads bounds how many /v1/extract bodies (up to PDFMaxUpload each) are read into
// memory at once, ahead of the PDF pool's own limits.
uploads chan struct{}