pub trait Consumer: Send + Sync {
// Required methods
fn set_threads(&self, n: usize) -> Result<(), ResizeError>;
fn live_threads(&self) -> usize;
fn work(&self) -> Work;
// Provided method
fn set_measurement_mode(&self, _mode: ProducerMeasurementMode) { ... }
}Expand description
The side that consumes decoded bytes: mapping, aligning, counting.
Implementors resize a worker pool and report how much work it has done.
Required Methods§
Sourcefn set_threads(&self, n: usize) -> Result<(), ResizeError>
fn set_threads(&self, n: usize) -> Result<(), ResizeError>
Ask for n worker threads. May take effect gradually.
Returning success acknowledges the request, not its completion. The
broker observes Self::live_threads before spending the released
capacity on the producer.
Sourcefn live_threads(&self) -> usize
fn live_threads(&self) -> usize
Workers actually running now, which may lag what was asked for.
Diagnostic only, and deliberately not “the target”: the broker tracks what it asked for itself. The gap between the two is what you want in a log when a split looks wrong, because it separates “the broker decided badly” from “the broker decided well and the pool has not caught up”. Reporting the target here would hide exactly that distinction.
Sourcefn work(&self) -> Work
fn work(&self) -> Work
Cumulative work. See Work for the two contracts that matter.
Publish more often than once per batch. A counter updated only at batch
boundaries cannot be sampled faster than a batch completes, and a window
containing no completed batch reads as zero work — indistinguishable
from a totally idle consumer, and reporting maximum starvation for one
running flat out. BusyMeter handles this.
Provided Methods§
Sourcefn set_measurement_mode(&self, _mode: ProducerMeasurementMode)
fn set_measurement_mode(&self, _mode: ProducerMeasurementMode)
Switch instrumentation between decision-quality and settled cadence.
Most consumers can leave this as a no-op. Consumers for which publishing progress is itself measurable work may use a finer cadence only while a decision is open and a coarser cadence in steady state.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".