pub struct SpeculationController { /* private fields */ }Expand description
Runtime-neutral owner of one volume generation’s two speculation engines.
The controller performs no I/O and spawns no work. It gives embedded,
browser, daemon, and fleet adapters one atomic transition surface while
execution remains pull-based through execute_residency and
execute_promotion.
Implementations§
Source§impl SpeculationController
impl SpeculationController
Sourcepub fn new(
options: SpeculationOptions,
volume_id: VolumeId,
generation_id: GenerationId,
) -> Result<Self, SpeculationControllerError>
pub fn new( options: SpeculationOptions, volume_id: VolumeId, generation_id: GenerationId, ) -> Result<Self, SpeculationControllerError>
Creates both engines against the same exact volume generation.
§Errors
Rejects an invalid policy without retaining either partial engine.
Sourcepub fn observe_hint(
&mut self,
operation_id: OperationId,
volume_id: VolumeId,
generation_id: GenerationId,
foreground_bytes: u64,
hint: ResidencyHint,
) -> Result<ResidencyAdmission, SpeculationControllerError>
pub fn observe_hint( &mut self, operation_id: OperationId, volume_id: VolumeId, generation_id: GenerationId, foreground_bytes: u64, hint: ResidencyHint, ) -> Result<ResidencyAdmission, SpeculationControllerError>
Records foreground demand and evaluates its already-authenticated successor as one all-or-nothing transition.
§Errors
Leaves foreground history and admission state unchanged on exact accounting failure.
Sourcepub fn plan_promotion(
&mut self,
permit: ResidencyPermit,
accepted_tiers: Vec<StorageTier>,
residency: &[ObjectResidency],
destinations: &[PromotionDestination],
) -> Result<PromotionAdmission, SpeculationControllerError>
pub fn plan_promotion( &mut self, permit: ResidencyPermit, accepted_tiers: Vec<StorageTier>, residency: &[ObjectResidency], destinations: &[PromotionDestination], ) -> Result<PromotionAdmission, SpeculationControllerError>
Converts an admitted local prediction into a bounded promotion plan.
§Errors
Leaves promotion state unchanged on policy or accounting failure.
Sourcepub fn finish_residency(
&mut self,
operation_id: OperationId,
useful: bool,
) -> Result<(), SpeculationControllerError>
pub fn finish_residency( &mut self, operation_id: OperationId, useful: bool, ) -> Result<(), SpeculationControllerError>
Records terminal local-residency usefulness exactly once.
§Errors
Rejects unknown identities or accounting overflow without mutation.
Sourcepub fn finish_promotion(
&mut self,
operation_id: OperationId,
useful: bool,
) -> Result<(), SpeculationControllerError>
pub fn finish_promotion( &mut self, operation_id: OperationId, useful: bool, ) -> Result<(), SpeculationControllerError>
Records terminal promotion usefulness exactly once.
§Errors
Rejects unknown identities or accounting overflow without mutation.
Sourcepub fn preempt_for_foreground(
&mut self,
foreground_bytes: u64,
) -> Result<SpeculationPreemption, SpeculationControllerError>
pub fn preempt_for_foreground( &mut self, foreground_bytes: u64, ) -> Result<SpeculationPreemption, SpeculationControllerError>
Preempts both engines before recording new foreground traffic.
§Errors
Commits all cancellations and traffic together or changes neither engine.
Sourcepub fn replace_generation(
&mut self,
generation_id: GenerationId,
) -> Result<SpeculationPreemption, SpeculationControllerError>
pub fn replace_generation( &mut self, generation_id: GenerationId, ) -> Result<SpeculationPreemption, SpeculationControllerError>
Atomically fences both engines onto a new immutable generation.
§Errors
Leaves both engines on the old generation if either transition fails.
Sourcepub const fn metrics(&self) -> SpeculationMetrics
pub const fn metrics(&self) -> SpeculationMetrics
Returns both exact metrics from one committed controller state.
Sourcepub const fn residency(&self) -> &ResidencySpeculator
pub const fn residency(&self) -> &ResidencySpeculator
Borrows the local residency engine for pull-based execution.
Sourcepub const fn promotion(&self) -> &PromotionSpeculator
pub const fn promotion(&self) -> &PromotionSpeculator
Borrows the promotion engine for pull-based execution.
Sourcepub fn active_residency_permit(
&self,
operation_id: OperationId,
) -> Option<ResidencyPermit>
pub fn active_residency_permit( &self, operation_id: OperationId, ) -> Option<ResidencyPermit>
Returns one currently active local execution permit.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SpeculationController
impl RefUnwindSafe for SpeculationController
impl Send for SpeculationController
impl Sync for SpeculationController
impl Unpin for SpeculationController
impl UnsafeUnpin for SpeculationController
impl UnwindSafe for SpeculationController
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request