From 70e824defada710dc6f54b0e8bda2f0aedeb0a29 Mon Sep 17 00:00:00 2001 From: slinkydeveloper Date: Wed, 4 Nov 2026 16:34:57 +0100 Subject: [PATCH 1/2] Few touchups --- Cargo.lock | 3 ++- Cargo.toml | 6 +----- README.md | 63 ++++++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 57 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ad3c847c..815c9f5e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1552,7 +1552,8 @@ dependencies = [ [[package]] name = "restate-sdk-shared-core" version = "8.3.0" -source = "git+https://github.com/restatedev/sdk-shared-core?branch=cloud-exp-revamp#7fbd30d6b219a3540de7f9cfa68f9c643904dca0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7aab6c6bb01010b5dca515fc6547b636954647427ea8ecec3790feffbce7291" dependencies = [ "base64", "bs58", diff --git a/Cargo.toml b/Cargo.toml index 2f65d562..2a89c1bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ pyo3 = { version = "0.30.1", features = ["extension-module"] } pyo3-async-runtimes = { version = "0.30", features = ["tokio-runtime"] } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["fmt", "env-filter"] } -restate-sdk-shared-core = { version = "8.2.0", features = ["request_identity", "sha2_random_seed", "rust_crypto", "tunnel"] } +restate-sdk-shared-core = { version = "8.3.0", features = ["request_identity", "sha2_random_seed", "rust_crypto", "tunnel"] } # ASGI bridge for the tunnel bytes = "1.10" @@ -28,7 +28,3 @@ percent-encoding = "2.3" tokio = { version = "1.49", default-features = false, features = ["sync", "rt-multi-thread"] } tokio-stream = { version = "0.1", default-features = false } tokio-util = { version = "0.7", default-features = false } - -# Until restate-sdk-shared-core with the `cloud` and `tunnel` features is released. -[patch.crates-io] -restate-sdk-shared-core = { git = "https://github.com/restatedev/sdk-shared-core", branch = "cloud-exp-revamp" } diff --git a/README.md b/README.md index 8ae73092..1eb216bf 100644 --- a/README.md +++ b/README.md @@ -26,33 +26,78 @@ To use this SDK, add the dependency to your project: pip install restate_sdk ``` +## Serving using an ASGI server + +Given an `app.py`: + +```python +import restate + +greeter = restate.Service("greeter") + +@greeter.handler() +async def greet(ctx: restate.Context, name: str) -> str: + return f"Hello {name}!" + +app = restate.app(services=[greeter]) +``` + +`restate.app(...)` returns an ASGI application, so it can be served by any ASGI server. + +With [Hypercorn](https://github.com/pgjones/hypercorn): + +```shell +pip install hypercorn +python -m hypercorn app:app --bind "0.0.0.0:9080" +``` + +Or start it from code: + +```python +if __name__ == "__main__": + import asyncio + import hypercorn + import hypercorn.asyncio + + conf = hypercorn.Config() + conf.bind = ["0.0.0.0:9080"] + asyncio.run(hypercorn.asyncio.serve(app, conf)) +``` + +Once served, register the deployment with `restate deployments register http://localhost:9080`. + ## Connecting to Restate Cloud An application can connect outbound to Restate Cloud instead of exposing a port. Copy a connect key -from the Cloud UI (Development → Configure SDK), pick a name for the deployment, and run: +from the [Cloud UI -> Development → Configure SDK](https://cloud.restate.dev/to/developers/integration#configure-sdk), pick a name for the deployment, and run: ```shell -RESTATE_CONNECT_KEY=rstcloudv1_... python -m restate connect app:app --name greeter +RESTATE_CONNECT_KEY=rstcloudv1_... python -m restate connect app:app --name greeter-v1 ``` -where `app:app` is the module and attribute holding the application returned by `restate.app(...)`. -Then register the deployment as `connect://greeter`. The same from code, running until stopped: +Then register the deployment as `connect://greeter-v1`. + +The same from code: ```python if __name__ == "__main__": - asyncio.run(restate.connect(app, name="greeter")) + import asyncio + + asyncio.run(restate.connect(app, name="greeter-v1")) ``` -To do something while connected, use the context manager: +Or using the context manager, for finer control: ```python -async with restate.with_connection(app, name="greeter") as connection: +async with restate.with_connection(app, name="greeter-v1") as connection: print(connection.info.deployment_url) await connection.wait() ``` -Clients can read an ingress key the same way: `restate.create_client()` without an URL uses -`RESTATE_INGRESS_KEY` (Development → Configure Client). +### Clients + +`restate.create_client()` without a URL connects to Restate Cloud using the ingress key in +[Cloud UI -> Development → Configure SDK](https://cloud.restate.dev/to/developers/integration#configure-sdk). ## Versions From e2a32891b34b7591f7283de8f152fca7dd39966b Mon Sep 17 00:00:00 2001 From: Francesco Guardiani Date: Wed, 4 Nov 2026 16:48:17 +0100 Subject: [PATCH 2/2] Update README.md Co-authored-by: pullfrog[bot] <226033991+pullfrog[bot]@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1eb216bf..bd166bfe 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ async with restate.with_connection(app, name="greeter-v1") as connection: ### Clients -`restate.create_client()` without a URL connects to Restate Cloud using the ingress key in +`restate.create_client()` without a URL connects to Restate Cloud using the ingress key in `RESTATE_INGRESS_KEY`, copied from the [Cloud UI -> Development → Configure SDK](https://cloud.restate.dev/to/developers/integration#configure-sdk). ## Versions