pub struct CapacityAdaptiveRingSidecar { /* private fields */ }Expand description
Background scanner thread that drives capacity morphs on a
CapacityAdaptiveRing from a CapacityPolicy.
spawn starts the thread; shutdown stops it. The thread
scans every scan_interval, builds a
CapacityPolicyObservation, asks the policy, and calls
CapacityAdaptiveRing::morph_capacity_to on Some(new_capacity)
responses. Successful morphs increment the per-sidecar
morphs_triggered counter.
Implementations§
Source§impl CapacityAdaptiveRingSidecar
impl CapacityAdaptiveRingSidecar
Sourcepub fn spawn<P: CapacityPolicy>(
ring: Arc<CapacityAdaptiveRing>,
policy: P,
scan_interval: Duration,
) -> Self
pub fn spawn<P: CapacityPolicy>( ring: Arc<CapacityAdaptiveRing>, policy: P, scan_interval: Duration, ) -> Self
Spawn a sidecar thread that morphs ring according to
policy decisions sampled every scan_interval.
Prediction wiring: when policy.predict names the same
target on two consecutive scans (a sustained trend, not a
one-scan blip), the sidecar pre-builds that backing via
CapacityAdaptiveRing::prewarm - off the morph lock, on
this thread’s idle time - so the eventual decide-driven
morph consumes it instead of allocating on the critical
path. Policies whose predict returns None (the trait
default) get today’s behavior exactly.
Sourcepub fn spawn_gated<P: CapacityPolicy>(
ring: Arc<CapacityAdaptiveRing>,
policy: P,
scan_interval: Duration,
gate_cfg: GateConfig,
) -> Self
pub fn spawn_gated<P: CapacityPolicy>( ring: Arc<CapacityAdaptiveRing>, policy: P, scan_interval: Duration, gate_cfg: GateConfig, ) -> Self
As spawn with a confidence gate between the
policy’s recommendation and the morph. With
gate_cfg.enabled == false (the default) behavior is
identical to spawn. Enabled, a recommendation must hold
across consecutive scans until conviction crosses the
gate’s threshold (and any sample floor); recommendation
reversals, peer-count changes, and fill-ratio jumps collapse
conviction, so oscillating load starves the gate instead of
thrashing the ring.
Sourcepub fn morphs_triggered(&self) -> u64
pub fn morphs_triggered(&self) -> u64
Number of successful morphs triggered by this sidecar
since spawn.
Sourcepub fn prewarms_issued(&self) -> u64
pub fn prewarms_issued(&self) -> u64
Number of speculative backings this sidecar pre-built via
predict trends since spawn.