pub trait Producer: Send + Sync {
// Required methods
fn set_limit(&self, n: usize) -> Result<(), ResizeError>;
fn limit(&self) -> usize;
fn active_slots(&self) -> usize;
fn pressure(&self) -> ProducerPressure;
fn work(&self) -> Work;
// Provided methods
fn buffered_items(&self) -> Option<u64> { ... }
fn auxiliary_threads(&self) -> usize { ... }
fn set_measurement_mode(&self, _mode: ProducerMeasurementMode) { ... }
fn set_monitoring_interval(&self, _interval: Duration) { ... }
fn measurement_stats(&self) -> Option<ProducerMeasurementStats> { ... }
fn finish_measurement(&self) -> Option<ProducerMeasurementStats> { ... }
}Expand description
The side that produces decoded bytes: a decompressor or pool of them.
Required Methods§
Sourcefn set_limit(&self, n: usize) -> Result<(), ResizeError>
fn set_limit(&self, n: usize) -> Result<(), ResizeError>
Ask for an aggregate concurrency limit of n.
Returning success acknowledges the request, not the completion of work already admitted under the previous limit.
Sourcefn active_slots(&self) -> usize
fn active_slots(&self) -> usize
Slots executing producer work now.
This is the acknowledgement signal for a shrink. It must include work admitted before a lower limit was requested and exclude coordinator or I/O threads that do not consume controlled execution slots.
Sourcefn pressure(&self) -> ProducerPressure
fn pressure(&self) -> ProducerPressure
Why the producer is or is not keeping up.
Used only as a directional guard; it never selects a target. Source-bound
or inelastic evidence may cap growth. A live ProducerPressure::Starved
signal may veto a model-requested shrink while the current limit is
demonstrably occupied, which protects against allocation-dependent cost
under-reporting. That exception can retain the current split but cannot
grow it or choose a larger one. Pressure signals are deliberately not
used to size the split because they saturate: they cannot distinguish
“just enough” from “far too much”.
Provided Methods§
Sourcefn buffered_items(&self) -> Option<u64>
fn buffered_items(&self) -> Option<u64>
Current queued output in the same unit as Work::items, when known.
The controller rejects cost windows in which this buffer changes materially, because the two stages then processed different amounts of logical work and their busy-time ratio is not a per-item cost ratio.
Sourcefn auxiliary_threads(&self) -> usize
fn auxiliary_threads(&self) -> usize
Live auxiliary threads outside the controlled execution-slot budget.
Sourcefn set_measurement_mode(&self, _mode: ProducerMeasurementMode)
fn set_measurement_mode(&self, _mode: ProducerMeasurementMode)
Select how aggressively an adapter should observe producer busy time.
Calibration is requested only while the broker is gathering or ratifying cost evidence. Monitoring is requested while resizing, blacking out contaminated windows, or sitting at a settled split. The default is a no-op because producers with native cumulative counters do not need a sampling policy.
Sourcefn set_monitoring_interval(&self, _interval: Duration)
fn set_monitoring_interval(&self, _interval: Duration)
Suggest an observation interval while the broker is settled.
Producers with native cumulative counters may ignore this. An adapter that reconstructs busy time by polling should reduce its own observation rate when steady-state probes are far apart. It may clamp the request to the minimum cadence needed for a useful estimate.
Sourcefn measurement_stats(&self) -> Option<ProducerMeasurementStats>
fn measurement_stats(&self) -> Option<ProducerMeasurementStats>
Optional diagnostics for a sampled producer measurement.
Sourcefn finish_measurement(&self) -> Option<ProducerMeasurementStats>
fn finish_measurement(&self) -> Option<ProducerMeasurementStats>
Stop any private measurement adapter and return its final diagnostics.
The controller calls this exactly once when it exits. Native cumulative counters may use the default snapshot implementation. Sampled adapters should join their sampler here so lifetime CPU accounting is complete before the report is serialized.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".