← Back to the notebook

System design / SAMPLE ARTICLE

A stateless worker still needs somewhere to put the state.

This is a sample article while I build the new site. It tests the publishing layout; the implementation described below is still in progress.

Start with the question

A newsletter sounds small: collect an email, confirm it, send something later. But what happens if someone unsubscribes while a message is waiting in a queue?

The interesting part is deciding which record gets the final say.

One place gets the final say

For this project, D1 will hold the authoritative subscription and consent records. Pending and verified KV entries will be projections that can be rebuilt. A delayed KV write must never reverse an unsubscribe.

A queue carries a request to do work. It does not prove that the work is still wanted. Before sending a campaign, the consumer needs to check the current consent record.

Diagram: the planned subscription path. Confirmation changes authoritative consent in D1. A KV projection cannot override that record. Sending requires a fresh consent check, including after an unsubscribe.

The awkward case is the useful one

If sending an email times out, I may not know whether it was delivered. Retrying blindly could send it twice. The plan is to record uncertain delivery and reconcile it, with bounded retries rather than a promise of exactly-once delivery.

That is the kind of failure I want to write about here: small enough to reproduce, but useful far beyond a blog.

See what is being built, or bring your own design question.

Around the table.

Comments will open when moderation is ready. In the meantime, you can keep reading through RSS.

Somewhere in my notes…

ESC TO CLOSE SEARCH THE NOTEBOOK