pub struct SharedConsumer<E> { /* private fields */ }Expand description
Consumer for multi-process disruptor with broadcast semantics Each consumer maintains its own sequence and sees all events
Implementations§
Sourcepub fn signal_readiness(&self)
pub fn signal_readiness(&self)
Signal consumer readiness (internal coordination) This is called automatically when the consumer is created
Sourcepub fn try_attach_coordination(&mut self, base_name: &str) -> bool
pub fn try_attach_coordination(&mut self, base_name: &str) -> bool
Try to attach to coordination structure (retry mechanism for timing issues)
Sourcepub fn has_coordination_support(&self) -> bool
pub fn has_coordination_support(&self) -> bool
Check if this consumer has coordination support
Sourcepub fn attach_counters(&mut self, file: &CountersFile)
pub fn attach_counters(&mut self, file: &CountersFile)
Register consumer counters in the supplied counters file and
store handles on this consumer. After this call, hot-path
try_consume_next operations record into the file with one
relaxed atomic increment per event. RFC 0040 §Counters.
Sourcepub fn attach_counters_selected(
&mut self,
file: &CountersFile,
selection: ConsumerCounterSelection,
)
pub fn attach_counters_selected( &mut self, file: &CountersFile, selection: ConsumerCounterSelection, )
Register a selected subset of consumer counters in the supplied counters file.
Sourcepub fn counters(&self) -> &ConsumerCounters
pub fn counters(&self) -> &ConsumerCounters
Read-only access to the consumer’s attached counters.
Sourcepub fn record_consume_latency_ns(&self, ns: u64)
pub fn record_consume_latency_ns(&self, ns: u64)
Record a consume-side latency sample (nanoseconds) through the
metrics-rs facade under the histogram name
disruptor_mp_consume_latency_ns. The downstream recorder
(Prometheus / OTLP / Debugging) decides how to aggregate the
distribution.
Cost: one metrics::histogram! call (per-process recorder
dispatch). When no recorder is installed the call is a no-op.
When the metrics feature is off this method compiles to a
no-op; it stays in the API so call-sites don’t need to be
cfg-gated.
Sourcepub fn try_consume_next(&mut self) -> Option<(Sequence, E)>
pub fn try_consume_next(&mut self) -> Option<(Sequence, E)>
Try to consume the next available event for this consumer Returns None if no new events are available
Sourcepub fn try_consume_next_leased(&mut self) -> Option<SharedConsumerLease<'_, E>>
pub fn try_consume_next_leased(&mut self) -> Option<SharedConsumerLease<'_, E>>
Try to lease the next available event without copying it out of the ring slot.
The returned lease publishes consumer progress only when dropped, which keeps the backing slot valid for the lease lifetime.
Sourcepub fn consume_next(&mut self) -> (Sequence, E)
pub fn consume_next(&mut self) -> (Sequence, E)
Wait for and consume the next event (blocking) Returns the sequence and event data
Sourcepub fn consume_next_leased(&mut self) -> SharedConsumerLease<'_, E>
pub fn consume_next_leased(&mut self) -> SharedConsumerLease<'_, E>
Wait for and lease the next event (blocking).
Sourcepub fn consume_next_with_sleep(&mut self) -> (Sequence, E)
pub fn consume_next_with_sleep(&mut self) -> (Sequence, E)
Wait for and consume the next event (blocking with sleep for CPU efficiency) Returns the sequence and event data Use this when you want better CPU efficiency at the cost of throughput
Sourcepub fn consume_next_leased_with_sleep(&mut self) -> SharedConsumerLease<'_, E>
pub fn consume_next_leased_with_sleep(&mut self) -> SharedConsumerLease<'_, E>
Wait for and lease the next event (blocking with sleep for CPU efficiency).
Sourcepub fn process_next_blocking<F>(&mut self, processor: F) -> (Sequence, bool)
pub fn process_next_blocking<F>(&mut self, processor: F) -> (Sequence, bool)
Process next available event with blocking semantics (HIGH PERFORMANCE)
This method blocks until an event is available, then processes it
Uses spin_loop() for maximum throughput (CPU intensive)
Returns the sequence and whether this was the end of a batch
Sourcepub fn process_next_blocking_with_sleep<F>(
&mut self,
processor: F,
) -> (Sequence, bool)
pub fn process_next_blocking_with_sleep<F>( &mut self, processor: F, ) -> (Sequence, bool)
Process next available event with blocking semantics (CPU EFFICIENT)
This method blocks until an event is available, then processes it
Uses sleep() for better CPU efficiency (lower throughput)
Returns the sequence and whether this was the end of a batch
Sourcepub fn process_available_blocking<F>(&mut self, processor: F) -> usize
pub fn process_available_blocking<F>(&mut self, processor: F) -> usize
Process available events with blocking semantics + batch processing (HIGH PERFORMANCE) This method blocks until at least one event is available, then processes ALL available events This matches the performance characteristics of manual polling by processing in batches Returns the number of events processed
Sourcepub fn process_available<F>(&mut self, processor: F) -> usize
pub fn process_available<F>(&mut self, processor: F) -> usize
Process available events with a callback function Returns the number of events processed by this consumer
Sourcepub fn current_sequence(&self) -> Sequence
pub fn current_sequence(&self) -> Sequence
Get the last sequence processed by this consumer
Sourcepub fn producer_sequence(&self) -> Sequence
pub fn producer_sequence(&self) -> Sequence
Get the current producer sequence (for debugging)
Sourcepub fn consumer_sequence(&self) -> Sequence
pub fn consumer_sequence(&self) -> Sequence
Get this consumer’s sequence (for debugging)
Sourcepub fn debug_sequences(&self) -> (Sequence, Sequence, Sequence)
pub fn debug_sequences(&self) -> (Sequence, Sequence, Sequence)
Get debug information about sequences
Sourcepub fn consumer_id(&self) -> &str
pub fn consumer_id(&self) -> &str
Get consumer ID