Skip to main content

CapacityAdaptiveRingSidecar

Struct CapacityAdaptiveRingSidecar 

Source
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

Source

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.

Source

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.

Source

pub fn morphs_triggered(&self) -> u64

Number of successful morphs triggered by this sidecar since spawn.

Source

pub fn prewarms_issued(&self) -> u64

Number of speculative backings this sidecar pre-built via predict trends since spawn.

Source

pub fn shutdown(self)

Stop the sidecar thread and wait for it to exit.

Trait Implementations§

Source§

impl Drop for CapacityAdaptiveRingSidecar

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

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.