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§

Attribute Macros§