From cdfb89309b8b6598787867d0a34062e9470a7dd7 Mon Sep 17 00:00:00 2001 From: Durable Workflow Date: Fri, 23 Oct 2026 08:34:21 +0000 Subject: [PATCH 1/2] docs: explain Rust worker task capacity and concurrency --- docs/polyglot/rust.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/polyglot/rust.md b/docs/polyglot/rust.md index a82b6bc0470..9ae26b37e0c 100644 --- a/docs/polyglot/rust.md +++ b/docs/polyglot/rust.md @@ -118,6 +118,26 @@ or a worker minor newer than the server's advertised minor is rejected. The SDK and Server release versions are tracked independently. Their runtime protocol manifests determine compatibility. +## Worker task concurrency {#worker-task-concurrency} + +The bounded worker lanes below are qualified in Rust SDK **4.3.1**. Check the crate in `Cargo.lock` before using them: the installation pin above belongs to a separate qualified artifact tuple and may select an older SDK. The [published-package acceptance](https://github.com/durable-workflow/sdk-rust/issues/107#issuecomment-6360719863) verifies three configured slots, a fourth callback admitted after a slot is released, and seven completed workflows including a handled activity failure. This guide does not change the Server protocol requirements above. + +`Worker::max_concurrent_workflow_tasks(...)` and `Worker::max_concurrent_activity_tasks(...)` each default to **10**. `run()` and `run_until()` use independent bounded workflow and remote-activity lanes. Set a limit to **1** for serial execution within that task family. For example, configure an existing client before registering your application handlers: + +```rust +use durable_workflow::Worker; + +let mut worker = Worker::new(client.clone(), "payments") + .max_concurrent_workflow_tasks(1) + .max_concurrent_activity_tasks(1); +``` + +Register the workflow and activity handlers, then start `run()` or `run_until()` as usual. Setting both limits to one still permits a workflow task and a remote activity task to run at the same time. Queries keep a separate polling lane. Worker clones share the configured capacity, including simultaneous `run_once()` calls; cloning does not create another independent allowance. + +Heartbeat availability follows actual claimed tasks, including input/history loading, callback execution and settlement. An empty long poll leaves capacity available. Success, failure, refusal and cancellation release the local slot. Inline local activities occupy their **workflow-task** slot and bypass the remote-activity pool, so the activity limit does not separately cap inline local execution across workflows. + +Handlers are async futures on Tokio and must yield for other work to progress. Use `tokio::task::spawn_blocking` or a separate process for blocking work, with an explicit cancellation and shutdown boundary. Raising concurrency does not provide CPU isolation or make a detached thread cancellable. See the [Worker API](https://rust.durable-workflow.com/durable_workflow/struct.Worker.html) for the installed SDK's controls. + ## Local activities Rust SDK 3.1.0 adds inline local execution on workers configured with From 5d7015c78b2233f889b29732aaa534282feb2f69 Mon Sep 17 00:00:00 2001 From: Durable Workflow Date: Fri, 23 Oct 2026 08:41:14 +0000 Subject: [PATCH 2/2] docs: translate Rust worker capacity guidance in all locales --- docs/polyglot/rust.md | 2 +- .../current/polyglot/rust.md | 20 +++++++++++++++++++ i18n/de/source-hashes.json | 2 +- .../current/polyglot/rust.md | 20 +++++++++++++++++++ i18n/es/source-hashes.json | 2 +- .../current/polyglot/rust.md | 20 +++++++++++++++++++ i18n/fr/source-hashes.json | 2 +- .../current/polyglot/rust.md | 20 +++++++++++++++++++ i18n/ja/source-hashes.json | 2 +- .../current/polyglot/rust.md | 20 +++++++++++++++++++ i18n/pt-BR/source-hashes.json | 2 +- .../current/polyglot/rust.md | 20 +++++++++++++++++++ i18n/uk/source-hashes.json | 2 +- .../current/polyglot/rust.md | 20 +++++++++++++++++++ i18n/zh-Hans/source-hashes.json | 2 +- 15 files changed, 148 insertions(+), 8 deletions(-) diff --git a/docs/polyglot/rust.md b/docs/polyglot/rust.md index 9ae26b37e0c..0560c3aa10f 100644 --- a/docs/polyglot/rust.md +++ b/docs/polyglot/rust.md @@ -120,7 +120,7 @@ protocol manifests determine compatibility. ## Worker task concurrency {#worker-task-concurrency} -The bounded worker lanes below are qualified in Rust SDK **4.3.1**. Check the crate in `Cargo.lock` before using them: the installation pin above belongs to a separate qualified artifact tuple and may select an older SDK. The [published-package acceptance](https://github.com/durable-workflow/sdk-rust/issues/107#issuecomment-6360719863) verifies three configured slots, a fourth callback admitted after a slot is released, and seven completed workflows including a handled activity failure. This guide does not change the Server protocol requirements above. +The bounded worker lanes below require Rust SDK **4.3.1 or newer**. Check the crate in `Cargo.lock` before using them: the installation pin above belongs to a separate qualified artifact tuple and may select an older SDK. The [published-package acceptance](https://github.com/durable-workflow/sdk-rust/issues/107#issuecomment-6360719863) verifies three configured slots, a fourth callback admitted after a slot is released, and seven completed workflows including a handled activity failure. This guide does not change the Server protocol requirements above. `Worker::max_concurrent_workflow_tasks(...)` and `Worker::max_concurrent_activity_tasks(...)` each default to **10**. `run()` and `run_until()` use independent bounded workflow and remote-activity lanes. Set a limit to **1** for serial execution within that task family. For example, configure an existing client before registering your application handlers: diff --git a/i18n/de/docusaurus-plugin-content-docs/current/polyglot/rust.md b/i18n/de/docusaurus-plugin-content-docs/current/polyglot/rust.md index 8640838742b..0d13f5d78e2 100644 --- a/i18n/de/docusaurus-plugin-content-docs/current/polyglot/rust.md +++ b/i18n/de/docusaurus-plugin-content-docs/current/polyglot/rust.md @@ -118,6 +118,26 @@ eine andere Hauptversion oder eine höhere Worker-Nebenversion als die vom Server gemeldete werden abgelehnt. SDK- und Server-Release-Versionen werden unabhängig geführt. Ihre Laufzeit-Protokollmanifeste bestimmen die Kompatibilität. +## Parallelität der Worker-Tasks {#worker-task-concurrency} + +Die folgenden begrenzten Ausführungsspuren benötigen Rust SDK **4.3.1 oder neuer**. Prüfen Sie die Version in `Cargo.lock`: Die oben fixierte Installation gehört zu einem anderen qualifizierten Artefaktsatz und kann ein älteres SDK auswählen. Die [Akzeptanz des veröffentlichten Pakets](https://github.com/durable-workflow/sdk-rust/issues/107#issuecomment-6360719863) prüft drei konfigurierte Slots, einen vierten Callback erst nach Slot-Freigabe und sieben abgeschlossene Workflows einschließlich eines behandelten Aktivitätsfehlers. Die oben beschriebenen Server-Protokollanforderungen gelten weiterhin. + +`Worker::max_concurrent_workflow_tasks(...)` und `Worker::max_concurrent_activity_tasks(...)` haben jeweils den Standardwert **10**. `run()` und `run_until()` nutzen unabhängige begrenzte Spuren für Workflow und entfernte Aktivität. Wählen Sie **1** für sequenzielle Ausführung innerhalb einer Task-Familie. Konfigurieren Sie zum Beispiel einen vorhandenen Client vor der Handler-Registrierung: + +```rust +use durable_workflow::Worker; + +let mut worker = Worker::new(client.clone(), "payments") + .max_concurrent_workflow_tasks(1) + .max_concurrent_activity_tasks(1); +``` + +Registrieren Sie die Handler und starten Sie dann `run()` oder `run_until()` wie gewohnt. Zwei Grenzen von eins erlauben weiterhin einen Workflow-Task und einen entfernten Aktivitätstask gleichzeitig. Abfragen behalten ihre eigene Polling-Spur. Worker-Klone teilen die konfigurierte Kapazität, auch bei gleichzeitigen `run_once()`-Aufrufen. Klonen schafft kein weiteres unabhängiges Kontingent. + +Die Heartbeat-Verfügbarkeit folgt tatsächlich beanspruchten Tasks einschließlich Eingabe-/History-Laden, Callback-Ausführung und Abschlussbestätigung. Ein leerer Long-Poll lässt Kapazität verfügbar. Erfolg, Fehler, Ablehnung und Abbruch geben den lokalen Slot frei. Inline ausgeführte lokale Aktivitäten belegen ihren **Workflow-Task**-Slot und umgehen den entfernten Aktivitätspool. Das Aktivitätslimit begrenzt deshalb Inline-Ausführung über mehrere Workflows nicht separat. + +Handler sind async Futures auf Tokio und müssen Ausführungszeit abgeben. Verwenden Sie für blockierende Arbeit `tokio::task::spawn_blocking` oder einen separaten Prozess mit ausdrücklicher Abbruch- und Shutdown-Grenze. Mehr Parallelität isoliert keine CPU und macht einen abgetrennten Thread nicht abbrechbar. Siehe die [Worker-API](https://rust.durable-workflow.com/durable_workflow/struct.Worker.html) des installierten SDKs. + ## Lokale Aktivitäten {#local-activities} Rust SDK 3.1.0 ergänzt lokale Inline-Ausführung auf Workern mit diff --git a/i18n/de/source-hashes.json b/i18n/de/source-hashes.json index 4a63aee9ca0..174371bba02 100644 --- a/i18n/de/source-hashes.json +++ b/i18n/de/source-hashes.json @@ -84,7 +84,7 @@ "polyglot/prerelease-history-migration.md": "a57f05f492228a8a67791f9152648a1e5f80856325b78777cf63b6ef49b7413c", "polyglot/python.md": "a9fc8330cbc78953244b94a170197038a299a5a25fa78c38c7bfb451fd67d345", "polyglot/rust-cloud-quickstart.md": "2303434fc9302a81a8381ad4836423ef9952eb3201a4574c432254e3cb68c5f3", - "polyglot/rust.md": "32de05a771b5ee6d8cf54fdd408222372995ce29c8be63102abe58b977ac8ef0", + "polyglot/rust.md": "0bb9929cafe2751e1fde615ee033e127c5f6c6eaa8d4bbae941b4e1e86b06d58", "polyglot/server-api-reference.md": "e94af77a13b341d6fdc9941d4ee94e5053ab932d2e77069b238eb33351414e83", "polyglot/server-config-reference.md": "edb4cf00b9df2c9946b32a81c6bb2c4db6eaee89794b85286c61c235a4846414", "polyglot/server-role-topology.md": "3d048f0c6b5f179399622508f51e67fff8aa5a6d5b2492533fc720eeec2c27f2", diff --git a/i18n/es/docusaurus-plugin-content-docs/current/polyglot/rust.md b/i18n/es/docusaurus-plugin-content-docs/current/polyglot/rust.md index a7d523f724e..8f3811a192c 100644 --- a/i18n/es/docusaurus-plugin-content-docs/current/polyglot/rust.md +++ b/i18n/es/docusaurus-plugin-content-docs/current/polyglot/rust.md @@ -65,6 +65,26 @@ Server negocia las cabeceras del protocolo de workers dentro de la versión prin La negociación rechaza las incompatibilidades. Se rechaza una cabecera ausente o malformada, otra versión principal o una versión menor del worker superior a la anunciada por el servidor. Las versiones del SDK y de Server se gestionan por separado. Sus manifiestos de protocolo en runtime determinan la compatibilidad. +## Concurrencia de tareas del worker {#worker-task-concurrency} + +Los carriles acotados descritos aquí requieren Rust SDK **4.3.1 o posterior**. Compruebe la versión de `Cargo.lock`: la instalación fijada arriba pertenece a otra tupla cualificada y puede seleccionar un SDK anterior. La [verificación del paquete publicado](https://github.com/durable-workflow/sdk-rust/issues/107#issuecomment-6360719863) confirma tres slots configurados, una cuarta llamada admitida al liberarse uno, y siete workflows completados, incluido un fallo de actividad manejado. Siguen vigentes los requisitos de protocolo del Server descritos arriba. + +`Worker::max_concurrent_workflow_tasks(...)` y `Worker::max_concurrent_activity_tasks(...)` tienen un valor predeterminado de **10** cada uno. `run()` y `run_until()` usan carriles independientes y acotados para workflow y actividad remota. Configure **1** para ejecución secuencial dentro de esa familia de tareas. Por ejemplo, configure un cliente existente antes de registrar sus handlers: + +```rust +use durable_workflow::Worker; + +let mut worker = Worker::new(client.clone(), "payments") + .max_concurrent_workflow_tasks(1) + .max_concurrent_activity_tasks(1); +``` + +Registre los handlers y después inicie `run()` o `run_until()` normalmente. Dos límites de uno aún permiten ejecutar simultáneamente una tarea de workflow y una actividad remota. Las consultas mantienen su carril de polling separado. Los clones comparten la capacidad configurada, incluso entre llamadas simultáneas a `run_once()`; clonar no crea otro cupo independiente. + +La disponibilidad anunciada en heartbeats sigue las tareas realmente reclamadas, incluida la carga de entrada/historial, la ejecución y la confirmación. Un long poll vacío deja capacidad disponible. Éxito, fallo, negativa y cancelación liberan el slot local. Las actividades locales inline ocupan su slot de **tarea de workflow** y evitan el pool remoto; el límite de actividades no acota por separado la ejecución inline entre workflows. + +Los handlers son futures async de Tokio y deben ceder el control. Use `tokio::task::spawn_blocking` o un proceso separado para trabajo bloqueante, con límites explícitos de cancelación y apagado. Aumentar concurrencia no aísla CPU ni hace cancelable un thread desacoplado. Consulte la [API de Worker](https://rust.durable-workflow.com/durable_workflow/struct.Worker.html) del SDK instalado. + ## Actividades locales {#local-activities} El SDK de Rust 3.1.0 añade ejecución local en el propio worker con `Worker::local_activities(true)`. Registra callbacks con los métodos ordinarios de registro de actividades y utiliza los métodos de actividad local del contexto de workflow. Consulta el [ejemplo ejecutable](https://github.com/durable-workflow/sdk-rust/blob/3.1.0/examples/local_activities.rs) y la [referencia de LocalActivityOptions](https://rust.durable-workflow.com/durable_workflow/struct.LocalActivityOptions.html) para configurar reintentos y tiempos de espera. diff --git a/i18n/es/source-hashes.json b/i18n/es/source-hashes.json index 4a63aee9ca0..174371bba02 100644 --- a/i18n/es/source-hashes.json +++ b/i18n/es/source-hashes.json @@ -84,7 +84,7 @@ "polyglot/prerelease-history-migration.md": "a57f05f492228a8a67791f9152648a1e5f80856325b78777cf63b6ef49b7413c", "polyglot/python.md": "a9fc8330cbc78953244b94a170197038a299a5a25fa78c38c7bfb451fd67d345", "polyglot/rust-cloud-quickstart.md": "2303434fc9302a81a8381ad4836423ef9952eb3201a4574c432254e3cb68c5f3", - "polyglot/rust.md": "32de05a771b5ee6d8cf54fdd408222372995ce29c8be63102abe58b977ac8ef0", + "polyglot/rust.md": "0bb9929cafe2751e1fde615ee033e127c5f6c6eaa8d4bbae941b4e1e86b06d58", "polyglot/server-api-reference.md": "e94af77a13b341d6fdc9941d4ee94e5053ab932d2e77069b238eb33351414e83", "polyglot/server-config-reference.md": "edb4cf00b9df2c9946b32a81c6bb2c4db6eaee89794b85286c61c235a4846414", "polyglot/server-role-topology.md": "3d048f0c6b5f179399622508f51e67fff8aa5a6d5b2492533fc720eeec2c27f2", diff --git a/i18n/fr/docusaurus-plugin-content-docs/current/polyglot/rust.md b/i18n/fr/docusaurus-plugin-content-docs/current/polyglot/rust.md index 8a6d1331f08..92c3055c6a9 100644 --- a/i18n/fr/docusaurus-plugin-content-docs/current/polyglot/rust.md +++ b/i18n/fr/docusaurus-plugin-content-docs/current/polyglot/rust.md @@ -122,6 +122,26 @@ celle annoncée par Server est refusée. Les versions de publication SDK et Server sont suivies indépendamment. Leurs manifestes de protocole runtime déterminent la compatibilité. +## Concurrence des tâches du worker {#worker-task-concurrency} + +Les voies bornées ci-dessous nécessitent Rust SDK **4.3.1 ou ultérieur**. Vérifiez la version dans `Cargo.lock` : l’installation fixée plus haut appartient à une autre combinaison qualifiée et peut sélectionner un ancien SDK. La [vérification du paquet publié](https://github.com/durable-workflow/sdk-rust/issues/107#issuecomment-6360719863) confirme trois emplacements configurés, un quatrième callback admis après libération d’un emplacement et sept workflows terminés, dont un échec d’activité traité. Les exigences de protocole Server précédentes restent applicables. + +`Worker::max_concurrent_workflow_tasks(...)` et `Worker::max_concurrent_activity_tasks(...)` valent chacun **10** par défaut. `run()` et `run_until()` utilisent des voies bornées indépendantes pour workflow et activité distante. Choisissez **1** pour une exécution séquentielle au sein de cette famille de tâches. Par exemple, configurez un client existant avant d’enregistrer les handlers applicatifs : + +```rust +use durable_workflow::Worker; + +let mut worker = Worker::new(client.clone(), "payments") + .max_concurrent_workflow_tasks(1) + .max_concurrent_activity_tasks(1); +``` + +Enregistrez les handlers, puis lancez `run()` ou `run_until()` normalement. Deux limites à un permettent encore une tâche de workflow et une tâche d’activité distante simultanées. Les requêtes de lecture gardent leur propre voie de polling. Les clones partagent la capacité configurée, y compris entre appels simultanés à `run_once()` ; cloner ne crée pas de quota indépendant supplémentaire. + +La disponibilité des heartbeats suit les tâches réellement réclamées : chargement d’entrée/historique, exécution et confirmation. Un long poll vide laisse la capacité disponible. Succès, échec, refus et annulation libèrent l’emplacement local. Les activités locales inline occupent leur emplacement de **tâche de workflow** et contournent le pool distant ; la limite d’activité ne borne donc pas séparément l’exécution inline entre workflows. + +Les handlers sont des futures async Tokio et doivent céder la main. Utilisez `tokio::task::spawn_blocking` ou un processus séparé pour le travail bloquant, avec une limite explicite d’annulation et d’arrêt. Augmenter la concurrence n’isole pas le CPU et ne rend pas un thread détaché annulable. Voir l’[API Worker](https://rust.durable-workflow.com/durable_workflow/struct.Worker.html) du SDK installé. + ## Activités locales {#local-activities} Le SDK Rust 3.1.0 ajoute l’exécution locale en ligne sur les workers configurés diff --git a/i18n/fr/source-hashes.json b/i18n/fr/source-hashes.json index 4a63aee9ca0..174371bba02 100644 --- a/i18n/fr/source-hashes.json +++ b/i18n/fr/source-hashes.json @@ -84,7 +84,7 @@ "polyglot/prerelease-history-migration.md": "a57f05f492228a8a67791f9152648a1e5f80856325b78777cf63b6ef49b7413c", "polyglot/python.md": "a9fc8330cbc78953244b94a170197038a299a5a25fa78c38c7bfb451fd67d345", "polyglot/rust-cloud-quickstart.md": "2303434fc9302a81a8381ad4836423ef9952eb3201a4574c432254e3cb68c5f3", - "polyglot/rust.md": "32de05a771b5ee6d8cf54fdd408222372995ce29c8be63102abe58b977ac8ef0", + "polyglot/rust.md": "0bb9929cafe2751e1fde615ee033e127c5f6c6eaa8d4bbae941b4e1e86b06d58", "polyglot/server-api-reference.md": "e94af77a13b341d6fdc9941d4ee94e5053ab932d2e77069b238eb33351414e83", "polyglot/server-config-reference.md": "edb4cf00b9df2c9946b32a81c6bb2c4db6eaee89794b85286c61c235a4846414", "polyglot/server-role-topology.md": "3d048f0c6b5f179399622508f51e67fff8aa5a6d5b2492533fc720eeec2c27f2", diff --git a/i18n/ja/docusaurus-plugin-content-docs/current/polyglot/rust.md b/i18n/ja/docusaurus-plugin-content-docs/current/polyglot/rust.md index bc7dedb2dc7..4a266932734 100644 --- a/i18n/ja/docusaurus-plugin-content-docs/current/polyglot/rust.md +++ b/i18n/ja/docusaurus-plugin-content-docs/current/polyglot/rust.md @@ -65,6 +65,26 @@ Server はメジャー `1` 内で Worker プロトコルヘッダーをネゴシ ネゴシエーションは安全側に失敗します。ヘッダーの欠落・不正、異なるメジャー、Server が広告するマイナーより新しい Worker マイナーは拒否します。SDK と Server のリリースバージョンは独立に管理します。互換性はランタイムのプロトコルマニフェストで決まります。 +## Worker タスクの並行実行 {#worker-task-concurrency} + +以下の有界実行レーンには Rust SDK **4.3.1 以降**が必要です。`Cargo.lock` のバージョンを確認してください。上の固定インストールは別の検証済み構成に属し、古い SDK を選ぶ場合があります。[公開パッケージの受け入れ検証](https://github.com/durable-workflow/sdk-rust/issues/107#issuecomment-6360719863)では、設定した三つのスロット、解放後に初めて入る四つ目のコールバック、処理済みのアクティビティ失敗を含む七つのワークフロー完了を確認しています。前述の Server プロトコル要件は引き続き適用されます。 + +`Worker::max_concurrent_workflow_tasks(...)` と `Worker::max_concurrent_activity_tasks(...)` は、それぞれ既定値が **10** です。`run()` と `run_until()` はワークフローとリモートアクティビティで独立した有界レーンを使います。各タスク種別を逐次実行するには **1** を指定します。例えば、アプリケーションのハンドラー登録前に既存のクライアントを設定します。 + +```rust +use durable_workflow::Worker; + +let mut worker = Worker::new(client.clone(), "payments") + .max_concurrent_workflow_tasks(1) + .max_concurrent_activity_tasks(1); +``` + +ハンドラーを登録し、通常どおり `run()` または `run_until()` を起動してください。両方を一にしても、ワークフロータスク一つとリモートアクティビティタスク一つは同時に実行できます。クエリは別のポーリングレーンを使います。Worker のクローンは同時の `run_once()` 呼び出しを含めて容量を共有します。クローンを作っても独立した追加枠にはなりません。 + +ハートビートの空き容量は、入力・履歴の読み込み、コールバック実行、結果確定を含む実際の取得済みタスクに従います。空のロングポーリングは空き容量を残します。成功、失敗、拒否、キャンセルでローカルスロットを解放します。インラインのローカルアクティビティは**ワークフロータスク**のスロットを使い、リモートアクティビティプールを通りません。アクティビティ上限は複数ワークフローのインライン実行を別枠で制限しません。 + +ハンドラーは Tokio の async future であり、他の処理が進むよう実行権を譲る必要があります。ブロックする処理には `tokio::task::spawn_blocking` または別プロセスを使い、キャンセルと終了の境界を明示してください。並行数を増やしても CPU は分離されず、切り離されたスレッドがキャンセル可能になるわけでもありません。インストールした SDK の [Worker API](https://rust.durable-workflow.com/durable_workflow/struct.Worker.html) を参照してください。 + ## ローカルアクティビティ {#local-activities} Rust SDK 3.1.0 は `Worker::local_activities(true)` で設定した Worker にインラインのローカル実行を追加します。通常のアクティビティ登録メソッドでコールバックを登録し、ワークフローコンテキストのローカルアクティビティメソッドを使います。再試行とタイムアウトの設定は[実行可能な例](https://github.com/durable-workflow/sdk-rust/blob/3.1.0/examples/local_activities.rs)と [LocalActivityOptions リファレンス](https://rust.durable-workflow.com/durable_workflow/struct.LocalActivityOptions.html)を参照してください。 diff --git a/i18n/ja/source-hashes.json b/i18n/ja/source-hashes.json index 4a63aee9ca0..174371bba02 100644 --- a/i18n/ja/source-hashes.json +++ b/i18n/ja/source-hashes.json @@ -84,7 +84,7 @@ "polyglot/prerelease-history-migration.md": "a57f05f492228a8a67791f9152648a1e5f80856325b78777cf63b6ef49b7413c", "polyglot/python.md": "a9fc8330cbc78953244b94a170197038a299a5a25fa78c38c7bfb451fd67d345", "polyglot/rust-cloud-quickstart.md": "2303434fc9302a81a8381ad4836423ef9952eb3201a4574c432254e3cb68c5f3", - "polyglot/rust.md": "32de05a771b5ee6d8cf54fdd408222372995ce29c8be63102abe58b977ac8ef0", + "polyglot/rust.md": "0bb9929cafe2751e1fde615ee033e127c5f6c6eaa8d4bbae941b4e1e86b06d58", "polyglot/server-api-reference.md": "e94af77a13b341d6fdc9941d4ee94e5053ab932d2e77069b238eb33351414e83", "polyglot/server-config-reference.md": "edb4cf00b9df2c9946b32a81c6bb2c4db6eaee89794b85286c61c235a4846414", "polyglot/server-role-topology.md": "3d048f0c6b5f179399622508f51e67fff8aa5a6d5b2492533fc720eeec2c27f2", diff --git a/i18n/pt-BR/docusaurus-plugin-content-docs/current/polyglot/rust.md b/i18n/pt-BR/docusaurus-plugin-content-docs/current/polyglot/rust.md index 5036520fa26..a8882f410aa 100644 --- a/i18n/pt-BR/docusaurus-plugin-content-docs/current/polyglot/rust.md +++ b/i18n/pt-BR/docusaurus-plugin-content-docs/current/polyglot/rust.md @@ -117,6 +117,26 @@ major diferente ou uma minor de worker mais nova que a minor anunciada pelo servidor é rejeitada. Versões de release do SDK e Server são controladas independentemente. Seus manifestos de protocolo em runtime determinam a compatibilidade. +## Concorrência de tarefas do worker {#worker-task-concurrency} + +As faixas limitadas descritas aqui exigem Rust SDK **4.3.1 ou posterior**. Confira a versão em `Cargo.lock`: a instalação fixada acima pertence a outra tupla qualificada e pode selecionar um SDK anterior. A [aceitação do pacote publicado](https://github.com/durable-workflow/sdk-rust/issues/107#issuecomment-6360719863) verifica três slots configurados, uma quarta chamada admitida após a liberação de um slot e sete workflows concluídos, incluindo uma falha de atividade tratada. Os requisitos de protocolo do Server descritos acima continuam valendo. + +`Worker::max_concurrent_workflow_tasks(...)` e `Worker::max_concurrent_activity_tasks(...)` têm padrão **10** cada. `run()` e `run_until()` usam faixas independentes e limitadas para workflow e atividade remota. Defina **1** para execução sequencial dentro da família de tarefas. Por exemplo, configure um cliente existente antes de registrar seus handlers: + +```rust +use durable_workflow::Worker; + +let mut worker = Worker::new(client.clone(), "payments") + .max_concurrent_workflow_tasks(1) + .max_concurrent_activity_tasks(1); +``` + +Registre os handlers e depois execute `run()` ou `run_until()` normalmente. Os dois limites em um ainda permitem uma tarefa de workflow e uma atividade remota simultâneas. Consultas mantêm uma faixa separada de polling. Clones do worker compartilham a capacidade configurada, inclusive chamadas simultâneas de `run_once()`; clonar não cria outra cota independente. + +A disponibilidade dos heartbeats acompanha as tarefas realmente adquiridas, incluindo carregamento de entrada/histórico, execução e confirmação. Um long poll vazio mantém capacidade disponível. Sucesso, falha, recusa e cancelamento liberam o slot local. Atividades locais inline ocupam seu slot de **tarefa de workflow** e não usam o pool remoto; o limite de atividades não restringe separadamente a execução inline entre workflows. + +Handlers são futures async do Tokio e precisam ceder o controle. Use `tokio::task::spawn_blocking` ou outro processo para trabalho bloqueante, com limites explícitos de cancelamento e encerramento. Aumentar concorrência não fornece isolamento de CPU nem torna cancelável uma thread desacoplada. Veja a [API de Worker](https://rust.durable-workflow.com/durable_workflow/struct.Worker.html) do SDK instalado. + ## Atividades locais {#local-activities} O SDK Rust 3.1.0 adiciona execução local inline em workers configurados com diff --git a/i18n/pt-BR/source-hashes.json b/i18n/pt-BR/source-hashes.json index 4a63aee9ca0..174371bba02 100644 --- a/i18n/pt-BR/source-hashes.json +++ b/i18n/pt-BR/source-hashes.json @@ -84,7 +84,7 @@ "polyglot/prerelease-history-migration.md": "a57f05f492228a8a67791f9152648a1e5f80856325b78777cf63b6ef49b7413c", "polyglot/python.md": "a9fc8330cbc78953244b94a170197038a299a5a25fa78c38c7bfb451fd67d345", "polyglot/rust-cloud-quickstart.md": "2303434fc9302a81a8381ad4836423ef9952eb3201a4574c432254e3cb68c5f3", - "polyglot/rust.md": "32de05a771b5ee6d8cf54fdd408222372995ce29c8be63102abe58b977ac8ef0", + "polyglot/rust.md": "0bb9929cafe2751e1fde615ee033e127c5f6c6eaa8d4bbae941b4e1e86b06d58", "polyglot/server-api-reference.md": "e94af77a13b341d6fdc9941d4ee94e5053ab932d2e77069b238eb33351414e83", "polyglot/server-config-reference.md": "edb4cf00b9df2c9946b32a81c6bb2c4db6eaee89794b85286c61c235a4846414", "polyglot/server-role-topology.md": "3d048f0c6b5f179399622508f51e67fff8aa5a6d5b2492533fc720eeec2c27f2", diff --git a/i18n/uk/docusaurus-plugin-content-docs/current/polyglot/rust.md b/i18n/uk/docusaurus-plugin-content-docs/current/polyglot/rust.md index 17fe0562805..f8796d0dbf9 100644 --- a/i18n/uk/docusaurus-plugin-content-docs/current/polyglot/rust.md +++ b/i18n/uk/docusaurus-plugin-content-docs/current/polyglot/rust.md @@ -118,6 +118,26 @@ Rust SDK 3.5.0 за замовчуванням надсилає Версії випусків SDK та Server відстежуються незалежно. Їхня сумісність визначається protocol manifests runtime. +## Паралельність завдань worker {#worker-task-concurrency} + +Описані нижче обмежені лінії виконання потребують Rust SDK **4.3.1 або новішого**. Перевірте версію в `Cargo.lock`: наведена вище фіксація встановлення належить окремому кваліфікованому набору артефактів і може обирати старіший SDK. [Перевірка опублікованого пакета](https://github.com/durable-workflow/sdk-rust/issues/107#issuecomment-6360719863) підтверджує три налаштовані слоти, допуск четвертого виклику після звільнення слота і сім завершених workflow, зокрема з обробленою помилкою activity. Вимоги протоколу Server вище залишаються чинними. + +`Worker::max_concurrent_workflow_tasks(...)` і `Worker::max_concurrent_activity_tasks(...)` мають типове значення **10** кожен. `run()` та `run_until()` використовують незалежні обмежені лінії workflow і віддалених activity. Значення **1** задає послідовне виконання в межах цього типу завдань. Наприклад, налаштуйте наявний клієнт перед реєстрацією обробників: + +```rust +use durable_workflow::Worker; + +let mut worker = Worker::new(client.clone(), "payments") + .max_concurrent_workflow_tasks(1) + .max_concurrent_activity_tasks(1); +``` + +Зареєструйте обробники workflow та activity, потім запускайте `run()` або `run_until()` як звичайно. Дві межі по одному все одно дозволяють одночасно виконувати завдання workflow та віддаленої activity. Query має окрему лінію опитування. Клони worker спільно використовують налаштовану місткість, зокрема для одночасних `run_once()`. Клонування не створює додаткового незалежного бюджету. + +Доступність у heartbeat відповідає фактично взятим завданням, включно із завантаженням аргументів/історії, виконанням і підтвердженням результату. Порожнє довге опитування залишає місткість доступною. Успіх, помилка, відмова та скасування звільняють локальний слот. Inline local activity займає слот **завдання workflow** та оминає пул віддалених activity. Тому межа activity не обмежує окремо inline-виконання в різних workflow. + +Обробники є async future у Tokio і повинні віддавати керування. Для блокувальної роботи використовуйте `tokio::task::spawn_blocking` або окремий процес із явними межами скасування та завершення. Більша паралельність не ізолює CPU і не робить від’єднаний потік скасовуваним. Перегляньте [Worker API](https://rust.durable-workflow.com/durable_workflow/struct.Worker.html) для встановленої версії SDK. + ## Локальні activity {#local-activities} Rust SDK 3.1.0 додає inline local execution на workers із налаштуванням diff --git a/i18n/uk/source-hashes.json b/i18n/uk/source-hashes.json index 4a63aee9ca0..174371bba02 100644 --- a/i18n/uk/source-hashes.json +++ b/i18n/uk/source-hashes.json @@ -84,7 +84,7 @@ "polyglot/prerelease-history-migration.md": "a57f05f492228a8a67791f9152648a1e5f80856325b78777cf63b6ef49b7413c", "polyglot/python.md": "a9fc8330cbc78953244b94a170197038a299a5a25fa78c38c7bfb451fd67d345", "polyglot/rust-cloud-quickstart.md": "2303434fc9302a81a8381ad4836423ef9952eb3201a4574c432254e3cb68c5f3", - "polyglot/rust.md": "32de05a771b5ee6d8cf54fdd408222372995ce29c8be63102abe58b977ac8ef0", + "polyglot/rust.md": "0bb9929cafe2751e1fde615ee033e127c5f6c6eaa8d4bbae941b4e1e86b06d58", "polyglot/server-api-reference.md": "e94af77a13b341d6fdc9941d4ee94e5053ab932d2e77069b238eb33351414e83", "polyglot/server-config-reference.md": "edb4cf00b9df2c9946b32a81c6bb2c4db6eaee89794b85286c61c235a4846414", "polyglot/server-role-topology.md": "3d048f0c6b5f179399622508f51e67fff8aa5a6d5b2492533fc720eeec2c27f2", diff --git a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/polyglot/rust.md b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/polyglot/rust.md index 04a42c298ab..62393aa2340 100644 --- a/i18n/zh-Hans/docusaurus-plugin-content-docs/current/polyglot/rust.md +++ b/i18n/zh-Hans/docusaurus-plugin-content-docs/current/polyglot/rust.md @@ -65,6 +65,26 @@ Server 在主版本 `1` 内协商 Worker 协议头:公布 `1.N` 的 Server 仅 协商默认拒绝不合规请求。缺失或格式错误的头、不同主版本,或高于 Server 公布次版本的 Worker 次版本都会被拒绝。SDK 和 Server 发布版本独立跟踪,由运行时协议清单决定兼容性。 +## Worker 任务并发 {#worker-task-concurrency} + +以下有界执行通道需要 Rust SDK **4.3.1 或更高版本**。使用前检查 `Cargo.lock` 中的版本:上方的安装固定版本属于另一组已验证构件,可能选择较旧的 SDK。[已发布包验收](https://github.com/durable-workflow/sdk-rust/issues/107#issuecomment-6360719863)验证了三个配置槽位、释放槽位后第四次回调才被接纳,以及七个完成的工作流,其中包括已处理的活动失败。前述 Server 协议要求仍然适用。 + +`Worker::max_concurrent_workflow_tasks(...)` 和 `Worker::max_concurrent_activity_tasks(...)` 的默认值各为 **10**。`run()` 和 `run_until()` 为工作流与远程活动使用独立的有界通道。设为 **1** 可使该类任务串行执行。例如,在注册应用处理函数前配置现有客户端: + +```rust +use durable_workflow::Worker; + +let mut worker = Worker::new(client.clone(), "payments") + .max_concurrent_workflow_tasks(1) + .max_concurrent_activity_tasks(1); +``` + +注册工作流和活动处理函数后,照常启动 `run()` 或 `run_until()`。两个限制都设为一时,仍允许一个工作流任务与一个远程活动任务同时执行。查询保留独立轮询通道。Worker 克隆共享配置容量,包括同时调用 `run_once()`;克隆不会创建另一份独立配额。 + +心跳报告的可用容量以实际已领取任务为准,包括输入/历史加载、回调执行和结果确认。空长轮询保留可用容量。成功、失败、拒绝和取消都会释放本地槽位。内联本地活动占用其**工作流任务**槽位,不经过远程活动池,因此活动限制不会单独约束跨工作流的内联执行。 + +处理函数作为 Tokio async future 执行,必须让出执行权。阻塞工作应使用 `tokio::task::spawn_blocking` 或独立进程,并设置明确的取消和关闭边界。提高并发不会隔离 CPU,也不会使脱离管理的线程可取消。参见已安装 SDK 的 [Worker API](https://rust.durable-workflow.com/durable_workflow/struct.Worker.html)。 + ## 本地活动 {#local-activities} Rust SDK 3.1.0 在配置了 `Worker::local_activities(true)` 的 Worker 上增加内联本地执行。使用普通活动注册方法注册回调,然后使用工作流上下文的本地活动方法。重试和超时配置见[可运行示例](https://github.com/durable-workflow/sdk-rust/blob/3.1.0/examples/local_activities.rs)及 [LocalActivityOptions 参考](https://rust.durable-workflow.com/durable_workflow/struct.LocalActivityOptions.html)。 diff --git a/i18n/zh-Hans/source-hashes.json b/i18n/zh-Hans/source-hashes.json index 4a63aee9ca0..174371bba02 100644 --- a/i18n/zh-Hans/source-hashes.json +++ b/i18n/zh-Hans/source-hashes.json @@ -84,7 +84,7 @@ "polyglot/prerelease-history-migration.md": "a57f05f492228a8a67791f9152648a1e5f80856325b78777cf63b6ef49b7413c", "polyglot/python.md": "a9fc8330cbc78953244b94a170197038a299a5a25fa78c38c7bfb451fd67d345", "polyglot/rust-cloud-quickstart.md": "2303434fc9302a81a8381ad4836423ef9952eb3201a4574c432254e3cb68c5f3", - "polyglot/rust.md": "32de05a771b5ee6d8cf54fdd408222372995ce29c8be63102abe58b977ac8ef0", + "polyglot/rust.md": "0bb9929cafe2751e1fde615ee033e127c5f6c6eaa8d4bbae941b4e1e86b06d58", "polyglot/server-api-reference.md": "e94af77a13b341d6fdc9941d4ee94e5053ab932d2e77069b238eb33351414e83", "polyglot/server-config-reference.md": "edb4cf00b9df2c9946b32a81c6bb2c4db6eaee89794b85286c61c235a4846414", "polyglot/server-role-topology.md": "3d048f0c6b5f179399622508f51e67fff8aa5a6d5b2492533fc720eeec2c27f2",