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 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.
Auto Trait Implementations§
impl<'a, S> !RefUnwindSafe for CompensationBuilder<'a, S>
impl<'a, S> !UnwindSafe for CompensationBuilder<'a, S>
impl<'a, S> Freeze for CompensationBuilder<'a, S>
impl<'a, S> Send for CompensationBuilder<'a, S>
impl<'a, S> Sync for CompensationBuilder<'a, S>
impl<'a, S> Unpin for CompensationBuilder<'a, S>
impl<'a, S> UnsafeUnpin for CompensationBuilder<'a, S>where
&'a Runtime<S>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more