pub trait Strategy: Send + Sync {
// Required methods
fn name(&self) -> &'static str;
fn desired_replicas(
&self,
state: &ClusterState,
now: Timestamp,
) -> Vec<DesiredReplica>;
// Provided method
fn update_state(&self, _state: &ClusterState, _now: Timestamp) -> StateWrite { ... }
}Expand description
One cluster-autoscaling strategy: a pair of pure functions the controller runs each tick. See the module docs.
Send + Sync so the controller (which holds a set of boxed strategies) can
run on its own task.
Required Methods§
Sourcefn name(&self) -> &'static str
fn name(&self) -> &'static str
A stable identifier used in audit attribution (which strategies desired a create; drops carry no attribution).
Sourcefn desired_replicas(
&self,
state: &ClusterState,
now: Timestamp,
) -> Vec<DesiredReplica>
fn desired_replicas( &self, state: &ClusterState, now: Timestamp, ) -> Vec<DesiredReplica>
The replica slots this strategy contributes to state’s desired set at
time now.
Provided Methods§
Sourcefn update_state(&self, _state: &ClusterState, _now: Timestamp) -> StateWrite
fn update_state(&self, _state: &ClusterState, _now: Timestamp) -> StateWrite
The durable writes this strategy wants for state at time now. The
default is no write, which suits a strategy that only ever contributes
replicas (like the baseline).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".