mirror of https://github.com/bastion-rs/bastion
override the redundancy based on the resizer (#292)
Signed-off-by: பாலாஜி <rbalajis25@gmail.com>
This commit is contained in:
parent
a478cc66d8
commit
bd6c1646dd
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue