Restore stored jobs at start, ending interrupted sends uncertain
Breaking: job status can be "uncertain", a new status value. Clients that switch on status must handle it. The queue loads what its store keeps before the worker, the server and the subscriptions start. Queued deliveries wait again in submission order, ahead of any new job, even beyond queue.size: Submit answers queue_full until the backlog falls below it. Restored statuses answer at once, and the sequence continues from the highest stored. A delivery found in sending at start may have reached the printer, so the store ends it uncertain, a new terminal state, and it is never sent again; a person checks the paper and sends it again if it is missing. Each one is logged once at WARN by its job's ID, printer, source and reference. A job's status is uncertain once all its deliveries have finished and any is, over failed over done. With the memory store there is nothing to restore, so the daemon behaves as before; a store on disk comes in stage 1d. Part of stage 1c of docs/plans/job-store.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9b25c1bfd3
commit
45b57ab196
9 files changed
+405
-21
No files matched your search
@@ -19,18 +19,19 @@ var deliveryKinds = []deliveryKind{
|
||||
{"sending", StoredSending, true},
|
||||
{"done", StoredDone, false},
|
||||
{"failed", StoredFailed, false},
|
||||
{"uncertain", StoredUncertain, false},
|
||||
}
|
||||
|
||||
// A job's status follows from its deliveries': queued while every one
|
||||
// waits, printing while any is unfinished once one was taken or finished,
|
||||
// and once all have finished, failed over done. Every mix of one, two and
|
||||
// three deliveries is checked.
|
||||
// and once all have finished, uncertain over failed over done. Every mix
|
||||
// of one, two and three deliveries is checked.
|
||||
func TestJobStateFromDeliveries(t *testing.T) {
|
||||
for n := 1; n <= 3; n++ {
|
||||
for _, mix := range mixes(n) {
|
||||
var ds []*delivery
|
||||
var names []string
|
||||
waiting, finished, failed := 0, 0, 0
|
||||
waiting, finished, failed, uncertain := 0, 0, 0, 0
|
||||
for _, k := range mix {
|
||||
ds = append(ds, &delivery{Delivery: Delivery{State: k.state}, taken: k.taken})
|
||||
names = append(names, k.name)
|
||||
@@ -42,6 +43,9 @@ func TestJobStateFromDeliveries(t *testing.T) {
|
||||
case "failed":
|
||||
finished++
|
||||
failed++
|
||||
case "uncertain":
|
||||
finished++
|
||||
uncertain++
|
||||
}
|
||||
}
|
||||
want := StateDone
|
||||
@@ -50,6 +54,8 @@ func TestJobStateFromDeliveries(t *testing.T) {
|
||||
want = StateQueued
|
||||
case finished < n:
|
||||
want = StatePrinting
|
||||
case uncertain > 0:
|
||||
want = StateUncertain
|
||||
case failed > 0:
|
||||
want = StateFailed
|
||||
}
|
||||
@@ -67,6 +73,8 @@ func TestJobStateFromDeliveries(t *testing.T) {
|
||||
{[]string{"waiting", "done"}, StatePrinting},
|
||||
{[]string{"failed", "waiting", "sending"}, StatePrinting},
|
||||
{[]string{"done", "failed", "done"}, StateFailed},
|
||||
{[]string{"failed", "uncertain", "done"}, StateUncertain},
|
||||
{[]string{"uncertain", "taken"}, StatePrinting},
|
||||
{[]string{"done", "done", "done"}, StateDone},
|
||||
} {
|
||||
var ds []*delivery
|
||||
|
||||
Reference in new issue
Block a user