pub struct ResourceScaler { /* private fields */ }Expand description
Manager for dynamic resource scaling.
Implementations§
Source§impl ResourceScaler
impl ResourceScaler
Sourcepub fn with_cooldown_ms(self, ms: u64) -> Self
pub fn with_cooldown_ms(self, ms: u64) -> Self
Set the cooldown period between scaling events.
Sourcepub fn set_policy(&mut self, resource_id: ResourceId, policy: ScalingPolicy)
pub fn set_policy(&mut self, resource_id: ResourceId, policy: ScalingPolicy)
Register a scaling policy for a resource.
Sourcepub fn evaluate(&self, resource: &ResourceDescriptor) -> ScalingAction
pub fn evaluate(&self, resource: &ResourceDescriptor) -> ScalingAction
Evaluate whether a resource should be scaled.
Sourcepub fn apply(
&mut self,
pool: &mut ResourcePool,
resource_id: &ResourceId,
now_ms: u64,
) -> Option<ScalingEvent>
pub fn apply( &mut self, pool: &mut ResourcePool, resource_id: &ResourceId, now_ms: u64, ) -> Option<ScalingEvent>
Apply a scaling action to a resource pool, respecting cooldown.
Returns true if the action was applied, false if skipped (cooldown).
Sourcepub fn history(&self) -> &[ScalingEvent]
pub fn history(&self) -> &[ScalingEvent]
Get scaling history.
Sourcepub fn history_for(&self, resource_id: &ResourceId) -> Vec<&ScalingEvent>
pub fn history_for(&self, resource_id: &ResourceId) -> Vec<&ScalingEvent>
Get history for a specific resource.
Sourcepub fn policy_count(&self) -> usize
pub fn policy_count(&self) -> usize
Number of registered policies.
Trait Implementations§
Source§impl Debug for ResourceScaler
impl Debug for ResourceScaler
Auto Trait Implementations§
impl Freeze for ResourceScaler
impl RefUnwindSafe for ResourceScaler
impl Send for ResourceScaler
impl Sync for ResourceScaler
impl Unpin for ResourceScaler
impl UnsafeUnpin for ResourceScaler
impl UnwindSafe for ResourceScaler
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
Mutably borrows from an owned value. Read more