### Get and Run Go Example Source: https://github.com/restatedev/docs-restate/blob/main/docs/tour/microservice-orchestration.mdx Retrieves the Go orchestration example and starts it. Ensure Restate is installed and running. ```bash restate example go-tour-of-orchestration && cd go-tour-of-orchestration ``` ```bash go run . ``` -------------------------------- ### Get and Run Python Example Source: https://github.com/restatedev/docs-restate/blob/main/docs/tour/microservice-orchestration.mdx Retrieves the Python orchestration example and starts the development server using `uv`. Ensure Restate is installed and running. ```bash restate example python-tour-of-orchestration && cd python-tour-of-orchestration ``` ```bash uv run . ``` -------------------------------- ### Get and Run Java Example Source: https://github.com/restatedev/docs-restate/blob/main/docs/tour/microservice-orchestration.mdx Retrieves the Java orchestration example and starts it using Gradle. Ensure Restate is installed and running. ```bash restate example java-tour-of-orchestration && cd java-tour-of-orchestration ``` ```bash ./gradlew run ``` -------------------------------- ### Get and Run TypeScript Example Source: https://github.com/restatedev/docs-restate/blob/main/docs/tour/microservice-orchestration.mdx Retrieves the TypeScript orchestration example, installs dependencies, and starts the development server. Ensure Restate is installed and running. ```bash restate example typescript-tour-of-orchestration && cd typescript-tour-of-orchestration npm install ``` ```bash npm run dev ``` -------------------------------- ### Get and Run TypeScript Tour of Workflows Example Source: https://github.com/restatedev/docs-restate/blob/main/docs/tour/workflows.mdx Download the TypeScript example, install its dependencies, and run it. Then, register the deployment with Restate. ```bash restate example typescript-tour-of-workflows && cd typescript-tour-of-workflows npm install npm run dev restate deployments register http://localhost:9080 ``` -------------------------------- ### Install Restate Example (Maven + Spring Boot) Source: https://github.com/restatedev/docs-restate/blob/main/docs/quickstart.mdx Installs the Java Greeter service example using the Restate CLI. This command downloads and sets up the project. ```shell restate example java-hello-world-maven-spring-boot && cd java-hello-world-maven-spring-boot ``` -------------------------------- ### Get and Install Restate Example Project Source: https://github.com/restatedev/docs-restate/blob/main/docs/snippets/tour/ai/setup-vercel.mdx Download and set up a specific Restate example project, such as the TypeScript Vercel AI Tour of Agents. Navigate into the project directory and install its dependencies. ```bash restate example typescript-vercel-ai-tour-of-agents && cd typescript-vercel-ai-tour-of-agents npm install ``` -------------------------------- ### Start the Service Source: https://github.com/restatedev/docs-restate/blob/main/docs/guides/parallelizing-work.mdx Commands to install dependencies and start the example service. The specific command depends on the programming language used for the project. ```shell npm install npx tsx watch ./src/parallelizework/fan_out_worker.ts ``` ```shell ./gradlew -PmainClass=my.example.parallelizework.FanOutWorker run ``` ```shell ./gradlew -PmainClass=my.example.parallelizework.FanOutWorkerKt run ``` ```shell uv run parallelizework/app.py ``` ```shell go run ./src/parallelizework ``` -------------------------------- ### Get and Run Go Tour of Workflows Example Source: https://github.com/restatedev/docs-restate/blob/main/docs/tour/workflows.mdx Download the Go example and run it. Then, register the deployment with Restate. ```bash restate example go-tour-of-workflows && cd go-tour-of-workflows go run . restate deployments register http://localhost:9080 ``` -------------------------------- ### Get and Run Java Tour of Workflows Example Source: https://github.com/restatedev/docs-restate/blob/main/docs/tour/workflows.mdx Download the Java example and run it using Gradle. Then, register the deployment with Restate. ```bash restate example java-tour-of-workflows && cd java-tour-of-workflows ./gradlew run restate deployments register http://localhost:9080 ``` -------------------------------- ### Get and Install Restate TypeScript Example Source: https://github.com/restatedev/docs-restate/blob/main/docs/snippets/common/setup-restate-ts.mdx Fetches the TypeScript Restate tour of agents example and installs its dependencies. Navigate into the project directory after cloning. ```bash restate example typescript-restate-tour-of-agents && cd typescript-restate-tour-of-agents npm install ``` -------------------------------- ### Get and Run Python Tour of Workflows Example Source: https://github.com/restatedev/docs-restate/blob/main/docs/tour/workflows.mdx Download the Python example and run it using uvicorn. Then, register the deployment with Restate. ```bash restate example python-tour-of-workflows && cd python-tour-of-workflows uv run . restate deployments register http://localhost:9080 ``` -------------------------------- ### Get Restate Example Project (wget) Source: https://github.com/restatedev/docs-restate/blob/main/docs/quickstart.mdx Download the Rust hello-world shuttle example project using wget. ```shell wget https://github.com/restatedev/examples/releases/latest/download/rust-hello-world-shuttle.zip && unzip rust-hello-world-shuttle.zip -d rust-hello-world-shuttle && rm rust-hello-world-shuttle.zip && cd rust-hello-world-shuttle ``` -------------------------------- ### Get Python Restate Example Source: https://github.com/restatedev/docs-restate/blob/main/docs/snippets/common/setup-restate-py.mdx Download and navigate to the Python Restate tour of agents example project. This requires Restate to be installed. ```bash restate example python-restate-tour-of-agents && cd python-restate-tour-of-agents ``` -------------------------------- ### Get Python Langchain Tour Example Source: https://github.com/restatedev/docs-restate/blob/main/docs/snippets/tour/ai/setup-langchain.mdx Download and navigate to the Python Langchain tour example directory. ```bash restate example python-langchain-tour-of-agents && cd python-langchain-tour-of-agents ``` -------------------------------- ### Install Restate Server via Homebrew Source: https://github.com/restatedev/docs-restate/blob/main/restate-plugin/skills/building-restate-services/references/go/api-and-pitfalls.md Install the Restate server using Homebrew and start it. ```shell brew install restatedev/tap/restate-server restate-server ``` -------------------------------- ### Get Restate Example Project (CLI) Source: https://github.com/restatedev/docs-restate/blob/main/docs/quickstart.mdx Use the Restate CLI to download the Rust hello-world shuttle example project. ```shell restate example rust-hello-world-shuttle && cd rust-hello-world-shuttle ``` -------------------------------- ### Download Restate Example (Maven + Spring Boot) Source: https://github.com/restatedev/docs-restate/blob/main/docs/quickstart.mdx Downloads the Java Greeter service example as a zip archive. This is an alternative to using the Restate CLI for setup. ```shell wget https://github.com/restatedev/examples/releases/latest/download/java-hello-world-maven-spring-boot.zip && unzip java-hello-world-maven-spring-boot.zip -d java-hello-world-maven-spring-boot && rm java-hello-world-maven-spring-boot.zip && cd java-hello-world-maven-spring-boot ``` -------------------------------- ### Install Restate Go SDK Source: https://github.com/restatedev/docs-restate/blob/main/restate-plugin/skills/building-restate-services/references/go/api-and-pitfalls.md Install the Restate SDK for Go using the go get command. ```shell go get github.com/restatedev/sdk-go ``` -------------------------------- ### Run Example: Register Services and Send Request Source: https://github.com/restatedev/docs-restate/blob/main/docs/ai/patterns/remote-agents.mdx This section provides instructions on how to run the remote agents example. It includes commands to start the Restate server, register the services, and send a sample request. ```bash uv run app/remote_agents.py ``` ```bash restate deployments register http://localhost:9080 --force --yes # dev only: overrides previous registrations ``` ```bash curl localhost:8080/RemoteAgentRouter/answer \ --json '{"message": "I was charged twice for my subscription last month"}' ``` -------------------------------- ### Clone and Install AI Examples Source: https://github.com/restatedev/docs-restate/blob/main/docs/snippets/ai-guides/start-example.mdx Clone the AI examples repository and install dependencies for either TypeScript or Python projects. ```shell git clone https://github.com/restatedev/ai-examples.git && cd typescript-patterns && npm install ``` ```shell git clone https://github.com/restatedev/ai-examples.git && cd python-patterns ``` -------------------------------- ### Install Restate Server & CLI (Deno) Source: https://github.com/restatedev/docs-restate/blob/main/docs/quickstart.mdx Installs the Restate server and CLI tools for Deno projects. This is the initial setup step. ```shell restate example typescript-hello-world-deno && cd typescript-hello-world-deno ``` -------------------------------- ### Install Restate via Homebrew Source: https://github.com/restatedev/docs-restate/blob/main/docs/snippets/common/install-server.mdx Use Homebrew to install the Restate server and CLI. After installation, start the server using the 'restate-server' command. ```shell brew install restatedev/tap/restate-server restatedev/tap/restate ``` ```shell restate-server ``` ```shell restate --help ``` -------------------------------- ### Install Restate via npm Source: https://github.com/restatedev/docs-restate/blob/main/docs/snippets/common/install-server.mdx Install the Restate server and CLI globally using npm. After installation, start the server using 'restate-server' and find the CLI with 'restate --help'. ```shell npm install --global @restatedev/restate-server@latest @restatedev/restate@latest ``` ```shell restate-server ``` ```shell restate --help ``` -------------------------------- ### Complete Workflow Example in Java Source: https://github.com/restatedev/docs-restate/blob/main/docs/develop/java/external-events.mdx A full workflow example in Java demonstrating document review. It includes sending for review, waiting for external submission, and processing the result. Requires DurablePromiseKey setup. ```java @Workflow public class ReviewWorkflow { private static final DurablePromiseKey REVIEW_PROMISE = DurablePromiseKey.of("review", String.class); @Workflow public String run(WorkflowContext ctx, String documentId) { // Send document for review ctx.run(() -> askReview(documentId)); // Wait for external review submission String review = ctx.promise(REVIEW_PROMISE).future().await(); // Process the review result return processReview(documentId, review); } @Shared public void submitReview(SharedWorkflowContext ctx, String review) { // Signal the waiting run handler ctx.promiseHandle(REVIEW_PROMISE).resolve(review); } } ``` -------------------------------- ### Complete Workflow Example in Kotlin Source: https://github.com/restatedev/docs-restate/blob/main/docs/develop/java/external-events.mdx A full workflow example in Kotlin demonstrating document review. It includes sending for review, waiting for external submission, and processing the result. Requires durablePromiseKey setup. ```kotlin @Workflow class ReviewWorkflow { companion object { val REVIEW_PROMISE = durablePromiseKey("review") } @Workflow suspend fun run(ctx: WorkflowContext, documentId: String): String { // Send document for review ctx.runBlock { askReview(documentId) } // Wait for external review submission val review: String = ctx.promise(REVIEW_PROMISE).future().await() // Process the review result return processReview(documentId, review) } @Shared suspend fun submitReview(ctx: SharedWorkflowContext, review: String) { // Signal the waiting run handler ctx.promiseHandle(REVIEW_PROMISE).resolve(review) } } ``` -------------------------------- ### Run Python Example Source: https://github.com/restatedev/docs-restate/blob/main/docs/ai/patterns/workflow-evaluator.mdx Instructions to run the Python workflow evaluator example. This includes starting the Restate server, registering the service, and sending a request via curl. ```bash uv run app/workflow_evaluator_optimizer.py ``` ```bash restate deployments register http://localhost:9080 --force --yes # dev only: overrides previous registrations ``` ```bash curl localhost:8080/CodeGenerator/generate \ --json '{"task": "Write a function that checks if a string is a palindrome"}' ``` -------------------------------- ### Get Restate Example Code Source: https://github.com/restatedev/docs-restate/blob/main/docs/snippets/tour/ai/setup-google-adk.mdx Download and navigate to a specific Restate example project. This is useful for exploring Restate's capabilities with pre-built code. ```bash restate example python-google-adk-tour-of-agents && cd python-google-adk-tour-of-agents ``` -------------------------------- ### Run Sequential Workflow Example (Python) Source: https://github.com/restatedev/docs-restate/blob/main/docs/ai/patterns/workflow-sequential.mdx Execute the sequential workflow Python example. This command starts the Restate service and prepares it to handle incoming requests for claim reimbursements. ```bash uv run app/workflow_sequential.py ``` ```bash restate deployments register http://localhost:9080 --force --yes # dev only: overrides previous registrations ``` ```bash curl localhost:8080/ClaimReimbursement/process --json '{ "message": "Process my hospital bill of 2024-10-01 for 3000USD for a broken leg at General Hospital." }' ``` -------------------------------- ### Parallel Claim Analysis Setup (Bash) Source: https://github.com/restatedev/docs-restate/blob/main/docs/ai/patterns/workflow-parallel.mdx These bash commands are used to set up and run the parallel claim analysis example. First, run the Python application using `uv`. Then, register the Restate deployment. Finally, send a POST request with claim details to the running service. ```bash uv run app/workflow_parallel.py ``` ```bash restate deployments register http://localhost:9080 --force --yes # dev only: overrides previous registrations ``` ```bash curl localhost:8080/ParallelAgentClaimApproval/run --json '{ "date":"2024-10-01", "category":"orthopedic", "reason":"hospital bill for a broken leg", "amount":3000, "placeOfService":"General Hospital" }' ``` -------------------------------- ### Get Python OpenAI Agents Example Source: https://github.com/restatedev/docs-restate/blob/main/docs/snippets/tour/ai/setup-openai.mdx Download and navigate to the Python OpenAI agents example project. This is useful for exploring Restate's capabilities with AI agents. ```bash restate example python-openai-agents-tour-of-agents && cd python-openai-agents-tour-of-agents ``` -------------------------------- ### Install Restate Server & CLI Source: https://github.com/restatedev/docs-restate/blob/main/docs/ai-quickstart.mdx This command installs the Restate server and command-line interface. Ensure you have Python and uv installed. ```shell restate example python-langchain-template && cd python-langchain-template ``` -------------------------------- ### Download Example Project Source: https://github.com/restatedev/docs-restate/blob/main/docs/guides/cron.mdx Download and navigate to the example project for your chosen SDK. ```bash restate example typescript-patterns-use-cases && cd typescript-patterns-use-cases ``` ```bash restate example java-patterns-use-cases && cd java-patterns-use-cases ``` ```bash restate example go-patterns-use-cases && cd go-patterns-use-cases ``` -------------------------------- ### Download and Navigate to Restate Example Source: https://github.com/restatedev/docs-restate/blob/main/docs/snippets/tour/ai/setup-pydantic-ai.mdx Fetches a Python example project for AI agents and changes the current directory to it. ```bash restate example python-pydantic-ai-tour-of-agents && cd python-pydantic-ai-tour-of-agents ``` -------------------------------- ### Add Guide Metadata Example Source: https://github.com/restatedev/docs-restate/blob/main/docs/README.md Example of frontmatter for a new guide in MDX format. Ensure it includes a title, description, and a valid tag. ```mdx --- title: "Guide Title" description: "Short description of the guide." tags: ["recipe"] --- ``` -------------------------------- ### Add Guide Metadata Example Source: https://github.com/restatedev/docs-restate/blob/main/README.md Example of frontmatter for an MDX guide. Ensure it includes a title, description, and one of the allowed tags: 'recipe', 'development', 'deployment', or 'integration'. ```mdx --- title: "Guide Title" description: "Short description of the guide." tags: ["recipe"] --- ``` -------------------------------- ### Download Restate Example Project Source: https://github.com/restatedev/docs-restate/blob/main/docs/guides/parallelizing-work.mdx Use this command to download and navigate into the example project directory. Choose the command corresponding to your preferred language. ```shell restate example typescript-patterns-use-cases && cd typescript-patterns-use-cases ``` ```shell restate example java-patterns-use-cases && cd java-patterns-use-cases ``` ```shell restate example kotlin-patterns-use-cases && cd kotlin-patterns-use-cases ``` ```shell restate example python-patterns-use-cases && cd python-patterns-use-cases ``` ```shell restate example go-patterns-use-cases && cd go-patterns-use-cases ``` -------------------------------- ### Start Sagas Service Source: https://github.com/restatedev/docs-restate/blob/main/docs/guides/sagas.mdx Start the Sagas service for the specified language. Ensure dependencies are installed for TypeScript. ```bash npm install npx tsx watch ./src/sagas/booking_workflow.ts ``` ```bash ./gradlew -PmainClass=my.example.sagas.BookingWorkflow run ``` ```bash ./gradlew -PmainClass=my.example.sagas.BookingWorkflowKt run ``` ```bash uv run sagas/app.py ``` ```bash go run ./src/sagas ``` -------------------------------- ### Running the Google ADK Example Source: https://github.com/restatedev/docs-restate/blob/main/docs/ai/patterns/workflow-evaluator.mdx Instructions to run the Google ADK agent service example. This includes setting up the environment, running the service, and sending a request. ```bash uv run app/workflow_evaluator_optimizer.py ``` ```bash restate deployments register http://localhost:9080 --force --yes # dev only: overrides previous registrations ``` ```bash curl localhost:8080/CodeGenerator/user123/generate \ --json '{"task": "Write a function that checks if a string is a palindrome"}' ``` -------------------------------- ### Install Restate Service Template (wget) Source: https://github.com/restatedev/docs-restate/blob/main/docs/quickstart.mdx Download the Java Hello World Maven template using wget, unzip it, remove the zip file, and navigate into the project directory. ```shell wget https://github.com/restatedev/examples/releases/latest/download/java-hello-world-maven.zip && unzip java-hello-world-maven.zip -d java-hello-world-maven && rm java-hello-world-maven.zip && cd java-hello-world-maven ``` -------------------------------- ### Download Sagas Example Project Source: https://github.com/restatedev/docs-restate/blob/main/docs/guides/sagas.mdx Download and navigate to the example project for the specified language. ```bash restate example typescript-patterns-use-cases && cd typescript-patterns-use-cases ``` ```bash restate example java-patterns-use-cases && cd java-patterns-use-cases ``` ```bash restate example kotlin-patterns-use-cases && cd kotlin-patterns-use-cases ``` ```bash restate example python-patterns-use-cases && cd python-patterns-use-cases ``` ```bash restate example go-patterns-use-cases && cd go-patterns-use-cases ``` -------------------------------- ### Start Local Documentation Preview Source: https://github.com/restatedev/docs-restate/blob/main/README.md Navigate to the docs directory and start the local development server for previewing documentation changes. View the preview at http://localhost:3000. ```shell cd docs mint dev ``` -------------------------------- ### Run the Greeter service (Python) Source: https://github.com/restatedev/docs-restate/blob/main/docs/quickstart.mdx Start the Restate Greeter service using uv. Ensure it listens on port 9080. ```shell uv run . ``` -------------------------------- ### Start Development Server Source: https://github.com/restatedev/docs-restate/blob/main/CLAUDE.md Runs the code loading watcher and Mintlify docs server concurrently. Use this to start your local development environment. ```bash npm run dev ``` -------------------------------- ### Run Sequential Workflow Example (TypeScript) Source: https://github.com/restatedev/docs-restate/blob/main/docs/ai/patterns/workflow-sequential.mdx Execute the sequential workflow TypeScript example. This command starts the Restate service and prepares it to handle incoming requests for claim reimbursements. ```bash npx tsx ./src/workflow-sequential.ts ``` ```bash restate deployments register http://localhost:9080 --force --yes # dev only: overrides previous registrations ``` ```bash curl localhost:8080/ClaimReimbursement/process --json '{ "message": "Process my hospital bill of 2024-10-01 for 3000USD for a broken leg at General Hospital." }' ``` -------------------------------- ### Get User Subscriptions (Default) Source: https://github.com/restatedev/docs-restate/blob/main/docs/tour/microservice-orchestration.mdx Retrieves all subscriptions for a given user. This is the default example shown. ```bash curl localhost:8080/UserSubscriptions/user-123/getSubscriptions ``` -------------------------------- ### Run TypeScript Example Source: https://github.com/restatedev/docs-restate/blob/main/docs/ai/patterns/workflow-evaluator.mdx Instructions to run the TypeScript workflow evaluator example. This involves installing dependencies, running the TypeScript file, registering the service with Restate, and sending a request using curl. ```bash npx tsx ./src/workflow-evaluator-optimizer.ts ``` ```bash restate deployments register http://localhost:9080 --force --yes # dev only: overrides previous registrations ``` ```bash curl localhost:8080/CodeGenerator/generate \ --json '{"task": "Write a function that checks if a string is a palindrome"}' ``` -------------------------------- ### Install Restate Service Template (Gradle wget) Source: https://github.com/restatedev/docs-restate/blob/main/docs/quickstart.mdx Download the Java Hello World Gradle template using wget, unzip it, remove the zip file, and navigate into the project directory. ```shell wget https://github.com/restatedev/examples/releases/latest/download/java-hello-world-gradle.zip && unzip java-hello-world-gradle.zip -d java-hello-world-gradle && rm java-hello-world-gradle.zip && cd java-hello-world-gradle ``` -------------------------------- ### Run the Greeter Service (Gradle) Source: https://github.com/restatedev/docs-restate/blob/main/docs/quickstart.mdx Execute the Gradle wrapper to run the Greeter service. Ensure the service is configured to listen on port 9080. ```shell ./gradlew run ``` -------------------------------- ### Start Service with API Key Source: https://github.com/restatedev/docs-restate/blob/main/docs/snippets/ai-guides/start-example.mdx Export your model provider's API key as an environment variable and start the agent. This example shows how to set the OpenAI API key for both TypeScript and Python. ```shell export OPENAI_API_KEY=your_openai_api_key npm run dev ``` ```shell export OPENAI_API_KEY=your_openai_api_key uv run . ``` -------------------------------- ### Get and Install TypeScript AI Agent Template (Shell) Source: https://github.com/restatedev/docs-restate/blob/main/docs/ai-quickstart.mdx Clones the TypeScript AI agent template and installs its dependencies. This sets up a project for building AI agents with the Restate TypeScript SDK. ```shell restate example typescript-restate-agent-template && cd typescript-restate-agent-template npm install ``` -------------------------------- ### Set up API Keys for Logfire and OpenAI Source: https://github.com/restatedev/docs-restate/blob/main/docs/ai/ecosystem-integrations/logfire.mdx Create a .env file to store your Logfire write token and OpenAI API key. These are required for the example to run. ```bash echo 'LOGFIRE_WRITE_TOKEN=your-logfire-token' > .env echo 'OPENAI_API_KEY=sk-proj-...' >> .env ``` -------------------------------- ### Run the Greeter Service (Kotlin/Gradle/Spring Boot) Source: https://github.com/restatedev/docs-restate/blob/main/docs/quickstart.mdx Configure your IDE to build with Gradle and run the Greeter service. Ensure it listens on port 9080. ```shell ./gradlew bootRun ``` -------------------------------- ### Go Signup Workflow Source: https://github.com/restatedev/docs-restate/blob/main/docs/tour/workflows.mdx Implement a signup workflow in Go using Restate. This example shows how to define a workflow with a 'Run' method that performs durable operations for user creation, activation, and sending a welcome email. ```go type SignupWorkflow struct{} func (SignupWorkflow) Run(ctx restate.WorkflowContext, user User) (bool, error) { userID := restate.Key(ctx) // workflow ID = user ID // Write to database success, err := restate.Run(ctx, func(ctx restate.RunContext) (bool, error) { return CreateUser(userID, user) }, restate.WithName("create")) if err != nil || !success { return false, err } // Call APIs _, err = restate.Run(ctx, func(ctx restate.RunContext) (restate.Void, error) { return ActivateUser(userID) }, restate.WithName("activate")) if err != nil { return false, err } _, err = restate.Run(ctx, func(ctx restate.RunContext) (restate.Void, error) { return SendWelcomeEmail(user) }, restate.WithName("welcome")) if err != nil { return false, err } return true, nil } ``` -------------------------------- ### Install Restate Service Template (CLI) Source: https://github.com/restatedev/docs-restate/blob/main/docs/quickstart.mdx Use the Restate CLI to download the Java Hello World Maven template and navigate into the project directory. ```shell restate example java-hello-world-maven && cd java-hello-world-maven ``` -------------------------------- ### Get User Subscriptions (Go) Source: https://github.com/restatedev/docs-restate/blob/main/docs/tour/microservice-orchestration.mdx Retrieves subscriptions for a specific user after they have been added. This example is shown under the Go tab. ```bash curl localhost:8080/UserSubscriptions/user-123/GetSubscriptions ``` -------------------------------- ### Get Greeter Service Template (Next.js/Vercel) Source: https://github.com/restatedev/docs-restate/blob/main/docs/quickstart.mdx Clone the TypeScript Greeter service template for Next.js/Vercel and install its dependencies. ```shell restate example typescript-hello-world-vercel && cd typescript-hello-world-vercel && npm install ``` -------------------------------- ### Running the Pydantic AI Example Source: https://github.com/restatedev/docs-restate/blob/main/docs/ai/patterns/workflow-evaluator.mdx Instructions to run the Pydantic AI agent service example. This includes setting up the environment, running the service, and sending a request. ```bash uv run app/workflow_evaluator_optimizer.py ``` ```bash restate deployments register http://localhost:9080 --force --yes # dev only: overrides previous registrations ``` ```bash curl localhost:8080/CodeGenerator/generate \ --json '{"task": "Write a function that checks if a string is a palindrome"}' ``` -------------------------------- ### Restate SDK Testing Setup Source: https://github.com/restatedev/docs-restate/blob/main/restate-plugin/src/references/python/api-and-pitfalls.md Set up tests for your Restate services using the Restate SDK's harness, which runs tests against a real Restate Server in Docker via Testcontainers. Install with `pip install restate-sdk[harness]`. ```python from restate.testing import TestClient async def test_my_service(): async with TestClient(my_service) as client: response = await client.my_handler(MyModel(field1="hello", field2=1)) assert response.field1 == "hello" assert response.field2 == 2 ``` -------------------------------- ### Install Restate Service Template (Gradle CLI) Source: https://github.com/restatedev/docs-restate/blob/main/docs/quickstart.mdx Use the Restate CLI to download the Java Hello World Gradle template and navigate into the project directory. ```shell restate example java-hello-world-gradle && cd java-hello-world-gradle ``` -------------------------------- ### Get Greeter Service Template (Cloudflare Workers) Source: https://github.com/restatedev/docs-restate/blob/main/docs/quickstart.mdx Clone the TypeScript Greeter service template for Cloudflare Workers and install its dependencies. ```shell restate example typescript-hello-world-cloudflare-worker && cd typescript-hello-world-cloudflare-worker && npm install ``` -------------------------------- ### Running the Remote Agents Application Source: https://github.com/restatedev/docs-restate/blob/main/docs/ai/patterns/remote-agents.mdx This bash command starts the Python application that hosts the remote agents. Ensure you have the necessary dependencies installed. ```bash uv run app/remote_agents.py ``` -------------------------------- ### Run Restate Server with npx Source: https://github.com/restatedev/docs-restate/blob/main/docs/get-restate.mdx Execute the Restate Server directly using npx. This is a quick way to start the server without a global installation. ```bash npx @restatedev/restate-server ``` -------------------------------- ### Run Greeter Service with Maven + Quarkus Source: https://github.com/restatedev/docs-restate/blob/main/docs/quickstart.mdx Starts the Greeter service using Maven and Quarkus. Ensure the service listens on port 9080. ```shell quarkus dev ``` -------------------------------- ### Run Insurance Claim Reimbursement (Bash) Source: https://github.com/restatedev/docs-restate/blob/main/docs/ai/patterns/workflow-sequential.mdx Commands to run the sequential workflow example. Includes starting the application, registering agents, and sending a sample request. ```bash uv run app/workflow_sequential.py ``` ```bash restate deployments register http://localhost:9080 --force --yes # dev only: overrides previous registrations ``` ```bash curl localhost:8080/ClaimReimbursement/process --json '{ "message": "Process my hospital bill of 2024-10-01 for 3000USD for a broken leg at General Hospital." }' ``` -------------------------------- ### Install Restate Server & CLI Source: https://github.com/restatedev/docs-restate/blob/main/docs/ai-quickstart.mdx Installs the Restate server and command-line interface using the uv package manager. ```shell restate example python-pydantic-ai-template && cd python-pydantic-ai-template ``` -------------------------------- ### Set up Restate Test Environment Source: https://github.com/restatedev/docs-restate/blob/main/restate-plugin/skills/building-restate-services/references/ts/api-and-pitfalls.md Configure and start a `RestateTestEnvironment` for integration testing. This uses Testcontainers to run a real Restate server in Docker. Ensure `@restatedev/restate-sdk-testcontainers` is installed. ```typescript import {RestateTestEnvironment, TestEnvironmentOptions} from "@restatedev/restate-sdk-testcontainers"; import * as clients from "@restatedev/restate-sdk-clients"; import { describe, it, beforeAll, afterAll, expect } from "vitest"; import { greeter } from "./greeter-service"; describe("MyService", () => { let restateTestEnvironment: RestateTestEnvironment; let restateIngress: clients.Ingress; beforeAll(async () => { restateTestEnvironment = await RestateTestEnvironment.start({ services: [greeter], alwaysReplay: true, } as TestEnvironmentOptions); restateIngress = clients.connect({ url: restateTestEnvironment.baseUrl() }); }, 20_000); afterAll(async () => { await restateTestEnvironment?.stop(); }); it("Can call methods", async () => { const client = restateIngress.objectClient(greeter, "myKey"); await client.greet("Test!"); }); it("Can read/write state", async () => { const state = restateTestEnvironment.stateOf(greeter, "myKey"); await state.set("count", 123); expect(await state.get("count")).toBe(123); }); }); ``` -------------------------------- ### Curl command to trigger workflow Source: https://github.com/restatedev/docs-restate/blob/main/docs/tour/workflows.mdx Example curl command to send a request to start the SignupWithTimersWorkflow. Replace 'johndoe' with the desired workflow key and provide user details. ```bash curl localhost:8080/SignupWithTimersWorkflow/johndoe/run/send \ --json '{"name": "John Doe", "email": "john@mail.com"}' ``` -------------------------------- ### Install Restate Server & CLI Source: https://github.com/restatedev/docs-restate/blob/main/docs/ai-quickstart.mdx Install the Restate server and CLI. This is a prerequisite for running the AI agent. ```shell restate example typescript-vercel-ai-template && cd typescript-vercel-ai-template npm install ``` -------------------------------- ### Get state value Source: https://github.com/restatedev/docs-restate/blob/main/docs/develop/java/state.mdx Read a state value by its key. Provides examples for String and Integer types. Use `orElse` for default values in Java. Nullable types are used in Kotlin. ```java // Getting String value StateKey STRING_STATE_KEY = StateKey.of("my-key", String.class); String stringState = ctx.get(STRING_STATE_KEY).orElse("my-default"); // Getting integer value StateKey INT_STATE_KEY = StateKey.of("my-key", Integer.class); int intState = ctx.get(INT_STATE_KEY).orElse(0); ``` ```kotlin // Getting String value val STRING_STATE_KEY = stateKey("my-key") val stringState: String? = ctx.get(STRING_STATE_KEY) // Getting integer value val INT_STATE_KEY = stateKey("my-key") val intState: Int? = ctx.get(INT_STATE_KEY) ``` -------------------------------- ### Download and Install Restate Binaries (Linux-x64) Source: https://github.com/restatedev/docs-restate/blob/main/docs/snippets/common/install-server-without-running-cli.mdx Download and install Restate server and CLI binaries for Linux x64. This script downloads, extracts, and places the binaries in $HOME/.local/bin. ```shell BIN=$HOME/.local/bin && RESTATE_PLATFORM=x86_64-unknown-linux-musl && \ curl -L --remote-name-all https://restate.gateway.scarf.sh/latest/restate-{server,cli}-$RESTATE_PLATFORM.tar.xz && \ tar -xvf restate-server-$RESTATE_PLATFORM.tar.xz --strip-components=1 restate-server-$RESTATE_PLATFORM/restate-server && \ tar -xvf restate-cli-$RESTATE_PLATFORM.tar.xz --strip-components=1 restate-cli-$RESTATE_PLATFORM/restate && \ chmod +x restate restate-server && \ mv restate $BIN && \ mv restate-server $BIN ```