Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions docs/polyglot/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,40 @@ Heartbeat availability follows actual claimed tasks, including input/history loa

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.

## Received activity retry budgets {#activity-retry-info}

Rust SDK **4.8.0 or newer** exposes `ActivityContext::retry_info()` in service activity handlers. Check the installed crate in `Cargo.lock`: the separately selected installation pin above can be older. The returned `ActivityRetryInfo` preserves the original `attempt_number()` and received `policy()` JSON, including unknown fields. It is an immutable snapshot of this invocation, independent of mutable compatibility fields on the context.

Use `attempt_limit()` and `is_last_configured_attempt()` to interpret the received budget:

| Received retry policy | `ActivityAttemptLimit` | Final configured attempt |
| --- | --- | --- |
| Object with positive integer `max_attempts: n` | `Bounded(n)`, including the first attempt | `Some(true)` once the original attempt reaches or exceeds `n`, otherwise `Some(false)` |
| Object with `max_attempts: null` | `Unlimited` | `Some(false)` |
| Omitted policy, root null, missing field or invalid limit | `Unknown` | `None` |

The helper also returns `None` for an invalid zero attempt number. A runtime's scheduling default does not establish received metadata: the published Server 2.11.0 no-authored-policy control omits the snapshot and therefore reports `Unknown`, not an inferred `Bounded(1)`. `policy()` distinguishes an omitted policy from a received JSON null without treating either as unlimited. The [normal installed acceptance](https://github.com/durable-workflow/sdk-rust/issues/135#issuecomment-6366200791) includes this control and the recipe below.

For a final-configured-attempt fallback or application alert, register a handler on your existing Worker:

```rust
use durable_workflow::{json, Worker};

pub fn register_charge(worker: &mut Worker) {
worker.register_activity("charge", |ctx, _| async move {
let retry = ctx.retry_info();
if retry.is_last_configured_attempt() == Some(true) {
// Select a final-attempt fallback or record an application alert.
}
Ok(json!({"attempt": retry.attempt_number()}))
});
}
```

`Some(false)` is not a promise of another execution. Non-retryable failure, cancellation, workflow closure and elapsed deadlines can end work before its configured budget is used. The helper does not change retry admission or grant extra time.

