The Problem That Started It All
Have you ever reached for a workflow engine because you just needed one thing — to make sure a function finishes even if your process restarts — and suddenly found yourself running a whole distributed system?
I’ve been there. You want your order processing, provisioning, or data pipeline to survive a crash or a deploy. You look around, and the options are powerful — but they come with strings attached. Docker Compose files, separate servers, authentication, task queues, multiple databases to manage, YAML, DSLs, complex rules about what you can and can’t write in your own code.
I didn’t need a platform. I just needed my functions to be durable. That’s it.
I wanted: call a function, if it crashes pick up where it left off, don’t re-run the stuff that already finished.
I didn’t want: to become a DevOps engineer just to run some Go code.
So I built go-endure.
✨ What It Is
go-endure is a tiny Go library for durable execution. Here’s the core idea in one paragraph:
Wrap each side effect in a
Step(). Every result gets checkpointed. If your process dies, another one picks up the workflow, runs it from the top, and any step that already finished just returns its stored result — it never runs twice.
There’s no server. No YAML. No brokers. No cluster. Just your code and a database.
func ProcessOrder(ctx endure.Context, order Order) (Result, error) {
// Step 1 — reserve stock
res, err := endure.Step(ctx, "reserve", func(ctx context.Context) (string, error) {
return reserveStock(ctx, order.ID)
})
if err != nil {
return Result{}, err
}
// Step 2 — wait for payment (worker doesn't hang around waiting)
if _, err := endure.Wait[bool](ctx, "payment-confirmed"); err != nil {
return Result{}, err
}
// Step 3 — ship
return endure.Step(ctx, "ship", func(ctx context.Context) (Result, error) {
return shipOrder(ctx, res)
})
}
That’s it. It reads like normal Go because it is normal Go.
🤔 The Philosophy: Less Infrastructure, More Code
Every existing solution makes a trade-off that eventually felt like too much for what I was building:
| Tool | What you get | What you inherit |
|---|---|---|
| Temporal/Cadence | Mature, powerful, multi-language | Server cluster, event history, deterministic workflow rules, task queues, operational complexity |
| Self-rolled | Total control | You write retries, state tracking, recovery, idempotency, failover… |
| go-endure | Durable steps, retries, sleeps, signals, compensation | Your code + one database |
go-endure sits right in that sweet spot I kept looking for but couldn’t find:
- ✅ PostgreSQL today, SQLite coming soon — use what you’re already running. No extra services.
- ✅ Zero learning curve — your workflows are just Go functions. No new concepts to memorise.
- ✅ Multi-replica safe — run as many copies as you like. Leases and
FOR UPDATE SKIP LOCKEDmean work gets picked up exactly once across workers. - ✅ Sagas built in —
Defer()registers compensation steps that run automatically on failure. - ✅ Durable timers & waits —
Sleep()andWait()park the workflow in the database; no worker hangs around waiting.
🧱 How It Actually Works (Without The Magic)
The design is intentionally simple — there’s no clever event history replay going on:
- Your workflow runs from the top every time it resumes — after a crash, restart, sleep, or retry.
-
Each
Stepchecks the database first — if it already succeeded, return that value immediately. Don’t run the function again. - If it hasn’t run yet — execute it, store the result, mark it done.
-
When it suspends —
SleeporWaitparks the workflow row with arun_attime or awaitingstatus. Another replica can pick it up later. - Failover via leases — a worker holds a temporary lease. If it disappears, the lease expires and another replica claims the work. No leader election needed — Postgres is the coordinator.
That’s really all there is to it. Postgres does the heavy lifting on locking, transactions, and concurrency — battle-tested stuff that’s been around longer than most of us have been coding.
🚧 What’s Next — And Why Your Input Matters
go-endure is fresh — it’s been out for a few weeks — but the response so far has been amazing. I’ve already opened GitHub issues based on the feedback I’ve received, covering:
- 📋 Better guidance on common pitfalls and safe workflow evolution
- 🧹 Built-in helpers for workflow cleanup and retention
- 📊 Simple monitoring/status helpers so you don’t write the same SQL queries
- 📈 Metrics hooks for observability without locking into specific tools
- 💾 SQLite support — because sometimes you don’t even want a database server. File-based durability for CLI tools, single instances, and offline workflows.
My goal is simple: keep it small, keep it focused, make it incredibly easy to adopt. No feature creep — just solve the durable execution problem well and get out of your way.
🤝 Come Say Hello
If you’ve ever thought “I just need my function not to run twice when something restarts — do I really need all that infrastructure?” — this library is for you.
- 🔗 GitHub: github.com/appex-uk/go-endure
- ⭐ Star the repo to follow progress — SQLite support is the next big milestone
- 🐛 Issues and discussions are open — every question, bug report, and idea helps shape where it goes
Whether it’s feedback on the API, a use case I haven’t considered, or even just “this is exactly what I needed” — all of it is incredibly welcome. Thanks for reading, and here’s to less infrastructure and more code. 🎯
"Simplicity is the ultimate sophistication." — Sometimes the best tool is the one that gets out of your way.
Top comments (0)