override the redundancy based on the resizer (#292)

Signed-off-by: பாலாஜி <rbalajis25@gmail.com>
This commit is contained in:
Captain Meow 2020-12-07 16:59:21 +05:30 committed by GitHub
parent a478cc66d8
commit bd6c1646dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions

View File

@ -314,6 +314,10 @@ impl Children {
} else {
self.redundancy = redundancy;
}
#[cfg(feature = "scaling")]
{
self.resizer.set_lower_bound(self.redundancy as u64);
}
self
}
@ -383,7 +387,8 @@ impl Children {
/// # }
/// ```
/// [`Resizer`]: ../resizer/struct.Resizer.html
pub fn with_resizer(mut self, resizer: OptimalSizeExploringResizer) -> Self {
pub fn with_resizer(mut self, mut resizer: OptimalSizeExploringResizer) -> Self {
self.redundancy = resizer.lower_bound() as usize;
self.resizer = Box::new(resizer);
self
}

View File

@ -112,9 +112,23 @@ impl OptimalSizeExploringResizer {
self.actor_stats.clone()
}
/// Returns lower bound of the number of actors in the scaling group.
pub(crate) fn lower_bound(&self) -> u64 {
self.lower_bound
}
/// Set lower bound of the autoscaling group.
pub(crate) fn set_lower_bound(&mut self, lower_bound: u64) {
self.lower_bound = lower_bound;
}
/// Overrides the minimal amount of actors available to use.
pub fn with_lower_bound(mut self, lower_bound: u64) -> Self {
self.lower_bound = lower_bound;
if lower_bound == u64::MIN {
self.lower_bound = lower_bound.saturating_add(1);
} else {
self.lower_bound = lower_bound;
}
self
}