Local activities and direct `testing::WorkflowEnvironment::run_activity` calls have no received Server snapshot and report unknown policy. Fresh `run_workflow` tests expose the modeled snapshot recorded in their generated history. These test semantics do not prove a deployed Server sends a policy. See [ActivityRetryInfo](https://rust.durable-workflow.com/durable_workflow/struct.ActivityRetryInfo.html) and [ActivityAttemptLimit](https://rust.durable-workflow.com/durable_workflow/enum.ActivityAttemptLimit.html).

## Local activities

Rust SDK 3.1.0 adds inline local execution on workers configured with
Expand Down
34 changes: 34 additions & 0 deletions i18n/de/docusaurus-plugin-content-docs/current/polyglot/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,40 @@ Die Heartbeat-Verfügbarkeit folgt tatsächlich beanspruchten Tasks einschließl

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.

## Empfangene Wiederholungsbudgets für Aktivitäten {#activity-retry-info}

Rust SDK **4.8.0 oder neuer** stellt `ActivityContext::retry_info()` in Aktivitätshandlern im Service-Modus bereit. Prüfen Sie das installierte Crate in `Cargo.lock`: Die oben separat gewählte Installationsversion kann älter sein. Der zurückgegebene `ActivityRetryInfo` bewahrt die ursprüngliche `attempt_number()` und das empfangene `policy()`-JSON einschließlich unbekannter Felder. Dieser unveränderliche Snapshot des Aufrufs ist von veränderbaren Kompatibilitätsfeldern des Kontexts unabhängig.

Verwenden Sie `attempt_limit()` und `is_last_configured_attempt()`, um das empfangene Budget auszuwerten:

| Empfangene Wiederholungsrichtlinie | `ActivityAttemptLimit` | Letzter konfigurierter Versuch |
| --- | --- | --- |
| Objekt mit positiver Ganzzahl `max_attempts: n` | `Bounded(n)` einschließlich des ersten Versuchs | `Some(true)`, sobald der ursprüngliche Versuch `n` erreicht oder überschreitet, andernfalls `Some(false)` |
| Objekt mit `max_attempts: null` | `Unlimited` | `Some(false)` |
| Fehlende Richtlinie, null auf oberster Ebene, fehlendes Feld oder ungültige Grenze | `Unknown` | `None` |

Der Helper gibt auch bei einer ungültigen Versuchsnummer null `None` zurück. Ein Planungsstandard des Runtimes belegt keine empfangenen Metadaten: Der veröffentlichte Server-2.11.0-Kontrollfall ohne ausdrücklich verfasste Richtlinie lässt den Snapshot aus und meldet daher `Unknown` statt eines abgeleiteten `Bounded(1)`. `policy()` unterscheidet eine fehlende Richtlinie von empfangenem JSON null, ohne eines davon als unbegrenzt zu behandeln. Die [Abnahme mit normal installiertem Paket](https://github.com/durable-workflow/sdk-rust/issues/135#issuecomment-6366200791) umfasst diesen Kontrollfall und das folgende Beispiel.

Registrieren Sie für einen Fallback oder Anwendungsalarm beim letzten konfigurierten Versuch einen Handler an Ihrem vorhandenen Worker:

```rust
use durable_workflow::{json, Worker};

pub fn register_charge(worker: &mut Worker) {
worker.register_activity("charge", |ctx, _| async move {
let retry = ctx.retry_info();
if retry.is_last_configured_attempt() == Some(true) {
// Select a final-attempt fallback or record an application alert.
}
Ok(json!({"attempt": retry.attempt_number()}))
});
}
```

`Some(false)` verspricht keine weitere Ausführung. Ein nicht wiederholbarer Fehler, Abbruch, Workflow-Abschluss oder abgelaufene Fristen können die Arbeit beenden, bevor das konfigurierte Budget ausgeschöpft ist. Der Helper ändert weder die Zulassung von Wiederholungen noch gewährt er zusätzliche Zeit.

Lokale Aktivitäten und direkte Aufrufe von `testing::WorkflowEnvironment::run_activity` haben keinen empfangenen Server-Snapshot und melden eine unbekannte Richtlinie. Neue `run_workflow`-Tests zeigen den modellierten Snapshot aus ihrer erzeugten Historie. Diese Testsemantik belegt nicht, dass ein bereitgestellter Server eine Richtlinie sendet. Siehe [ActivityRetryInfo](https://rust.durable-workflow.com/durable_workflow/struct.ActivityRetryInfo.html) und [ActivityAttemptLimit](https://rust.durable-workflow.com/durable_workflow/enum.ActivityAttemptLimit.html).

## Lokale Aktivitäten {#local-activities}

Rust SDK 3.1.0 ergänzt lokale Inline-Ausführung auf Workern mit
Expand Down
2 changes: 1 addition & 1 deletion i18n/de/source-hashes.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"polyglot/prerelease-history-migration.md": "a57f05f492228a8a67791f9152648a1e5f80856325b78777cf63b6ef49b7413c",
"polyglot/python.md": "d55056ca7638df07b7267bc6d62e635b954957b99620478e861df90558860df3",
"polyglot/rust-cloud-quickstart.md": "2303434fc9302a81a8381ad4836423ef9952eb3201a4574c432254e3cb68c5f3",
"polyglot/rust.md": "1466f1f9b417708d88f6d89efa055c2d92e2ee93e9508cf82eb05fa1dc801a88",
"polyglot/rust.md": "f6ac50f08ee1a7e94686403df5880e771cd306aa07aed69c73261e5a25f6d78f",
"polyglot/server-api-reference.md": "e94af77a13b341d6fdc9941d4ee94e5053ab932d2e77069b238eb33351414e83",
"polyglot/server-config-reference.md": "edb4cf00b9df2c9946b32a81c6bb2c4db6eaee89794b85286c61c235a4846414",
"polyglot/server-role-topology.md": "3d048f0c6b5f179399622508f51e67fff8aa5a6d5b2492533fc720eeec2c27f2",
Expand Down
34 changes: 34 additions & 0 deletions i18n/es/docusaurus-plugin-content-docs/current/polyglot/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,40 @@ La disponibilidad anunciada en heartbeats sigue las tareas realmente reclamadas,

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.

## Presupuestos de reintento recibidos por la actividad {#activity-retry-info}

Rust SDK **4.8.0 o posterior** ofrece `ActivityContext::retry_info()` en los manejadores de actividades del servicio. Comprueba el crate instalado en `Cargo.lock`: la versión de instalación seleccionada por separado arriba puede ser anterior. El `ActivityRetryInfo` devuelto conserva el `attempt_number()` original y el JSON de `policy()` recibido, incluidos los campos desconocidos. Es una instantánea inmutable de esta invocación, independiente de los campos de compatibilidad mutables del contexto.

Usa `attempt_limit()` e `is_last_configured_attempt()` para interpretar el presupuesto recibido:

| Política de reintento recibida | `ActivityAttemptLimit` | Último intento configurado |
| --- | --- | --- |
| Objeto con entero positivo `max_attempts: n` | `Bounded(n)`, incluido el primer intento | `Some(true)` cuando el intento original alcanza o supera `n`; en otro caso, `Some(false)` |
| Objeto con `max_attempts: null` | `Unlimited` | `Some(false)` |
| Política omitida, null raíz, campo ausente o límite inválido | `Unknown` | `None` |

El helper también devuelve `None` ante un número de intento cero inválido. El valor predeterminado de planificación del runtime no demuestra los metadatos recibidos: el control publicado de Server 2.11.0 sin política escrita omite la instantánea y devuelve `Unknown`, sin inferir `Bounded(1)`. `policy()` distingue una política omitida de un JSON null recibido sin interpretar ninguno como ilimitado. La [aceptación con instalación normal](https://github.com/durable-workflow/sdk-rust/issues/135#issuecomment-6366200791) incluye este control y la receta siguiente.

Para elegir una alternativa o registrar una alerta de aplicación en el último intento configurado, registra un manejador en tu Worker existente:

```rust
use durable_workflow::{json, Worker};

pub fn register_charge(worker: &mut Worker) {
worker.register_activity("charge", |ctx, _| async move {
let retry = ctx.retry_info();
if retry.is_last_configured_attempt() == Some(true) {
// Select a final-attempt fallback or record an application alert.
}
Ok(json!({"attempt": retry.attempt_number()}))
});
}
```

`Some(false)` no promete otra ejecución. Un fallo no reintentable, la cancelación, el cierre del workflow y los plazos agotados pueden terminar el trabajo antes de consumir el presupuesto configurado. El helper no cambia la admisión de reintentos ni concede tiempo adicional.

Las actividades locales y las llamadas directas a `testing::WorkflowEnvironment::run_activity` no tienen una instantánea recibida del Server y devuelven política desconocida. Las pruebas nuevas con `run_workflow` exponen la instantánea modelada que registran en su historial generado. Esta semántica de pruebas no demuestra que un Server desplegado envíe una política. Consulta [ActivityRetryInfo](https://rust.durable-workflow.com/durable_workflow/struct.ActivityRetryInfo.html) y [ActivityAttemptLimit](https://rust.durable-workflow.com/durable_workflow/enum.ActivityAttemptLimit.html).

## 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.
Expand Down
2 changes: 1 addition & 1 deletion i18n/es/source-hashes.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"polyglot/prerelease-history-migration.md": "a57f05f492228a8a67791f9152648a1e5f80856325b78777cf63b6ef49b7413c",
"polyglot/python.md": "d55056ca7638df07b7267bc6d62e635b954957b99620478e861df90558860df3",
"polyglot/rust-cloud-quickstart.md": "2303434fc9302a81a8381ad4836423ef9952eb3201a4574c432254e3cb68c5f3",
"polyglot/rust.md": "1466f1f9b417708d88f6d89efa055c2d92e2ee93e9508cf82eb05fa1dc801a88",
"polyglot/rust.md": "f6ac50f08ee1a7e94686403df5880e771cd306aa07aed69c73261e5a25f6d78f",
"polyglot/server-api-reference.md": "e94af77a13b341d6fdc9941d4ee94e5053ab932d2e77069b238eb33351414e83",
"polyglot/server-config-reference.md": "edb4cf00b9df2c9946b32a81c6bb2c4db6eaee89794b85286c61c235a4846414",
"polyglot/server-role-topology.md": "3d048f0c6b5f179399622508f51e67fff8aa5a6d5b2492533fc720eeec2c27f2",
Expand Down
34 changes: 34 additions & 0 deletions i18n/fr/docusaurus-plugin-content-docs/current/polyglot/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,40 @@ La disponibilité des heartbeats suit les tâches réellement réclamées : char

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é.

## Budgets de tentatives reçus par une activité {#activity-retry-info}

Rust SDK **4.8.0 ou ultérieur** expose `ActivityContext::retry_info()` dans les gestionnaires d’activités en mode service. Vérifiez le crate installé dans `Cargo.lock` : la version d’installation sélectionnée séparément ci-dessus peut être plus ancienne. Le `ActivityRetryInfo` renvoyé conserve le `attempt_number()` original et le JSON `policy()` reçu, y compris les champs inconnus. Cet instantané immuable de l’invocation est indépendant des champs de compatibilité modifiables du contexte.

Utilisez `attempt_limit()` et `is_last_configured_attempt()` pour interpréter le budget reçu :

| Politique de tentatives reçue | `ActivityAttemptLimit` | Dernière tentative configurée |
| --- | --- | --- |
| Objet avec un entier positif `max_attempts: n` | `Bounded(n)`, première tentative comprise | `Some(true)` lorsque la tentative originale atteint ou dépasse `n`, sinon `Some(false)` |
| Objet avec `max_attempts: null` | `Unlimited` | `Some(false)` |
| Politique omise, null à la racine, champ absent ou limite invalide | `Unknown` | `None` |

Le helper renvoie aussi `None` pour un numéro de tentative nul invalide. Le comportement de planification par défaut du runtime ne prouve pas les métadonnées reçues : le contrôle publié sur Server 2.11.0 sans politique définie par l’auteur omet l’instantané et indique donc `Unknown`, sans déduire `Bounded(1)`. `policy()` distingue une politique omise d’un JSON null reçu sans considérer l’un ou l’autre comme illimité. L’[acceptation avec installation normale](https://github.com/durable-workflow/sdk-rust/issues/135#issuecomment-6366200791) comprend ce contrôle et l’exemple ci-dessous.

Pour choisir une solution de repli ou enregistrer une alerte applicative lors de la dernière tentative configurée, enregistrez un gestionnaire sur votre Worker existant :

```rust
use durable_workflow::{json, Worker};

pub fn register_charge(worker: &mut Worker) {
worker.register_activity("charge", |ctx, _| async move {
let retry = ctx.retry_info();
if retry.is_last_configured_attempt() == Some(true) {
// Select a final-attempt fallback or record an application alert.
}
Ok(json!({"attempt": retry.attempt_number()}))
});
}
```

`Some(false)` ne promet pas une nouvelle exécution. Un échec non réessayable, l’annulation, la fermeture du workflow ou des échéances dépassées peuvent terminer le travail avant épuisement du budget configuré. Le helper ne change pas l’admission des tentatives et n’accorde pas de temps supplémentaire.

Les activités locales et les appels directs à `testing::WorkflowEnvironment::run_activity` n’ont pas d’instantané reçu du Server et indiquent une politique inconnue. Les nouveaux tests `run_workflow` exposent l’instantané modélisé enregistré dans leur historique généré. Cette sémantique de test ne prouve pas qu’un Server déployé transmet une politique. Voir [ActivityRetryInfo](https://rust.durable-workflow.com/durable_workflow/struct.ActivityRetryInfo.html) et [ActivityAttemptLimit](https://rust.durable-workflow.com/durable_workflow/enum.ActivityAttemptLimit.html).

## Activités locales {#local-activities}

Le SDK Rust 3.1.0 ajoute l’exécution locale en ligne sur les workers configurés
Expand Down
2 changes: 1 addition & 1 deletion i18n/fr/source-hashes.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"polyglot/prerelease-history-migration.md": "a57f05f492228a8a67791f9152648a1e5f80856325b78777cf63b6ef49b7413c",
"polyglot/python.md": "d55056ca7638df07b7267bc6d62e635b954957b99620478e861df90558860df3",
"polyglot/rust-cloud-quickstart.md": "2303434fc9302a81a8381ad4836423ef9952eb3201a4574c432254e3cb68c5f3",
"polyglot/rust.md": "1466f1f9b417708d88f6d89efa055c2d92e2ee93e9508cf82eb05fa1dc801a88",
"polyglot/rust.md": "f6ac50f08ee1a7e94686403df5880e771cd306aa07aed69c73261e5a25f6d78f",
"polyglot/server-api-reference.md": "e94af77a13b341d6fdc9941d4ee94e5053ab932d2e77069b238eb33351414e83",
"polyglot/server-config-reference.md": "edb4cf00b9df2c9946b32a81c6bb2c4db6eaee89794b85286c61c235a4846414",
"polyglot/server-role-topology.md": "3d048f0c6b5f179399622508f51e67fff8aa5a6d5b2492533fc720eeec2c27f2",
Expand Down
Loading
Loading