Crate restate_sdk
source ·Expand description
§Restate Rust SDK
Restate is a system for easily building resilient applications using distributed durable async/await. This crate is the Restate SDK for writing Restate services using Rust.
// The prelude contains all the imports you need to get started
use restate_sdk::prelude::*;
// Define the service using Rust traits
#[restate_sdk::service]
trait Greeter {
async fn greet(name: String) -> HandlerResult<String>;
}
// Implement the service
struct GreeterImpl;
impl Greeter for GreeterImpl {
async fn greet(&self, _: Context<'_>, name: String) -> HandlerResult<String> {
Ok(format!("Greetings {name}"))
}
}
// Start the HTTP server to expose services
#[tokio::main]
async fn main() {
HttpServer::new(
Endpoint::builder()
.bind(GreeterImpl.serve())
.build(),
)
.listen_and_serve("0.0.0.0:9080".parse().unwrap())
.await;
}
For a general overview about Restate, check out the Restate documentation.
Modules§
- Types exposing Restate functionalities to service handlers.
- This module contains the generated data structures from the service protocol manifest schema.
- Error types to use within handlers.
- Battery-packed HTTP server to expose services.
- Hyper integration.
- Prelude contains all the useful imports you need to get started with Restate.
- Serialization/Deserialization traits and concrete implementations for handlers and state.
Attribute Macros§
- Entry-point macro to define a Restate Virtual object.
- Entry-point macro to define a Restate Service.
- Entry-point macro to define a Restate Workflow.