diff --git a/docs/develop/rust/activities/basics.mdx b/docs/develop/rust/activities/basics.mdx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/develop/rust/activities/execution.mdx b/docs/develop/rust/activities/execution.mdx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/develop/rust/activities/index.mdx b/docs/develop/rust/activities/index.mdx new file mode 100644 index 0000000000..528a5d75b5 --- /dev/null +++ b/docs/develop/rust/activities/index.mdx @@ -0,0 +1,22 @@ +--- +id: index +title: Activities - TypeScript SDK +sidebar_label: Activities +description: + This section explains how to implement Activities with the Rust SDK +toc_max_heading_level: 4 +keywords: + - Rust +tags: + - Rust SDK + - Temporal SDKs +--- + +import * as Components from '@site/src/components'; + +![Rust SDK Banner](/img/assets/banner-rust-temporal.png) + +## Activities + +- [Activity basics](/develop/rust/activities/basics) +- [Activity execution](/develop/rust/activities/execution) \ No newline at end of file diff --git a/docs/develop/rust/client/index.mdx b/docs/develop/rust/client/index.mdx new file mode 100644 index 0000000000..998f7d0810 --- /dev/null +++ b/docs/develop/rust/client/index.mdx @@ -0,0 +1,21 @@ +--- +id: index +title: Client - Rust SDK +sidebar_label: Client +description: + This section explains how to implement the Client with the Rust SDK +toc_max_heading_level: 4 +keywords: + - Rust +tags: + - Rust SDK + - Temporal SDKs +--- + +import * as Components from '@site/src/components'; + +![Rust SDK Banner](/img/assets/banner-rust-temporal.png) + +## Temporal Client + +- [Temporal Client](/develop/rust/client/temporal-client) \ No newline at end of file diff --git a/docs/develop/rust/client/temporal-client.mdx b/docs/develop/rust/client/temporal-client.mdx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/develop/rust/index.mdx b/docs/develop/rust/index.mdx new file mode 100644 index 0000000000..18ce5ba238 --- /dev/null +++ b/docs/develop/rust/index.mdx @@ -0,0 +1,66 @@ +--- +id: index +title: Rust SDK developer guide +sidebar_label: Rust SDK +description: + This guide offers a thorough overview of structures, features, and best practices for developing with Temporal's Rust SDK, including Workflows, Client, Activities, and more. +toc_max_heading_level: 4 +keywords: + - Rust +tags: + - Rust SDK + - Temporal SDKs +--- + +import * as Components from '@site/src/components'; + +![Rust SDK Banner](/img/assets/banner-rust-temporal.png) + +## Install and get started + +You can find detailed installation instructions for the Rust SDK in the [Quickstart](/develop/rust/quickstart). + +There's also a short walkthrough of how to use the Temporal primitives (Activities, Workflows, and Workers) to build and run a Temporal application to get you up and running. + +Once your local Temporal Service is set up, continue building with the following resources: + +- [Develop a Workflow](/develop/rust/workflows/basics) +- [Develop an Activity](/develop/rust/activities/basics) +- [Start an Activity execution](/develop/rust/activities/execution) +- [Run Worker processes](/develop/rust/workers/run-worker-process) + +## [Workflows](/develop/rust/workflows) + +- [Workflow basics](/develop/rust/workflows/basics) +- [Child Workflows](/develop/rust/workflows/child-workflows) +- [Continue-As-New](/develop/rust/workflows/continue-as-new) +- [Message passing](/develop/rust/workflows/message-passing) +- [Cancellation](/develop/rust/workflows/cancellation) +- [Timers](/develop/rust/workflows/timers) + +## [Activities](/develop/rust/activities) + +- [Activity basics](/develop/rust/activities/basics) +- [Activity execution](/develop/rust/activities/execution) + +## [Workers](/develop/rust/workers) + +- [Worker processes](/develop/rust/workers/worker-process) + +## [Temporal Client](/develop/rust/client) + +- [Temporal Client](/develop/rust/client/temporal-client) + +## [Temporal Nexus](/develop/rust/nexus) + +- [Service handlers](/develop/rust/nexus/service-handler) + +## Temporal Rust Technical Resources + +- [Rust SDK Quickstart - Setup Guide](/develop/rust/quickstart) +- [Rust API Documentation](https://docs.rs/temporalio-sdk/0.2.0/temporalio_sdk/) +- [Rust SDK GitHub](https://github.com/temporalio/sdk-core/tree/master/crates/sdk) + +### Get Connected with the Temporal TypeScript Community + +- [Temporal Rust Community Slack](https://temporalio.slack.com/archives/C08G723SFNZ/p1773935454727179) \ No newline at end of file diff --git a/docs/develop/rust/nexus/index.mdx b/docs/develop/rust/nexus/index.mdx new file mode 100644 index 0000000000..3b2229f8fc --- /dev/null +++ b/docs/develop/rust/nexus/index.mdx @@ -0,0 +1,21 @@ +--- +id: index +title: Nexus - Rust SDK +sidebar_label: Nexus +description: + This section explains how to implement Temporal Nexus with the Rust SDK +toc_max_heading_level: 4 +keywords: + - Rust +tags: + - Rust SDK + - Temporal SDKs +--- + +import * as Components from '@site/src/components'; + +![Rust SDK Banner](/img/assets/banner-rust-temporal.png) + +## Temporal Nexus + +- [Service handlers](/develop/rust/nexus/service-handler) \ No newline at end of file diff --git a/docs/develop/rust/nexus/service-handler.mdx b/docs/develop/rust/nexus/service-handler.mdx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/develop/rust/quickstart.mdx b/docs/develop/rust/quickstart.mdx new file mode 100644 index 0000000000..31469c050b --- /dev/null +++ b/docs/develop/rust/quickstart.mdx @@ -0,0 +1,298 @@ +--- +id: quickstart +title: Set up your local development environment with the Rust SDK +sidebar_label: Quickstart +description: Configure your local development environment to get started developing with Temporal +keywords: + - set up + - getting started + - rust sdk +tags: + - Rust SDK + - setup + - getting started +hide_table_of_contents: true +--- + +import { SetupSteps, SetupStep, CodeSnippet } from '@site/src/components/elements/SetupSteps'; +import { CallToAction } from '@site/src/components/elements/CallToAction'; + +# Quickstart + +Configure your local development environment to get started developing with Temporal. + + + + + python3 -V + + + python 3.13.3 + + +}> +## Install Python + +Make sure you have Python installed. Check your version of Python with the following command. + + + + + +mkdir temporal-project + + +cd temporal-project + + +python3 -m venv env + + +source env/bin/activate + + +pip install temporalio + + +}> + +## Install the Temporal Python SDK + +You should install the Temporal Python SDK in your project using a virtual environment. Create a directory for your +Temporal project, switch to the new directory, create a Python virtual environment, activate it, and then install the +Temporal SDK. + +Next, you'll configure a local Temporal Service for development. + + + + + + + +

