Skip to content

restatedev/examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Documentation Discord Slack Twitter

Restate examples

A collection of examples that illustrate how to use Restate to solve common application challenges.

  • Basics: Small examples highlighting the basic building blocks, like durable execution or virtual objects.

  • Use Cases and Patterns: Small specific use cases, like webhooks, workflows, asynchronous task queuing.

  • Integrations: Examples of integrating Restate with other popular tools, technologies, and libraries.

  • End-to-End Applications: Runnable demo applications that consist of many components, e.g., a food ordering app, or an e-commerce site. Typically packaged as a docker compose setup.

  • Templates: Project templates for various languages, build systems and runtimes. Simple 'Hello World!' examples in a proper build setup that you can use if you want to start a brand new project for a service or lambda that will be invoked through Restate.

  • Tutorials: A step-by-step guide that builds an application and introduces the Restate concepts on the way.

Example catalogs

Have a look at the example catalog for your preferred SDK language:

TypeScript Go Python Java Kotlin Rust

Or have a look at the general catalog below:

Basics

Example Name Languages
Services - Durable Execution
Durable Building Blocks
Virtual Objects
Workflows

Use Cases and Patterns

Example Name Languages
Durable RPC, Idempotency & Concurrency
(Delayed) Message Queue
Webhook Callbacks
Convert Sync Tasks to Async
Payments Signals (Advanced)
Sagas
Stateful Actors and State Machines
Payment State Machines (Advanced)
Scheduling Tasks
Parallelizing Work
Transactional Event Processing
Event Enrichment / Joins
Durable Promises as a Service
Priority Queue

Integrations

Example Name Languages
AWS Lambda + CDK
XState
Knative

End-to-End Applications

Example Name Languages
Food Ordering App
AI Image Processing Workflow
LLM-powered Chat Bot / Task Agent
Kotlin Todo App

Templates

Tour of Restate Tutorial

Joining the community

If you want to join the Restate community in order to stay up to date, then please join our Discord or Slack. This is also the perfect place for sharing your feedback with us, learning more about Restate and connect with others!

Running the examples

Some examples are just illustrations of code, but many are runnable. Their READMEs explain how to get them running. Here are the general steps:

(1) Starting the Restate Server

To run an example locally, you need a running Restate Server instance. Some examples can be run with Docker Compose. Those already bring their own Restate server instance.

To install the Restate Server and CLI, have a look at the installation instructions in the documentation.

(2) Register the examples at Restate Server

The service endpoints need to be registered in Restate, so that Restate will proxy their function calls and do its magic. Once both server and example are running, register the example:

  • Via the CLI: restate deployments register localhost:9080
  • Via curl localhost:9070/deployments -H 'content-type: application/json' -d '{"uri": "http://localhost:9080"}'

Important When running Restate with Docker, use host.docker.internal instead of localhost in the URIs above.


Adding Examples and Releasing (for Restate developers/contributors)

When adding a new example:

  • Make sure it has a README
  • Add it to the following catalogs: the one in this readme, the language-specific catalog, and the patterns-use-cases catalog if it is a pattern.
  • Check it's listed in run tests/update examples scripts in .tools
  • Optionally, add it to the zips script and release.yaml

Creating a Release

Before releasing, trigger the "pre-release" workflow to update sdk versions. This automatically creates a pull request, which must be manually merged.

Once the repo is ready for the release, push a tag of the form vX.Y.Z:

git checkout main
git tag -m "Examples v0.9.1" v0.9.1
git push origin v0.9.1

This triggers a workflow that creates a draft release on GitHub, which you need to approve to finalize it.

Please update the version tag referenced on the Tour of Restate documentation page.