pub struct CompensationBuilder<'a, S> { /* private fields */ }Expand description
Undoes a closure effect. Created by Runtime::compensation.
Implementations§
Source§impl<'a, S: EffectStore> CompensationBuilder<'a, S>
impl<'a, S: EffectStore> CompensationBuilder<'a, S>
Sourcepub fn output_schema(self, schema: PayloadSchema) -> Self
pub fn output_schema(self, schema: PayloadSchema) -> Self
Interprets or migrates the stored output before invoking compensation. Unsupported payloads never invoke the application’s compensation.
Sourcepub fn reason(self, reason: impl Into<String>) -> Self
pub fn reason(self, reason: impl Into<String>) -> Self
Why the effect is being undone; recorded in the audit trail.
Sourcepub fn actor(self, actor: impl Into<String>) -> Self
pub fn actor(self, actor: impl Into<String>) -> Self
Who is undoing it, e.g. agent:support-bot.
Sourcepub fn retry(self, policy: RetryPolicy) -> Self
pub fn retry(self, policy: RetryPolicy) -> Self
The retry policy for compensation attempts; defaults to the
runtime’s. Its max_attempts bounds attempts over the compensation’s
life.
Sourcepub fn attempt_timeout(self, timeout: Duration) -> Self
pub fn attempt_timeout(self, timeout: Duration) -> Self
Gives up waiting for one attempt after timeout, and retries.
Sourcepub async fn run<T, F, Fut>(
self,
compensate: F,
) -> Result<CompensationOutcome, RuntimeError>where
T: DeserializeOwned + Send + 'static,
F: Fn(CompensationContext, Option<T>) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<(), EffectFailure>> + Send + 'static,
pub async fn run<T, F, Fut>(
self,
compensate: F,
) -> Result<CompensationOutcome, RuntimeError>where
T: DeserializeOwned + Send + 'static,
F: Fn(CompensationContext, Option<T>) -> Fut + Send + Sync + 'static,
Fut: Future<Output = Result<(), EffectFailure>> + Send + 'static,
Undoes the effect with compensate, which receives the effect’s
stored output (None if it had none). Calling again after it is
undone returns CompensationOutcome::Compensated without running
anything.
§Errors
Infrastructure failures, an invalid name or key, or no such effect.