/// Applies checks and does scaling up/down depends on stats.
Applies checks and does scaling up/down depends on stats.
Applies checks and does scaling up / down depends on stats .
pub(crate) async fn scale(
        &self,
        actors: &FxHashMap<BastionId, (Sender, RecoverableHandle<()>)>,
    ) -> ScalingRule {
        // Do a pre-check before doing a scaling up/down: need to ensure that
        // we always have a minimum amount of actors in runtime, in according
        // to the specified lower_bound parameter
        let active_actors_count = actors.len() as u64;
        if active_actors_count < self.lower_bound {
            let additional_actors_count = self.lower_bound - active_actors_count;
            return ScalingRule::Upscale(additional_actors_count);
        }
        let mut stats = ActorGroupStats::load(self.stats.clone());
        if let Some(scaling_rule) = self.do_upscaling(&mut stats, actors) {
            return scaling_rule;
        }
        if let Some(scaling_rule) = self.do_downscaling(&mut stats, actors) {
            return scaling_rule;
        }
        ScalingRule::DoNothing
    }
pub ( crate ) async fn scale ( & self , actors : & FxHashMap < BastionId , ( Sender , RecoverableHandle < ( ) > ) > , ) -> ScalingRule { // Do a pre-check before doing a scaling up/down: need to ensure that // we always have a minimum amount of actors in runtime, in according // to the specified lower_bound parameter let active_actors_count = actors . len ( ) as u64 ; if active_actors_count < self . lower_bound { let additional_actors_count = self . lower_bound - active_actors_count ; return ScalingRule :: Upscale ( additional_actors_count ) ; } let mut stats = ActorGroupStats :: load ( self . stats . clone ( ) ) ; if let Some ( scaling_rule ) = self . do_upscaling ( & mut stats , actors ) { return scaling_rule ; } if let Some ( scaling_rule ) = self . do_downscaling ( & mut stats , actors ) { return scaling_rule ; } ScalingRule :: DoNothing }
Applies checks and does scaling up/down depends on stats.
Applies checks and does scaling up / down depends on stats .
&self
actors
&FxHashMap<BastionId, (Sender, RecoverableHandle<()>)>