pub struct SideEffectGuard { /* private fields */ }Expand description
Guard that tracks whether side effects should be executed.
During normal indexing, side effects (webhooks, external API calls) are executed. During replay after a reorg, side effects are skipped because they were already executed during the original processing.
§Example
use chainindex_core::idempotency::{ReplayContext, SideEffectGuard};
let ctx = ReplayContext::normal();
let guard = SideEffectGuard::new(&ctx);
assert!(guard.should_execute()); // normal mode: execute side effects
let replay_ctx = ReplayContext::replay(100, None);
let replay_guard = SideEffectGuard::new(&replay_ctx);
assert!(!replay_guard.should_execute()); // replay mode: skip side effectsImplementations§
Source§impl SideEffectGuard
impl SideEffectGuard
Sourcepub fn new(replay_ctx: &ReplayContext) -> Self
pub fn new(replay_ctx: &ReplayContext) -> Self
Create a new guard based on the replay context.
Side effects are skipped when replay_ctx.is_replay is true.
Sourcepub fn should_execute(&self) -> bool
pub fn should_execute(&self) -> bool
Returns true if side effects should be executed (not in replay mode).
Auto Trait Implementations§
impl Freeze for SideEffectGuard
impl RefUnwindSafe for SideEffectGuard
impl Send for SideEffectGuard
impl Sync for SideEffectGuard
impl Unpin for SideEffectGuard
impl UnsafeUnpin for SideEffectGuard
impl UnwindSafe for SideEffectGuard
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