Add the job store interface and its memory store
The print queue is to keep its jobs in a store that can outlive the process. printqueue now defines that Store: a job is a Record with one or more deliveries, one per printer, each with a stored state (queued, sending, done, failed or uncertain), its attempts, error and times. Add, Sending and Finish commit each change; Finish also drops the jobs, deliveries and content retention lets go of, in the same commit. Load turns every delivery found in sending into uncertain and says which. MemoryStore implements it in memory, for when no state directory is set. It refuses to mark a finished delivery again, so a bug that would resend a job shows up as an error. The references of unique jobs are kept per source, the newest 512, apart from the jobs themselves, for the duplicate check to come. Nothing uses the store yet. 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
50db21190b
commit
888470bbdc
3 files changed
+575
No files matched your search
@@ -0,0 +1,9 @@
|
||||
package printqueue
|
||||
|
||||
// NewDurableMemoryStore returns a MemoryStore that reports itself durable,
|
||||
// so that a second Queue on it stands for the daemon after a restart.
|
||||
func NewDurableMemoryStore() *MemoryStore {
|
||||
s := NewMemoryStore()
|
||||
s.durable = true
|
||||
return s
|
||||
}
|
||||
Reference in new issue
Block a user