Skip to content

Commit

Permalink
Merge pull request #183 from ahmedtadde/feat/simplify-adding-scaler-f…
Browse files Browse the repository at this point in the history
…or-scale-manager

Refactor manifest upgrade for more efficient scaler computation
  • Loading branch information
thomastaylor312 authored Sep 22, 2023
2 parents 4813b4f + 261dae2 commit 81d754d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/scaler/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,11 @@ where
/// This only constructs the scalers and doesn't reconcile. The returned [`Scalers`] type can be
/// used to set this model to backoff mode
#[instrument(level = "trace", skip_all, fields(name = %manifest.metadata.name, lattice_id = %self.lattice_id))]
pub async fn add_scalers<'a>(&'a self, manifest: &'a Manifest) -> Result<Scalers> {
let scalers = self.scalers_for_manifest(manifest);
pub async fn add_scalers<'a>(
&'a self,
manifest: &'a Manifest,
scalers: ScalerList,
) -> Result<Scalers> {
self.add_raw_scalers(&manifest.metadata.name, scalers).await;
let notification = serde_json::to_vec(&Notifications::CreateScalers(manifest.to_owned()))?;
self.client
Expand Down
3 changes: 1 addition & 2 deletions src/workers/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,8 +793,7 @@ where
// redelivered. When it is, the ones that succeeded will be in backoff mode and the ones
// that failed will be retried.

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

let (commands, res) = get_commands_and_result(
scalers.iter().map(|s| s.reconcile()),
Expand Down

0 comments on commit 81d754d

Please sign in to comment.