Skip to main content

Strategy

Trait Strategy 

Source
pub trait Strategy: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn desired_replicas(
        &self,
        state: &ClusterState,
        signals: &LiveSignals,
        now: Timestamp,
    ) -> Vec<DesiredReplica>;

    // Provided methods
    fn signal_request(&self, _state: &ClusterState) -> SignalRequest { ... }
    fn update_state(
        &self,
        _state: &ClusterState,
        _signals: &LiveSignals,
        _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§

Source

fn name(&self) -> &'static str

A stable identifier used in audit attribution (which strategies desired a create; drops carry no attribution).

Source

fn desired_replicas( &self, state: &ClusterState, signals: &LiveSignals, now: Timestamp, ) -> Vec<DesiredReplica>

The replica slots this strategy contributes to state’s desired set at time now.

Provided Methods§

Source

fn signal_request(&self, _state: &ClusterState) -> SignalRequest

The live signals this strategy needs to evaluate state this tick, declared as a pure function of the durable state. 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).

Source

fn update_state( &self, _state: &ClusterState, _signals: &LiveSignals, _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".

Implementors§