Examples of production-ready patterns demonstrating distributed async await and durable execution.
This organization hosts battle-tested patterns for building reliable distributed systems without the complexity. From human-in-the-loop workflows to saga patterns, from serverless long-running functions to Kafka workers - see how Resonate solves real problems with clean code.
Write sequential code. Get distributed systems guarantees.
Resonate handles the hard parts automatically:
- ✅ Crash recovery - Resume exactly where you left off
- ✅ Retries & timeouts - Automatic with exponential backoff
- ✅ Idempotency - Safe to retry operations
- ✅ Concurrency - Structured fork-join patterns
- ✅ Observability - Built-in tracing and metrics
No more:
- ❌ Writing retry logic everywhere
- ❌ Managing distributed state machines
- ❌ Debugging non-deterministic failures
- ❌ Building custom orchestration layers
brew install resonatehq/tap/resonateTypeScript:
npm install @resonatehq/sdkPython:
pip install resonate-sdkA countdown as a loop. Simple, but the function can run for minutes, hours, or days, despite restarts.
TypeScript (countdown.ts):
import { Resonate, type Context } from '@resonatehq/sdk';
function* countdown(context: Context, count: number, delay: number) {
for (let i = count; i > 0; i--) {
// Run a function, persist its result
yield* context.run((context: Context) => console.log(`Countdown: ${i}`));
// Sleep
yield* context.sleep(delay * 1000);
}
console.log("Done!");
}
// Instantiate Resonate
const resonate = new Resonate({ url: 'http://localhost:8001' });
// Register the function
resonate.register(countdown);Python (countdown.py):
from resonate import Resonate, Context
from threading import Event
def countdown(ctx: Context, count: int, delay: int):
for i in range(count, 0, -1):
# Run a function, persist its result
yield ctx.run(ntfy, i)
# Sleep
yield ctx.sleep(delay)
print("Done!")
def ntfy(_: Context, i: int):
print(f"Countdown: {i}")
# Instantiate Resonate
resonate = Resonate.remote()
# Register the function
resonate.register(countdown)
resonate.start() # Start Resonate threads
Event().wait() # Keep the main thread aliveresonate devTypeScript:
npx ts-node countdown.tsPython:
python countdown.pyActivate the function with execution ID countdown.1:
resonate invoke countdown.1 --func countdown --arg 5 --arg 60You will see the countdown in the terminal:
Countdown: 5
Countdown: 4
Countdown: 3
Countdown: 2
Countdown: 1
Done!
Perfect for learning the basics:
| Example | Description | Language |
|---|---|---|
| Human in the Loop | Workflows that pause for approval | TypeScript |
| Money Transfer | Saga pattern for distributed transactions | TypeScript |
| Hello World | Your first durable function | TypeScript, Python |
Real-world architectures:
- Money Transfer - Atomic operations across accounts (TypeScript)
- Approval Workflows - Workflows that suspend awaiting human input (TypeScript)
- Website Summarization Agent - AI summarization with approval (TypeScript, Python)
- Kafka Worker - Concurrent message processing without head-of-line blocking (Python)
- Load Balancing - Distribute work across worker pools (TypeScript, Python)
Run long-duration workflows on serverless platforms that have execution time limits:
- Deep Research Agent (Cloudflare) - Recursive AI research (TypeScript)
- Deep Research Agent (GCP) - Recursive AI research (TypeScript)
- Countdown (Supabase) - Durable timers on Edge Functions (TypeScript)
- TigerBeetle + Resonate - Durable financial transactions (TypeScript)
- AI Travel Assistant - Multi-step AI agent with tool use (Python)
- Bluesky Scraper - Durable social media ingestion (TypeScript)
- Async HTTP API - Submit job, poll for results (TypeScript, Python)
- Async RPC - Cross-process communication (Python)
Deploy and operate Resonate:
- Countdown Examples - Durable sleep across platforms (TypeScript, Python)
- Token Auth - Authentication patterns (TypeScript)
| Concept | What It Solves | Example |
|---|---|---|
| Durable Execution | Functions survive crashes and resume | Hello World |
| Saga Pattern | Distributed transactions without 2PC | Money Transfer |
| Human-in-the-Loop | Workflows pause for external input | Approval Workflows |
| Structured Concurrency | Fork-join parallelism made safe | Load Balancing |
| Durable Sleep | Long waits without holding resources | Countdown |
| Idempotency | Safe retries without side effects | Money Transfer |
| RPC | Cross-process durable calls | Async RPC |
Code that works locally works in production - no changes needed. Just point your SDK at a remote Resonate server:
// Local development (embedded server)
const resonate = new Resonate();
// Production (remote server)
const resonate = new Resonate({
url: 'https://resonate.example.com',
auth: { username: 'user', password: 'pass' }
});Deploy Resonate server anywhere:
- Docker / Kubernetes
- Cloud VMs (AWS, GCP, Azure)
- Self-hosted on-prem
- 📘 Official Docs
- 🧠 Distributed Async Await Explained
- 📖 SEAA (Systems Engineering for Agentic Applications)
- TypeScript SDK - npm install @resonatehq/sdk
- Python SDK - pip install resonate-sdk
- 💬 Discord - Ask questions, share patterns
- 🐛 Issues - Report bugs or request examples
- 🌐 Website - Learn more about Resonate
We welcome contributions! To add a new example:
- Fork the example template or similar existing example
- Build your example following existing patterns
- Document with clear README explaining the use case
- Test that it works from a fresh clone
- Submit a PR with description of what problem it solves
See contribution guidelines for details.
All examples in this organization follow these standards:
- ✅ Runnable - Clear installation and run instructions
- ✅ Documented - Explains what, why, and how
- ✅ Tested - Works from a fresh git clone
- ✅ Modern - Uses latest SDK versions
- ✅ Clean - Well-structured, readable code
Most examples are MIT licensed. Check individual repositories for specifics.
Built with Resonate - Making distributed systems simple since 2023.
