pub trait Policy: Send + Sync {
// Required method
fn authorize(
&self,
run_id: &RunId,
action: &Action,
ctx: &PolicyCtx,
) -> Result<(), KernelError>;
// Provided methods
fn retry_strategy(
&self,
err: &dyn Display,
_action: &Action,
) -> RetryDecision { ... }
fn retry_strategy_attempt(
&self,
err: &ActionError,
action: &Action,
attempt: u32,
) -> RetryDecision { ... }
fn budget(&self) -> BudgetRules { ... }
}Expand description
Policy: authorize actions, decide retries, optional budget.
Required Methods§
Whether the action is allowed for this run and context.
Provided Methods§
Sourcefn retry_strategy(&self, err: &dyn Display, _action: &Action) -> RetryDecision
fn retry_strategy(&self, err: &dyn Display, _action: &Action) -> RetryDecision
Whether to retry after an error (and optionally after a delay).
Sourcefn retry_strategy_attempt(
&self,
err: &ActionError,
action: &Action,
attempt: u32,
) -> RetryDecision
fn retry_strategy_attempt( &self, err: &ActionError, action: &Action, attempt: u32, ) -> RetryDecision
Retry strategy with attempt count and structured error. Default uses kind: Permanent => Fail,
others may be retried by implementations. Applies only to executor Err; ActionResult::Failure is not retried.
attempt is the 0-based count of failures so far. Return Fail when no more retries are desired.
Sourcefn budget(&self) -> BudgetRules
fn budget(&self) -> BudgetRules
Optional budget; default is no limits.