pub trait Strategy: Send + Sync {
// Required method
fn desired_replicas(
&self,
state: &ClusterState,
signals: &LiveSignals,
config: &ConfigSignals,
now: Timestamp,
) -> Vec<DesiredReplica>;
// Provided methods
fn signal_request(
&self,
_state: &ClusterState,
_config: &ConfigSignals,
) -> SignalRequest { ... }
fn update_state(
&self,
_state: &ClusterState,
_signals: &LiveSignals,
_config: &ConfigSignals,
_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 desired_replicas(
&self,
state: &ClusterState,
signals: &LiveSignals,
config: &ConfigSignals,
now: Timestamp,
) -> Vec<DesiredReplica>
fn desired_replicas( &self, state: &ClusterState, signals: &LiveSignals, config: &ConfigSignals, now: Timestamp, ) -> Vec<DesiredReplica>
The replica slots this strategy contributes to state’s desired set at
time now.
Provided Methods§
Sourcefn signal_request(
&self,
_state: &ClusterState,
_config: &ConfigSignals,
) -> SignalRequest
fn signal_request( &self, _state: &ClusterState, _config: &ConfigSignals, ) -> SignalRequest
The live signals this strategy needs to evaluate state this tick,
declared as a pure function of the durable state and the tick’s config
signals. The kernel unions the requests across strategies, fetches them
through the ctx, and passes the result to Strategy::update_state and
Strategy::desired_replicas. The default requests nothing, which suits
a strategy that works off durable state alone (like the baseline).
Sourcefn update_state(
&self,
_state: &ClusterState,
_signals: &LiveSignals,
_config: &ConfigSignals,
_now: Timestamp,
) -> StateWrite
fn update_state( &self, _state: &ClusterState, _signals: &LiveSignals, _config: &ConfigSignals, _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). An empty StateWrite means “write
nothing”: the kernel drops it without emitting a decision.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".