Skip to content

Commit 81d754d

Browse files
Merge pull request #183 from ahmedtadde/feat/simplify-adding-scaler-for-scale-manager
Refactor manifest upgrade for more efficient scaler computation
2 parents 4813b4f + 261dae2 commit 81d754d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/scaler/manager.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,11 @@ where
248248
/// This only constructs the scalers and doesn't reconcile. The returned [`Scalers`] type can be
249249
/// used to set this model to backoff mode
250250
#[instrument(level = "trace", skip_all, fields(name = %manifest.metadata.name, lattice_id = %self.lattice_id))]
251-
pub async fn add_scalers<'a>(&'a self, manifest: &'a Manifest) -> Result<Scalers> {
252-
let scalers = self.scalers_for_manifest(manifest);
251+
pub async fn add_scalers<'a>(
252+
&'a self,
253+
manifest: &'a Manifest,
254+
scalers: ScalerList,
255+
) -> Result<Scalers> {
253256
self.add_raw_scalers(&manifest.metadata.name, scalers).await;
254257
let notification = serde_json::to_vec(&Notifications::CreateScalers(manifest.to_owned()))?;
255258
self.client

src/workers/event.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,8 +793,7 @@ where
793793
// redelivered. When it is, the ones that succeeded will be in backoff mode and the ones
794794
// that failed will be retried.
795795

796-
// TODO: inefficient to compute scalers twice, consider refactoring
797-
let scalers = self.scalers.add_scalers(&data.manifest).await?;
796+
let scalers = self.scalers.add_scalers(&data.manifest, scalers).await?;
798797

799798
let (commands, res) = get_commands_and_result(
800799
scalers.iter().map(|s| s.reconcile()),

0 commit comments

Comments
 (0)