Skip to main content

SharedConsumer

Struct SharedConsumer 

Source
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§

Source§

impl<E> SharedConsumer<E>
where E: Copy + Default,

Source

pub fn signal_readiness(&self)

Signal consumer readiness (internal coordination) This is called automatically when the consumer is created

Source

pub fn try_attach_coordination(&mut self, base_name: &str) -> bool

Try to attach to coordination structure (retry mechanism for timing issues)

Source

pub fn has_coordination_support(&self) -> bool

Check if this consumer has coordination support

Source

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.

Source

pub fn attach_counters_selected( &mut self, file: &CountersFile, selection: ConsumerCounterSelection, )

Register a selected subset of consumer counters in the supplied counters file.

Source

pub fn counters(&self) -> &ConsumerCounters

Read-only access to the consumer’s attached counters.

Source

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.

Source

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

Source

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.

Source

pub fn consume_next(&mut self) -> (Sequence, E)

Wait for and consume the next event (blocking) Returns the sequence and event data

Source

pub fn consume_next_leased(&mut self) -> SharedConsumerLease<'_, E>

Wait for and lease the next event (blocking).

Source

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

Source

pub fn consume_next_leased_with_sleep(&mut self) -> SharedConsumerLease<'_, E>

Wait for and lease the next event (blocking with sleep for CPU efficiency).

Source

pub fn process_next_blocking<F>(&mut self, processor: F) -> (Sequence, bool)
where F: FnMut(&E, 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

Source

pub fn process_next_blocking_with_sleep<F>( &mut self, processor: F, ) -> (Sequence, bool)
where F: FnMut(&E, 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

Source

pub fn process_available_blocking<F>(&mut self, processor: F) -> usize
where F: FnMut(&E, Sequence, bool),

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

Source

pub fn process_available<F>(&mut self, processor: F) -> usize
where F: FnMut(&E, Sequence),

Process available events with a callback function Returns the number of events processed by this consumer

Source

pub fn current_sequence(&self) -> Sequence

Get the last sequence processed by this consumer

Source

pub fn producer_sequence(&self) -> Sequence

Get the current producer sequence (for debugging)

Source

pub fn consumer_sequence(&self) -> Sequence

Get this consumer’s sequence (for debugging)

Source

pub fn debug_sequences(&self) -> (Sequence, Sequence, Sequence)

Get debug information about sequences

Source

pub fn consumer_id(&self) -> &str

Get consumer ID

Auto Trait Implementations§

§

impl<E> Freeze for SharedConsumer<E>

§

impl<E> !RefUnwindSafe for SharedConsumer<E>

§

impl<E> Send for SharedConsumer<E>

§

impl<E> Sync for SharedConsumer<E>

§

impl<E> Unpin for SharedConsumer<E>

§

impl<E> UnsafeUnpin for SharedConsumer<E>

§

impl<E> !UnwindSafe for SharedConsumer<E>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V