Install the Temporal CLI using Homebrew:

+ + brew install temporal + +
+ + +

Download the Temporal CLI archive for your architecture:

+ +

Extract it and add temporal.exe to your PATH.

+
+ + +

Download the Temporal CLI for your architecture:

+ +

Extract the archive and move the temporal binary into your PATH, for example:

+ + sudo mv temporal /usr/local/bin + +
+
+ + +}> + +## Install Temporal CLI + +The fastest way to get a development version of the Temporal Service running on your local machine is to use +[Temporal CLI](https://docs.temporal.io/cli). + +Choose your operating system to install Temporal CLI. + +
+ + + +

After installing, open a new Terminal window and start the development server:

+ +temporal server start-dev + +
+

Change the Web UI port

+

The Temporal Web UI may be on a different port in some examples or tutorials. To change the port for the Web UI, use the --ui-port option when starting the server:

+ +temporal server start-dev --ui-port 8080 + +

The Temporal Web UI will now be available at http://localhost:8080.

+
+ +}> + +## Start the development server + +Once you've installed Temporal CLI and added it to your PATH, open a new Terminal window and run the following command. + +This command starts a local Temporal Service. It starts the Web UI, creates the default Namespace, and uses an in-memory +database. + +The Temporal Service will be available on localhost:7233. The Temporal Web UI will be available at +http://localhost:8233. + +Leave the local Temporal Service running as you work through tutorials and other projects. You can stop the Temporal +Service at any time by pressing CTRL+C. + +Once you have everything installed, you're ready to build apps with Temporal on your local machine. + +
+
+ +## Run Hello World: Test Your Installation + +Now let's verify your setup is working by creating and running a complete Temporal application with both a Workflow and +Activity. + +This test will confirm that: + +- The Temporal Python SDK is properly installed +- Your local Temporal Service is running +- You can successfully create and execute Workflows and Activities +- The communication between components is functioning correctly + +### 1. Create the Activity + +Create an Activity file (activities.py): + +```python +from temporalio import activity + +@activity.defn +async def greet(name: str) -> str: + return f"Hello {name}" +``` + +An Activity is a normal function or method that executes a single, well-defined action (either short or long running), +which often involve interacting with the outside world, such as sending emails, making network requests, writing to a +database, or calling an API, which are prone to failure. If an Activity fails, Temporal automatically retries it based +on your configuration. + +### 2. Create the Workflow + +Create a Workflow file (workflows.py): + +```python +from datetime import timedelta +from temporalio import workflow + +with workflow.unsafe.imports_passed_through(): + from activities import greet + +@workflow.defn +class SayHelloWorkflow: + @workflow.run + async def run(self, name: str) -> str: + return await workflow.execute_activity( + greet, + name, + schedule_to_close_timeout=timedelta(seconds=10), + ) +``` + +Workflows orchestrate Activities and contain the application logic. Temporal Workflows are resilient. They can run and +keep running for years, even if the underlying infrastructure fails. If the application itself crashes, Temporal will +automatically recreate its pre-failure state so it can continue right where it left off. + +### 3. Create the Worker + +Create a Worker file (worker.py): + +```python +import asyncio +from temporalio.client import Client +from temporalio.worker import Worker +from temporalio import workflow + +with workflow.unsafe.imports_passed_through(): + from workflows import SayHelloWorkflow + from activities import greet + +async def main(): + client = await Client.connect("localhost:7233") + worker = Worker( + client, + task_queue="my-task-queue", + workflows=[SayHelloWorkflow], + activities=[greet], + ) + print("Worker started.") + await worker.run() + +if __name__ == "__main__": + asyncio.run(main()) +``` + +Run the Worker by opening up a new terminal: + +```bash +source env/bin/activate +python3 worker.py +``` + +Keep this terminal running - you should see "Worker started" displayed. + +With your Activity and Workflow defined, you need a Worker to execute them. A Worker polls a Task Queue, that you +configure it to poll, looking for work to do. Once the Worker dequeues the Workflow or Activity task from the Task +Queue, it then executes that task. + +Workers are a crucial part of your Temporal application as they're what actually execute the tasks defined in your +Workflows and Activities. For more information on Workers, see +[Understanding Temporal](/evaluate/understanding-temporal#workers) and a [deep dive into Workers](/workers). + +### 4. Execute the Workflow + +Now that your Worker is running, it's time to start a Workflow Execution. + +This final step will validate that everything is working correctly with your file labeled `starter.py`. + +Create a separate file called `starter.py`: + +```python +import asyncio +import uuid +from temporalio.client import Client + +async def main(): + client = await Client.connect("localhost:7233") + result = await client.execute_workflow( + "SayHelloWorkflow", + "Temporal", + id=f"say-hello-workflow-{uuid.uuid4()}", + task_queue="my-task-queue", + ) + print("Workflow result:", result) + +if __name__ == "__main__": + asyncio.run(main()) +``` + +While the Worker is still running, run the following command in a new terminal: + +```bash +source env/bin/activate +python3 starter.py +``` + +### Verify Success + +If everything is working correctly, you should see: + +- Worker processing the Workflow and Activity +- Output: `Workflow result: Hello Temporal` +- Workflow Execution details in the [Temporal Web UI](http://localhost:8233) + + +

