diff --git a/go/basics/part0/durableexecution.go b/go/basics/part0/durableexecution.go index fdecddfc..efa05f63 100644 --- a/go/basics/part0/durableexecution.go +++ b/go/basics/part0/durableexecution.go @@ -16,10 +16,17 @@ import ( // Applications consist of services with handlers that can be called over HTTP or Kafka. // Handlers can be called at http://restate:8080/ServiceName/handlerName // -// Restate persists and proxies HTTP requests to handlers and manages their execution. -// The SDK lets you implement handlers with regular code and control flow, no custom DSLs. +// Restate persists and proxies HTTP requests to handlers and manages their execution: +// +// ┌────────┐ ┌─────────┐ ┌────────────────────────────┐ +// │ HTTP │ → │ Restate │ → │ Restate Service (with SDK) │ +// │ Client │ ← │ │ ← │ handler1(), handler2() │ +// └────────┘ └─────────┘ └────────────────────────────┘ +// +// The SDK lets you implement handlers with regular code and control flow. +// Handlers have access to a Context that provides durable building blocks that get persisted in Restate. // Whenever a handler uses the Restate Context, an event gets persisted in Restate's log. -// After a failure, this log gets replayed to recover the state of the handler. +// After a failure, a retry is triggered and this log gets replayed to recover the state of the handler. type SubscriptionRequest struct { UserID string `json:"userId"` diff --git a/java/basics/src/main/java/durable_execution/SubscriptionService.java b/java/basics/src/main/java/durable_execution/SubscriptionService.java index f77fe7eb..094bf9a1 100644 --- a/java/basics/src/main/java/durable_execution/SubscriptionService.java +++ b/java/basics/src/main/java/durable_execution/SubscriptionService.java @@ -14,14 +14,20 @@ // - Tracking progress of execution and preventing re-execution of completed work on retries // - Providing durable building blocks like timers, promises, and messaging: recoverable and revivable anywhere // -// Applications consist of services (annotated with `@Service`) with handlers (annotated with `@Handler`) -// that can be called over HTTP or Kafka. +// Applications consist of services with handlers that can be called over HTTP or Kafka. // Handlers can be called at http://restate:8080/ServiceName/handlerName // -// Restate persists and proxies HTTP requests to handlers and manages their execution. -// The SDK lets you implement handlers with regular code and control flow, no custom DSLs. +// Restate persists and proxies HTTP requests to handlers and manages their execution: +// +// ┌────────┐ ┌─────────┐ ┌────────────────────────────┐ +// │ HTTP │ → │ Restate │ → │ Restate Service (with SDK) │ +// │ Client │ ← │ │ ← │ handler1(), handler2() │ +// └────────┘ └─────────┘ └────────────────────────────┘ +// +// The SDK lets you implement handlers with regular code and control flow. +// Handlers have access to a Context that provides durable building blocks that get persisted in Restate. // Whenever a handler uses the Restate Context, an event gets persisted in Restate's log. -// After a failure, this log gets replayed to recover the state of the handler. +// After a failure, a retry is triggered and this log gets replayed to recover the state of the handler. @Service public class SubscriptionService { diff --git a/kotlin/basics/src/main/kotlin/durable_execution/SubscriptionService.kt b/kotlin/basics/src/main/kotlin/durable_execution/SubscriptionService.kt index 8fdecc2b..aa395783 100644 --- a/kotlin/basics/src/main/kotlin/durable_execution/SubscriptionService.kt +++ b/kotlin/basics/src/main/kotlin/durable_execution/SubscriptionService.kt @@ -14,14 +14,20 @@ import utils.createSubscription // - Tracking progress of execution and preventing re-execution of completed work on retries // - Providing durable building blocks like timers, promises, and messaging: recoverable and revivable anywhere // -// Applications consist of services (annotated with `@Service`) with handlers (annotated with `@Handler`) -// that can be called over HTTP or Kafka. +// Applications consist of services with handlers that can be called over HTTP or Kafka. // Handlers can be called at http://restate:8080/ServiceName/handlerName // -// Restate persists and proxies HTTP requests to handlers and manages their execution. -// The SDK lets you implement handlers with regular code and control flow, no custom DSLs. +// Restate persists and proxies HTTP requests to handlers and manages their execution: +// +// ┌────────┐ ┌─────────┐ ┌────────────────────────────┐ +// │ HTTP │ → │ Restate │ → │ Restate Service (with SDK) │ +// │ Client │ ← │ │ ← │ handler1(), handler2() │ +// └────────┘ └─────────┘ └────────────────────────────┘ +// +// The SDK lets you implement handlers with regular code and control flow. +// Handlers have access to a Context that provides durable building blocks that get persisted in Restate. // Whenever a handler uses the Restate Context, an event gets persisted in Restate's log. -// After a failure, this log gets replayed to recover the state of the handler. +// After a failure, a retry is triggered and this log gets replayed to recover the state of the handler. @Service class SubscriptionService { diff --git a/python/basics/app/0_durable_execution.py b/python/basics/app/0_durable_execution.py index 6d21b674..8f685658 100644 --- a/python/basics/app/0_durable_execution.py +++ b/python/basics/app/0_durable_execution.py @@ -21,10 +21,17 @@ class SubscriptionRequest(BaseModel): Applications consist of services with handlers that can be called over HTTP or Kafka. Handlers can be called at http://restate:8080/ServiceName/handlerName - Restate persists and proxies HTTP requests to handlers and manages their execution. - The SDK lets you implement handlers with regular code and control flow, no custom DSLs. + Restate persists and proxies HTTP requests to handlers and manages their execution: + + ┌────────┐ ┌─────────┐ ┌────────────────────────────┐ + │ HTTP │ → │ Restate │ → │ Restate Service (with SDK) │ + │ Client │ ← │ │ ← │ handler1(), handler2() │ + └────────┘ └─────────┘ └────────────────────────────┘ + + The SDK lets you implement handlers with regular code and control flow. + Handlers have access to a Context that provides durable building blocks that get persisted in Restate. Whenever a handler uses the Restate Context, an event gets persisted in Restate's log. - After a failure, this log gets replayed to recover the state of the handler. + After a failure, a retry is triggered and this log gets replayed to recover the state of the handler. """ subscription_service = Service("SubscriptionService") diff --git a/rust/basics/Cargo.lock b/rust/basics/Cargo.lock index 15a5b270..bdb0365b 100644 --- a/rust/basics/Cargo.lock +++ b/rust/basics/Cargo.lock @@ -829,11 +829,11 @@ name = "restate-example" version = "0.0.1" dependencies = [ "anyhow", - "log", "rand", "restate-sdk", "serde", "tokio", + "tracing", "tracing-subscriber", ] @@ -1276,9 +1276,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "pin-project-lite", "tracing-attributes", @@ -1287,9 +1287,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", @@ -1298,9 +1298,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", "valuable", diff --git a/rust/basics/Cargo.toml b/rust/basics/Cargo.toml index 91b7195b..e52cd304 100644 --- a/rust/basics/Cargo.toml +++ b/rust/basics/Cargo.toml @@ -10,7 +10,7 @@ tracing-subscriber = "0.3" rand = "0.8.5" anyhow = "1.0.86" serde = { version = "1.0.208", features = ["derive"] } -log = "0.4.22" +tracing = "0.1.41" [[example]] name = "example-0" diff --git a/rust/basics/src/p0_durable_execution.rs b/rust/basics/src/p0_durable_execution.rs index 586a8646..1b6be236 100644 --- a/rust/basics/src/p0_durable_execution.rs +++ b/rust/basics/src/p0_durable_execution.rs @@ -6,10 +6,10 @@ use serde::Deserialize; #[derive(Deserialize)] #[serde(rename_all = "camelCase")] -pub(crate) struct SubscriptionRequest { - pub(crate) user_id: String, - pub(crate) credit_card: String, - pub(crate) subscriptions: Vec, +pub struct SubscriptionRequest { + pub user_id: String, + pub credit_card: String, + pub subscriptions: Vec, } // Restate helps you implement resilient applications: diff --git a/rust/basics/src/stubs.rs b/rust/basics/src/stubs.rs index a3a2c64c..d4604894 100644 --- a/rust/basics/src/stubs.rs +++ b/rust/basics/src/stubs.rs @@ -1,6 +1,6 @@ #![allow(unused)] use anyhow::{anyhow, Result}; -use log::{error, info}; +use tracing::{error, info}; use rand::random; use restate_sdk::context::ObjectContext; use restate_sdk::errors::HandlerError; diff --git a/typescript/basics/src/0_durable_execution.ts b/typescript/basics/src/0_durable_execution.ts index c4ccb9a1..a564becb 100644 --- a/typescript/basics/src/0_durable_execution.ts +++ b/typescript/basics/src/0_durable_execution.ts @@ -14,10 +14,17 @@ import { // Applications consist of services with handlers that can be called over HTTP or Kafka. // Handlers can be called at http://restate:8080/ServiceName/handlerName // -// Restate persists and proxies HTTP requests to handlers and manages their execution. -// The SDK lets you implement handlers with regular code and control flow, no custom DSLs. +// Restate persists and proxies HTTP requests to handlers and manages their execution: +// +// ┌────────┐ ┌─────────┐ ┌────────────────────────────┐ +// │ HTTP │ → │ Restate │ → │ Restate Service (with SDK) │ +// │ Client │ ← │ │ ← │ handler1(), handler2() │ +// └────────┘ └─────────┘ └────────────────────────────┘ +// +// The SDK lets you implement handlers with regular code and control flow. +// Handlers have access to a Context that provides durable building blocks that get persisted in Restate. // Whenever a handler uses the Restate Context, an event gets persisted in Restate's log. -// After a failure, this log gets replayed to recover the state of the handler. +// After a failure, a retry is triggered and this log gets replayed to recover the state of the handler. const subscriptionService = restate.service({ name: "SubscriptionService",