pub struct ResizeCoalescer { /* private fields */ }Expand description
Adaptive resize stream coalescer.
Implements latest-wins coalescing with regime-aware behavior.
Implementations§
Source§impl ResizeCoalescer
impl ResizeCoalescer
Sourcepub fn new(config: CoalescerConfig, initial_size: (u16, u16)) -> Self
pub fn new(config: CoalescerConfig, initial_size: (u16, u16)) -> Self
Create a new coalescer with the given configuration and initial size.
Sourcepub fn with_telemetry_hooks(self, hooks: TelemetryHooks) -> Self
pub fn with_telemetry_hooks(self, hooks: TelemetryHooks) -> Self
Attach telemetry hooks for external observability.
Sourcepub fn with_evidence_sink(self, sink: EvidenceSink) -> Self
pub fn with_evidence_sink(self, sink: EvidenceSink) -> Self
Attach an evidence sink for JSONL decision logs.
Sourcepub fn with_evidence_run_id(self, run_id: impl Into<String>) -> Self
pub fn with_evidence_run_id(self, run_id: impl Into<String>) -> Self
Set the run identifier used in evidence logs.
Sourcepub fn with_screen_mode(self, screen_mode: ScreenMode) -> Self
pub fn with_screen_mode(self, screen_mode: ScreenMode) -> Self
Set the screen mode label used in evidence logs.
Sourcepub fn set_evidence_sink(&mut self, sink: Option<EvidenceSink>)
pub fn set_evidence_sink(&mut self, sink: Option<EvidenceSink>)
Set or clear the evidence sink.
Sourcepub fn with_last_render(self, time: Instant) -> Self
pub fn with_last_render(self, time: Instant) -> Self
Set the last render time (for deterministic testing).
Sourcepub fn record_external_apply(&mut self, width: u16, height: u16, now: Instant)
pub fn record_external_apply(&mut self, width: u16, height: u16, now: Instant)
Record an externally-applied resize (immediate path).
Sourcepub fn regime_transition_count(&self) -> u64
pub fn regime_transition_count(&self) -> u64
Get current regime transition count.
Sourcepub fn cycle_time_percentiles(&self) -> Option<CycleTimePercentiles>
pub fn cycle_time_percentiles(&self) -> Option<CycleTimePercentiles>
Get cycle time percentiles (p50, p95, p99) in milliseconds. Returns None if no cycle times recorded.
Sourcepub fn handle_resize(&mut self, width: u16, height: u16) -> CoalesceAction
pub fn handle_resize(&mut self, width: u16, height: u16) -> CoalesceAction
Handle a resize event.
Returns the action to take immediately.
Sourcepub fn handle_resize_at(
&mut self,
width: u16,
height: u16,
now: Instant,
) -> CoalesceAction
pub fn handle_resize_at( &mut self, width: u16, height: u16, now: Instant, ) -> CoalesceAction
Handle a resize event at a specific time (for testing).
Sourcepub fn tick(&mut self) -> CoalesceAction
pub fn tick(&mut self) -> CoalesceAction
Tick the coalescer (call each frame).
Returns the action to take.
Sourcepub fn tick_at(&mut self, now: Instant) -> CoalesceAction
pub fn tick_at(&mut self, now: Instant) -> CoalesceAction
Tick at a specific time (for testing).
Sourcepub fn time_until_apply(&self, now: Instant) -> Option<Duration>
pub fn time_until_apply(&self, now: Instant) -> Option<Duration>
Time until the pending resize should be applied.
Sourcepub fn has_pending(&self) -> bool
pub fn has_pending(&self) -> bool
Check if there’s a pending resize.
Sourcepub fn bocpd_enabled(&self) -> bool
pub fn bocpd_enabled(&self) -> bool
Check if BOCPD-based regime detection is enabled.
Sourcepub fn bocpd(&self) -> Option<&BocpdDetector>
pub fn bocpd(&self) -> Option<&BocpdDetector>
Get the BOCPD detector for inspection (if enabled).
Returns None if BOCPD is not enabled.
Sourcepub fn bocpd_p_burst(&self) -> Option<f64>
pub fn bocpd_p_burst(&self) -> Option<f64>
Get the current P(burst) from BOCPD (if enabled).
Returns the posterior probability that the system is in burst regime.
Returns None if BOCPD is not enabled.
Sourcepub fn bocpd_recommended_delay(&self) -> Option<u64>
pub fn bocpd_recommended_delay(&self) -> Option<u64>
Get the recommended delay from BOCPD (if enabled).
Returns the recommended coalesce delay in milliseconds based on the
current posterior distribution. Returns None if BOCPD is not enabled.
Sourcepub fn event_rate(&self) -> f64
pub fn event_rate(&self) -> f64
Get the current event rate (events/second).
Sourcepub fn last_applied(&self) -> (u16, u16)
pub fn last_applied(&self) -> (u16, u16)
Get the last applied size.
Sourcepub fn logs(&self) -> &[DecisionLog]
pub fn logs(&self) -> &[DecisionLog]
Get decision logs (if logging enabled).
Sourcepub fn clear_logs(&mut self)
pub fn clear_logs(&mut self)
Clear decision logs.
Sourcepub fn stats(&self) -> CoalescerStats
pub fn stats(&self) -> CoalescerStats
Get statistics about the coalescer.
Sourcepub fn decision_logs_jsonl(&self) -> String
pub fn decision_logs_jsonl(&self) -> String
Export decision logs as JSONL (one entry per line).
Sourcepub fn decision_checksum(&self) -> u64
pub fn decision_checksum(&self) -> u64
Compute a deterministic checksum of decision logs.
Sourcepub fn decision_checksum_hex(&self) -> String
pub fn decision_checksum_hex(&self) -> String
Compute checksum as hex string.
Sourcepub fn decision_summary(&self) -> DecisionSummary
pub fn decision_summary(&self) -> DecisionSummary
Compute a summary of the decision log.
Sourcepub fn evidence_to_jsonl(&self) -> String
pub fn evidence_to_jsonl(&self) -> String
Export config + decision logs + summary as JSONL.