01 // What it’s for
Why reach for DurabilityOutbox
Use DurabilityOutbox when downstream projections only need the latest committed version of each key—never every intermediate edit. Because stage() lives in the same SQLite database as your application tables, your state and publication intent commit or roll back as a single atomic unit.
02 // How it works
Inside your Durable Object
- 01Rigid 1-TX coupling: Call
outbox.stage(key, value)insidectx.storage.transaction()right next to your own SQL writes—if the transaction aborts, nothing leaks to the outbox. - 021-slot latest-state coalescing: Rapid updates to the same key overwrite the pending slot and bump the monotonic
durability_outbox_seqodometer, skipping intermediate writes duringbatchDelayMsor outages. - 03Generation & version fencing: Every publication carries its monotonic
version; sinks keep the highest version seen so a delayed retry of an older version can never clobber newer state. - 04Selective per-entry retry: Returning from
publish(entries)acknowledges every entry except those explicitly marked viaentry.retry().
Storage
durability_outbox + _seq
Alarm
Shared DurabilityScheduler
Import
durability/experimental