pub struct AutoscaleConfig { /* private fields */ }Expand description
The autoscale half of PolicyMode.
Every field an Autoscale policy requires lives here, unconditionally. That
is the whole trick: there is no Option to be None and no separate
validator to forget, so “an autoscale policy with no capacity ceiling” is not
a state this program can hold in memory, let alone persist.
Implementations§
Source§impl AutoscaleConfig
impl AutoscaleConfig
Sourcepub fn new(
routing_labels: RoutingLabels,
min_capacity: u16,
max_capacity: NonZeroU16,
) -> Result<Self, PolicyError>
pub fn new( routing_labels: RoutingLabels, min_capacity: u16, max_capacity: NonZeroU16, ) -> Result<Self, PolicyError>
§Errors
PolicyError::InvertedCapacityRange when min > max. Validated here
so clamp(demand, min, max) in crate::capacity is always
well-defined — an inverted range makes clamp panic in Rust, so this is
not a stylistic check.
Sourcepub fn v1(
routing_labels: RoutingLabels,
max_capacity: NonZeroU16,
) -> Result<Self, PolicyError>
pub fn v1( routing_labels: RoutingLabels, max_capacity: NonZeroU16, ) -> Result<Self, PolicyError>
The v1 shape: min_capacity fixed at 0 (D7).
§Errors
Never fails, because 0 cannot exceed a NonZeroU16; the Result is
kept so that lifting the D7 restriction later is not a signature change.
pub fn routing_labels(&self) -> &RoutingLabels
pub fn routing_labels_mut(&mut self) -> &mut RoutingLabels
pub const fn min_capacity(&self) -> u16
pub const fn max_capacity(&self) -> NonZeroU16
Sourcepub fn set_max_capacity(
&mut self,
max_capacity: NonZeroU16,
) -> Result<(), PolicyError>
pub fn set_max_capacity( &mut self, max_capacity: NonZeroU16, ) -> Result<(), PolicyError>
§Errors
PolicyError::InvertedCapacityRange if the new ceiling is below the
existing floor.
Trait Implementations§
Source§impl Clone for AutoscaleConfig
impl Clone for AutoscaleConfig
Source§fn clone(&self) -> AutoscaleConfig
fn clone(&self) -> AutoscaleConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more