Skip to main content

enqueue

Function enqueue 

Source
pub fn enqueue(work_dir: &Path, item: &WorkItem) -> Result<Enqueued, String>
Expand description

What: Write the item as a pending record, whole or absent, unless its id is already in any state. The producer never waits for a consumer and never reads anything back. Why: The id is the idempotency key; the exclusive publish makes two racing producers agree on one winner.

In TS you’d write (pseudocode):

await writeExclusive(join(workDir, 'pending', item.id), item.encode())