|
10 | 10 |
|
11 | 11 | ## Community
|
12 | 12 |
|
13 |
| -* 🤗️ [Join our online community](https://discord.gg/skW3AZ6uGd) for help, sharing feedback and talking to the community. |
14 |
| -* 📖 [Check out our documentation](https://docs.restate.dev) to get quickly started! |
15 |
| -* 📣 [Follow us on Twitter](https://twitter.com/restatedev) for staying up to date. |
16 |
| -* 🙋 [Create a GitHub issue](https://github.com/restatedev/sdk-java/issues) for requesting a new feature or reporting a problem. |
17 |
| -* 🏠 [Visit our GitHub org](https://github.com/restatedev) for exploring other repositories. |
| 13 | +- 🤗️ [Join our online community](https://discord.gg/skW3AZ6uGd) for help, sharing feedback and talking to the community. |
| 14 | +- 📖 [Check out our documentation](https://docs.restate.dev) to get quickly started! |
| 15 | +- 📣 [Follow us on Twitter](https://twitter.com/restatedev) for staying up to date. |
| 16 | +- 🙋 [Create a GitHub issue](https://github.com/restatedev/sdk-java/issues) for requesting a new feature or reporting a problem. |
| 17 | +- 🏠 [Visit our GitHub org](https://github.com/restatedev) for exploring other repositories. |
18 | 18 |
|
19 | 19 | ## Using the SDK
|
20 | 20 |
|
@@ -58,6 +58,74 @@ async fn main() {
|
58 | 58 | }
|
59 | 59 | ```
|
60 | 60 |
|
| 61 | +## Running on Lambda |
| 62 | + |
| 63 | +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. |
| 64 | + |
| 65 | +### Setup |
| 66 | + |
| 67 | +First, enable the `lambda` feature in your `Cargo.toml`: |
| 68 | + |
| 69 | +```toml |
| 70 | +[dependencies] |
| 71 | +restate-sdk = { version = "0.1", features = ["lambda"] } |
| 72 | +tokio = { version = "1", features = ["full"] } |
| 73 | +``` |
| 74 | + |
| 75 | +### Basic Lambda Service |
| 76 | + |
| 77 | +Here's how to create a simple Lambda service: |
| 78 | + |
| 79 | +```rust |
| 80 | +use restate_sdk::prelude::*; |
| 81 | + |
| 82 | +#[restate_sdk::service] |
| 83 | +trait Greeter { |
| 84 | + async fn greet(name: String) -> HandlerResult<String>; |
| 85 | +} |
| 86 | + |
| 87 | +struct GreeterImpl; |
| 88 | + |
| 89 | +impl Greeter for GreeterImpl { |
| 90 | + async fn greet(&self, _: Context<'_>, name: String) -> HandlerResult<String> { |
| 91 | + Ok(format!("Greetings {name}")) |
| 92 | + } |
| 93 | +} |
| 94 | + |
| 95 | +#[tokio::main] |
| 96 | +async fn main() { |
| 97 | + // To enable logging/tracing |
| 98 | + // tracing_subscriber::fmt::init(); |
| 99 | + |
| 100 | + // Build and run the Lambda endpoint |
| 101 | + Endpoint::builder() |
| 102 | + .bind(GreeterImpl.serve()) |
| 103 | + .build_lambda() |
| 104 | + .run() |
| 105 | + .await |
| 106 | + .unwrap(); |
| 107 | +} |
| 108 | +``` |
| 109 | + |
| 110 | +### Deployment |
| 111 | + |
| 112 | +1. Install `cargo-lambda` |
| 113 | + ``` |
| 114 | + cargo install cargo-lambda |
| 115 | + ``` |
| 116 | +2. Build your Lambda function: |
| 117 | + |
| 118 | + ```bash |
| 119 | + cargo lambda build --release --arm64 --output-format zip |
| 120 | + ``` |
| 121 | + |
| 122 | +3. Create a Lambda function with the following configuration: |
| 123 | + |
| 124 | + - **Runtime**: Amazon Linux 2023 |
| 125 | + - **Architecture**: arm64 |
| 126 | + |
| 127 | +4. Upload your `zip` file to the Lambda function. |
| 128 | + |
61 | 129 | ### Logging
|
62 | 130 |
|
63 | 131 | The SDK uses tokio's [`tracing`](https://docs.rs/tracing/latest/tracing/) crate to generate logs.
|
@@ -121,15 +189,15 @@ The Rust SDK is currently in active development, and might break across releases
|
121 | 189 |
|
122 | 190 | The compatibility with Restate is described in the following table:
|
123 | 191 |
|
124 |
| -| Restate Server\sdk-rust | 0.0 - 0.2 | 0.3 | 0.4 - 0.5 | 0.6 | |
125 |
| -|-------------------------|-----------|-----|-----------|------------------| |
126 |
| -| 1.0 | ✅ | ❌ | ❌ | ❌ | |
127 |
| -| 1.1 | ✅ | ✅ | ❌ | ❌ | |
128 |
| -| 1.2 | ✅ | ✅ | ❌ | ❌ | |
129 |
| -| 1.3 | ✅ | ✅ | ✅ | ✅ <sup>(1)</sup> | |
130 |
| -| 1.4 | ✅ | ✅ | ✅ | ✅ | |
| 192 | +| Restate Server\sdk-rust | 0.0 - 0.2 | 0.3 | 0.4 - 0.5 | 0.6 | |
| 193 | +| ----------------------- | --------- | --- | --------- | ----------------- | |
| 194 | +| 1.0 | ✅ | ❌ | ❌ | ❌ | |
| 195 | +| 1.1 | ✅ | ✅ | ❌ | ❌ | |
| 196 | +| 1.2 | ✅ | ✅ | ❌ | ❌ | |
| 197 | +| 1.3 | ✅ | ✅ | ✅ | ✅ <sup>(1)</sup> | |
| 198 | +| 1.4 | ✅ | ✅ | ✅ | ✅ | |
131 | 199 |
|
132 |
| -<sup>(1)</sup> **Note** `bind_with_options` works only from Restate 1.4 onward. |
| 200 | +<sup>(1)</sup> **Note** `bind_with_options` works only from Restate 1.4 onward. |
133 | 201 |
|
134 | 202 | ## Contributing
|
135 | 203 |
|
|
0 commit comments