Skip to content
webtypPublic

About

Client-side outbox: durable queue of pending mutations over storage.Conn with idempotency keys, retry with backoff and single-writer delivery

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

66 Commits

Folders and files

Repository files navigation

webtyp.com/outbox

A durable, ordered queue of pending mutations with retry, rejection, and coalescing.

Like the "Outbox" folder of an email client: it stores what you wrote and has not been sent yet.

It runs in the browser (compiles to TinyGo WASM, over webtyp/indexdb) and in tests (over webtyp.com/storage/mem), always through *orm.DB. The browser environment creates the store from the model directly; backend environments can create it with migrate.Migrate, which uses ddl.Sync (flow).

Warning

Deliver blocks until every due mutation was sent; never call it from a JavaScript event callback in WASM — run it in its own goroutine.

One-tab rule

Only one writer (one tab) per database at a time is supported. Ensure only a single tab is active for this.

Example

box, _ := outbox.New(orm.New(conn), ids, time.NowNano)
id, _ := box.Enqueue(outbox.Entry{Op: "clinical_encounter.save_draft", Payload: b, Coalesce: visitID})
go func() { report, err := box.Deliver(sender) /* … */ }()

About

Client-side outbox: durable queue of pending mutations over storage.Conn with idempotency keys, retry with backoff and single-writer delivery

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages