Skip to content
@resonatehq-examples

Resonate example applications

Examples of Resonate in action.

resonatehq-examples org readme banner

Resonate Example Applications

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.

Why Resonate?

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

Quick Start

1. Install the Resonate Server & CLI

brew install resonatehq/tap/resonate

2. Install the Resonate SDK

TypeScript:

npm install @resonatehq/sdk

Python:

pip install resonate-sdk

3. Write your first Resonate Function

A 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);

Working example →

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 alive

Working example →

4. Start the server

resonate dev

5. Start the worker

TypeScript:

npx ts-node countdown.ts

Python:

python countdown.py

6. Activate the function

Activate the function with execution ID countdown.1:

resonate invoke countdown.1 --func countdown --arg 5 --arg 60

7. Result

You will see the countdown in the terminal:

Countdown: 5
Countdown: 4
Countdown: 3
Countdown: 2
Countdown: 1
Done!

Featured Examples

🎯 Start Here

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

🚀 Production Patterns

Real-world architectures:

Saga Pattern & Distributed Transactions

Human-in-the-Loop Workflows

Message Queue Integration

  • Kafka Worker - Concurrent message processing without head-of-line blocking (Python)
  • Load Balancing - Distribute work across worker pools (TypeScript, Python)

Serverless & FaaS

Run long-duration workflows on serverless platforms that have execution time limits:

AI & LLM Workflows

HTTP APIs

  • Async HTTP API - Submit job, poll for results (TypeScript, Python)
  • Async RPC - Cross-process communication (Python)

🔧 Infrastructure Examples

Deploy and operate Resonate:

Browse by Language

TypeScript

See all TypeScript examples →

Python

See all Python examples →

Key Concepts Demonstrated

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

From Development to Deployment

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

Resources

Documentation

SDKs

Community

  • 💬 Discord - Ask questions, share patterns
  • 🐛 Issues - Report bugs or request examples
  • 🌐 Website - Learn more about Resonate

Contributing

We welcome contributions! To add a new example:

  1. Fork the example template or similar existing example
  2. Build your example following existing patterns
  3. Document with clear README explaining the use case
  4. Test that it works from a fresh clone
  5. Submit a PR with description of what problem it solves

See contribution guidelines for details.

Example Quality Standards

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

License

Most examples are MIT licensed. Check individual repositories for specifics.


Built with Resonate - Making distributed systems simple since 2023.

Get StartedJoin DiscordLearn More

Popular repositories Loading

  1. example-tigerbeetle-account-creation-ts example-tigerbeetle-account-creation-ts Public

    An example demonstrating how to maintain consistency in the absence of transactions, using the Write Last, Read First principle featuring TigerBeetle

    TypeScript 5

  2. example-kafka-worker-py example-kafka-worker-py Public

    Forked from flossypurse/batch-record-deletion

    Example app showcasing Redpanda + Resonate

    Python 3

  3. example-openai-deep-research-agent-ts example-openai-deep-research-agent-ts Public

    A recursive Deep Research Assistant powered by OpenAI and Resonate's Distributed Async Await.

    TypeScript 3

  4. example-schedule-reminder-agent-py example-schedule-reminder-agent-py Public

    An autonomous, long-running Reminder Assistant powered by OpenAI and Resonate's Distributed Async Await.

    Python 2

  5. example-openai-deep-research-agent-py example-openai-deep-research-agent-py Public

    A recursive Deep Research Assistant powered by OpenAI and Resonate's Distributed Async Await.

    Python 1

  6. example-browser-worker-ts example-browser-worker-ts Public

    A Resonate Worker running in a browser window or browser tab

    HTML 1

Repositories

Showing 10 of 48 repositories

Top languages

Loading…

Most used topics

Loading…