Skip to main content

Policy

Trait Policy 

Source
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§

Source

fn authorize( &self, run_id: &RunId, action: &Action, ctx: &PolicyCtx, ) -> Result<(), KernelError>

Whether the action is allowed for this run and context.

Provided Methods§

Source

fn retry_strategy(&self, err: &dyn Display, _action: &Action) -> RetryDecision

Whether to retry after an error (and optionally after a delay).

Source

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.

Source

fn budget(&self) -> BudgetRules

Optional budget; default is no limits.

Implementors§