Skip to content

restatedev/examples

Repository files navigation

Documentation Discord Twitter

Restate examples

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

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

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

  • 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.

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

  • Templates: Project templates for various languages and build systems. 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.

Examples by Language

TypeScript

Type Name / Link
Basics Workflows, Durable Execution, Event-processing, Virtual Objects
Use Cases Sagas
Use Cases Durable Promises
Use Cases State Machines
Use Cases Payment Service
Use Cases Async Tasks - Payments
End-to-End Food Ordering App
End-to-End AI Image Processing Workflow
End-to-End LLM-powered Chat Bot / Task Agent
Tutorial Tour of Restate
Templates Restate Node/TS Template
Templates Restate Bun/TS Template
Templates Restate CloudFlare Workers/TS Template
Templates Restate Deno/TS Template
Templates Testing Restate app with Test Containers

Java

Type Name / Link
Templates Maven Template
Templates Maven - Spring Boot Template
Templates Maven - Quarkus Template
Templates Gradle Template
Basics Durable Execution, Event-processing, Virtual Objects
Use Cases Sagas
Use Cases Payment Service
Use Cases Async Tasks - Payments
Patterns Spring & Spring JPA
End-to-End Food Ordering App
Tutorial Tour of Restate

Kotlin

Type Name / Link
Templates Template using Gradle
Basics Durable Execution, Event-processing, Virtual Objects
Use Cases Sagas
End-to-End Food Ordering App
End-to-End Todos Kotlin Multiplatform + Android app

Python

Type Name / Link
Templates Python Template
Tutorial Tour of Restate

Go

Type Name / Link
Templates Go Template
Tutorial Tour of Restate
Tutorial Restate + Knative

Rust

Type Name / Link
Templates Rust Template
Templates Rust - Shuttle.rs Template

Joining the community

If you want to join the Restate community in order to stay up to date, then please join our Discord. The Discord server 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 generally explain how to get them running. Here are the general steps:

(1) Starting the Restate Server

Examples that run individually typically need a running Restate Server instance. Some examples can be run with Docker Compose. Those already bring their own Restate server instance.

You can launch Restate in a number of ways, including using the Restate Cloud service. See Get Restate for all options to run Restate. Here is a short-list of options to run Restate Server locally.

Install and run the restate-server binary:

  • Download from https://github.com/restatedev/restate/releases
  • Install with Homebrew: brew install restatedev/tap/restate-server
  • Install with npm: npm install --global @restatedev/restate-server@latest
  • Run in Docker: docker run --name restate_dev --rm -p 8080:8080 -p 9070:9070 -p 9071:9071 --add-host=host.docker.internal:host-gateway docker.io/restatedev/restate:latest

(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 this README
  • 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.