Get the latest tech news

Building an idempotent email API with River unique jobs


Using unique jobs in River to build an email API that takes an idempotency key so that even in the event a request needs to be retried, it never sends a duplicate email.

Mutations like PUT or DELETE take more care than read, but especially when using an ACID database like Postgres, idempotency is usually very achievable as long as all changes happen in one transaction. Hopefully all responsible users will be generating V4 UUIDs that will statistically never collide with anything else, but bugs or malicious behavior could lead to duplicated keys, at which point scoping them to specific accounts becomes important, so our uniqueness is based off AccountID+ IdempototencyKey. As an additional safety feature, the API will return an error in case incoming parameters didn't match those that created an existing job.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of River

River

Photo of unique jobs

unique jobs

Photo of idempotent email API

idempotent email API

Related news:

News photo

Turn/River Agrees to Buy SolarWinds Years After Cyber-Attack

News photo

Procedural Hydrology: Dynamic lake and river simulation (2020)

News photo

Can you complete the Oregon Trail if you wait at a river for 14272 years?