Next: Run your first Temporal Application

+

Create a basic Workflow and run it with the Temporal Python SDK

+
diff --git a/docs/develop/rust/workers/index.mdx b/docs/develop/rust/workers/index.mdx new file mode 100644 index 0000000000..f21497d42f --- /dev/null +++ b/docs/develop/rust/workers/index.mdx @@ -0,0 +1,21 @@ +--- +id: index +title: Workers - Rust SDK +sidebar_label: Workers +description: + This section explains how to implement Workers with the Rust SDK +toc_max_heading_level: 4 +keywords: + - Rust +tags: + - Rust SDK + - Temporal SDKs +--- + +import * as Components from '@site/src/components'; + +![Rust SDK Banner](/img/assets/banner-rust-temporal.png) + +## Workers + +- [Worker processes](/develop/rust/workers/run-worker-process) \ No newline at end of file diff --git a/docs/develop/rust/workers/worker-process.mdx b/docs/develop/rust/workers/worker-process.mdx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/develop/rust/workflows/basics.mdx b/docs/develop/rust/workflows/basics.mdx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/develop/rust/workflows/cancellation.mdx b/docs/develop/rust/workflows/cancellation.mdx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/develop/rust/workflows/child-workflows.mdx b/docs/develop/rust/workflows/child-workflows.mdx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/develop/rust/workflows/continue-as-new.mdx b/docs/develop/rust/workflows/continue-as-new.mdx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/develop/rust/workflows/index.mdx b/docs/develop/rust/workflows/index.mdx new file mode 100644 index 0000000000..8477193a49 --- /dev/null +++ b/docs/develop/rust/workflows/index.mdx @@ -0,0 +1,26 @@ +--- +id: index +title: Workflows - Rust SDK +sidebar_label: Workflows +description: + This section explains how to implement Workflows with the Rust SDK +toc_max_heading_level: 4 +keywords: + - Rust +tags: + - Rust SDK + - Temporal SDKs +--- + +import * as Components from '@site/src/components'; + +![Rust SDK Banner](/img/assets/banner-rust-temporal.png) + +## Workflows + +- [Workflow basics](/develop/rust/workflows/basics) +- [Child Workflows](/develop/rust/workflows/child-workflows) +- [Continue-As-New](/develop/rust/workflows/continue-as-new) +- [Message passing](/develop/rust/workflows/message-passing) +- [Cancellation](/develop/rust/workflows/cancellation) +- [Timers](/develop/rust/workflows/timers) \ No newline at end of file diff --git a/docs/develop/rust/workflows/message-passing.mdx b/docs/develop/rust/workflows/message-passing.mdx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/develop/rust/workflows/timers.mdx b/docs/develop/rust/workflows/timers.mdx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/sidebars.js b/sidebars.js index 2de9f83ba9..f379728681 100644 --- a/sidebars.js +++ b/sidebars.js @@ -931,7 +931,82 @@ module.exports = { }, ], }, - 'develop/run-a-development-server', + { + type: 'category', + label: 'Rust SDK', + collapsed: true, + link: { + type: 'doc', + id: 'develop/rust/index', + }, + items: [ + 'develop/rust/quickstart', + { + type: 'category', + label: 'Workflows', + collapsed: true, + link: { + type: 'doc', + id: 'develop/rust/workflows/index', + }, + items: [ + 'develop/rust/workflows/basics', + 'develop/rust/workflows/child-workflows', + 'develop/rust/workflows/continue-as-new', + 'develop/rust/workflows/message-passing', + 'develop/rust/workflows/cancellation', + 'develop/rust/workflows/timers', + ], + }, + { + type: 'category', + label: 'Activities', + collapsed: true, + link: { + type: 'doc', + id: 'develop/rust/activities/index', + }, + items: [ + 'develop/rust/activities/basics', + 'develop/rust/activities/execution', + ], + }, + { + type: 'category', + label: 'Workers', + collapsed: true, + link: { + type: 'doc', + id: 'develop/rust/workers/index', + }, + items: [ + 'develop/rust/workers/worker-process', + ], + }, + { + type: 'category', + label: 'Client', + collapsed: true, + link: { + type: 'doc', + id: 'develop/rust/client/index', + }, + items: [ + 'develop/rust/client/temporal-client', + ], + }, + { + type: 'category', + label: 'Nexus', + collapsed: true, + link: { + type: 'doc', + id: 'develop/rust/nexus/index', + }, + items: ['develop/rust/nexus/service-handler'], + }, + ], + }, 'develop/environment-configuration', 'develop/activity-retry-simulator', 'develop/worker-performance', diff --git a/static/img/assets/banner-rust-temporal.png b/static/img/assets/banner-rust-temporal.png new file mode 100644 index 0000000000..b323a2cb4c Binary files /dev/null and b/static/img/assets/banner-rust-temporal.png differ