Skip to content

Commit

Permalink
Address feedback and add mermaid diagram to other SDK basics
Browse files Browse the repository at this point in the history
  • Loading branch information
gvdongen committed Jan 15, 2025
1 parent b1af6d1 commit f162a36
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 32 deletions.
13 changes: 10 additions & 3 deletions go/basics/part0/durableexecution.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 10 additions & 3 deletions python/basics/app/0_durable_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
14 changes: 7 additions & 7 deletions rust/basics/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/basics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions rust/basics/src/p0_durable_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
pub struct SubscriptionRequest {
pub user_id: String,
pub credit_card: String,
pub subscriptions: Vec<String>,
}

// Restate helps you implement resilient applications:
Expand Down
2 changes: 1 addition & 1 deletion rust/basics/src/stubs.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
13 changes: 10 additions & 3 deletions typescript/basics/src/0_durable_execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit f162a36

Please sign in to comment.