Restate Rust SDK
Restate is a system for easily building resilient applications using distributed durable async/await. This repository contains the Restate SDK for writing services using Rust.
Community
- π€οΈ Join our online community for help, sharing feedback and talking to the community.
- π Check out our documentation to get quickly started!
- π£ Follow us on Twitter for staying up to date.
- π Create a GitHub issue for requesting a new feature or reporting a problem.
- π Visit our GitHub org for exploring other repositories.
Using the SDK
Add Restate and Tokio as dependencies:
[]
= "0.1"
= { = "1", = ["full"] }
Then you're ready to develop your Restate service using Rust:
use *;
;
async
Running on Lambda
The Restate Rust SDK supports running services on AWS Lambda using Lambda Function URLs. This allows you to deploy your Restate services as serverless functions.
Setup
First, enable the lambda feature in your Cargo.toml:
[]
= { = "0.1", = ["lambda"] }
= { = "1", = ["full"] }
Basic Lambda Service
Here's how to create a simple Lambda service:
use *;
;
async
Deployment
-
Install
cargo-lambdacargo install cargo-lambda -
Build your Lambda function:
-
Create a Lambda function with the following configuration:
- Runtime: Amazon Linux 2023
- Architecture: arm64
-
Upload your
zipfile to the Lambda function.
Logging
The SDK uses tokio's tracing crate to generate logs.
Just configure it as usual through tracing_subscriber to get your logs.
Testing
The SDK uses Testcontainers to support integration testing using a Docker-deployed restate server.
The restate-sdk-testcontainers crate provides a framework for initializing the test environment, and an integration test example in testcontainers/tests/test_container.rs.
async
Versions
The Rust SDK is currently in active development, and might break across releases.
The compatibility with Restate is described in the following table:
| Restate Server\sdk-rust | < 0.4 | 0.4 - 0.5 | 0.6 | 0.7 |
|---|---|---|---|---|
| < 1.3 | β | β | β | β |
| 1.3 | β | β | β (1) | β (2) |
| 1.4 | β | β | β | β (2) |
| 1.5 | β (3) | β | β | β |
(1) Note bind_with_options works only from Restate 1.4 onward.
(2) Note the new retry_policy options work only from Restate 1.5 onward. Check the in-code documentation for more details.
(3) Warning SDK versions < 0.4 are deprecated, and cannot be registered anymore. Check the Restate 1.5 release notes for more info.
Contributing
Weβre excited if you join the Restate community and start contributing! Whether it is feature requests, bug reports, ideas & feedback or PRs, we appreciate any and all contributions. We know that your time is precious and, therefore, deeply value any effort to contribute!
Building the SDK locally
Prerequisites:
To build and test the SDK:
just verify
Releasing
You need the Rust toolchain. To verify:
just verify
To release we use cargo-release:
cargo release <VERSION> --exclude test-services --workspace