Expand description
Semantic retry policies for host-managed operations and local user code.
Named policies are installed and resolved by the Golem host. A resolved policy can also be
compiled into a RetrySchedule to retry arbitrary user code in the component:
use golem_rust::retry::{
PredicateValue, Props, RetrySchedule, resolve_retry_policy,
};
use std::io;
let context = vec![(
Props::STATUS_CODE.to_string(),
PredicateValue::Integer(503),
)];
let raw = resolve_retry_policy("send", "email://welcome", &context)
.map_err(io::Error::other)?
.ok_or_else(|| io::Error::other("no matching retry policy"))?;
let schedule = RetrySchedule::try_from(&raw)?;
schedule
.retry_with_properties(
async || Err::<(), _>(io::Error::other("temporarily unavailable")),
|_| context.clone(),
)
.await?;Resolution remains host-driven, but RetrySchedule execution is a local guest loop. Local
attempts do not become executor RetryAttempt entries or one host-managed retry sequence.
Re-exports§
pub use builder::NamedPolicy;pub use builder::Policy;pub use builder::Predicate;pub use builder::Props;pub use builder::RetryBuilderError;pub use builder::Value;
Modules§
Structs§
- Count
BoxConfig - Named
Retry Policy - ── Named policy rule ──────────────────────────────────────────── A named retry policy rule: predicate selects when it applies, policy defines the retry strategy, priority controls evaluation order (higher = checked first).
- Retry
Policy - A composable retry policy tree. Root is nodes[0]. Children referenced by policy-node-index.
- Retry
Policy Guard - Guard that restores the previous state of a named retry policy on drop. If the policy existed before, it is restored; if it was newly added, it is removed.
- Retry
Predicate - A composable predicate tree for matching retry contexts. Root is nodes[0]. Children referenced by predicate-node-index.
- Retry
Schedule - A validated retry schedule for retrying fallible user code locally.
Enums§
- Policy
Node - Predicate
Node - Predicate
Value - ── Predicate value ────────────────────────────────────────────── Dynamic value for property comparisons in retry predicates
- Retry
Policy Error - An error found while validating a flattened raw retry policy.
Functions§
- get_
retry_ policies - Get all retry policies active for this agent.
- get_
retry_ policy_ by_ name - Get a specific retry policy by name.
- remove_
retry_ policy - Remove a named retry policy by name (persisted to oplog).
- resolve_
retry_ policy - Resolve the matching retry policy for a given operation context. Evaluates named policies in descending priority order; returns the policy from the first rule whose predicate matches, or none. Invalid predicates return an error without trapping the invocation.
- set_
named_ policy - Add or overwrite a high-level named retry policy after validating and flattening it into the raw WIT representation.
- set_
retry_ policy - Add or overwrite a named retry policy (persisted to oplog). If a policy with the same name exists, it is replaced.
- use_
named_ policy - Temporarily sets a high-level named retry policy after validating and flattening it into the raw WIT representation.
- use_
retry_ policy - Temporarily sets a named retry policy. When the returned guard is dropped, the previous policy with the same name is restored (or removed if it didn’t exist).
- with_
named_ policy - Executes the given function with a high-level named retry policy temporarily set.
- with_
named_ policy_ async - Executes the given async function with a high-level named retry policy temporarily set.
- with_
retry_ policy - Executes the given function with a named retry policy temporarily set.
- with_
retry_ policy_ async - Executes the given async function with a named retry policy temporarily set.