pub struct IdempotentConsumerSegment { /* private fields */ }Expand description
Outcome-aware Idempotent Consumer segment.
Wraps a child sub-pipeline (OutcomeSegment) and a named
IdempotentRepository. On each exchange:
- Extract message-id via
message_id(&exchange).None→ forward to child. - Check
repo.contains(&key):Ok(true)→ duplicate, returnCompleted(exchange)(skip child).Ok(false)→ proceed.Err(e)→Failed(e)(contract C1).
- If
eager:repo.add(&key)before child.Ok(false)= race duplicate →Completed.Err→Failed. - Run child pipeline.
- Post-child:
Completed+ non-eager →repo.add(&key)(best-effort).Stopped→ no add (pipeline terminating).Failed+eager+remove_on_failure→repo.remove(&key)(best-effort).
§Eager mode + Stopped
In eager mode, the key is added BEFORE the child pipeline runs. If the child
returns Stopped, the key remains registered — subsequent deliveries of the
same message ID are treated as duplicates and return Completed immediately.
This is intentional: a Stop indicates the route chose to terminate, and
re-processing the same message would be incorrect.
Implementations§
Source§impl IdempotentConsumerSegment
impl IdempotentConsumerSegment
Sourcepub fn new(
repository: Arc<dyn IdempotentRepository>,
message_id: MessageIdExpression,
child_pipeline: OutcomeSegment,
eager: bool,
remove_on_failure: bool,
) -> Self
pub fn new( repository: Arc<dyn IdempotentRepository>, message_id: MessageIdExpression, child_pipeline: OutcomeSegment, eager: bool, remove_on_failure: bool, ) -> Self
Build a new segment from a resolved repository, message-id extractor, child sub-pipeline, and behaviour flags.
Trait Implementations§
Source§impl Clone for IdempotentConsumerSegment
impl Clone for IdempotentConsumerSegment
Source§impl OutcomePipeline for IdempotentConsumerSegment
impl OutcomePipeline for IdempotentConsumerSegment
Source§fn clone_box(&self) -> Box<dyn OutcomePipeline>
fn clone_box(&self) -> Box<dyn OutcomePipeline>
Clone the segment into a new boxed instance. Required because
Box<dyn OutcomePipeline> cannot directly derive Clone.Auto Trait Implementations§
impl !RefUnwindSafe for IdempotentConsumerSegment
impl !Sync for IdempotentConsumerSegment
impl !UnwindSafe for IdempotentConsumerSegment
impl Freeze for IdempotentConsumerSegment
impl Send for IdempotentConsumerSegment
impl Unpin for IdempotentConsumerSegment
impl UnsafeUnpin for IdempotentConsumerSegment
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