refresh caches on create / update

This commit is contained in:
mbecker20
2024-06-02 01:07:53 -07:00
parent 2441bc8cbf
commit 037364068d
4 changed files with 20 additions and 2 deletions

View File

@@ -90,6 +90,7 @@ impl super::MonitorResource for Build {
_created: &Resource<Self::Config, Self::Info>,
_update: &mut Update,
) -> anyhow::Result<()> {
refresh_build_state_cache().await;
Ok(())
}
@@ -111,6 +112,7 @@ impl super::MonitorResource for Build {
_updated: &Self,
_update: &mut Update,
) -> anyhow::Result<()> {
refresh_build_state_cache().await;
Ok(())
}

View File

@@ -22,6 +22,8 @@ use crate::{
empty_or_only_spaces, periphery_client,
query::get_deployment_state,
},
monitor::update_cache_for_server,
resource,
state::{action_states, db_client, deployment_status_cache},
};
@@ -120,9 +122,14 @@ impl super::MonitorResource for Deployment {
}
async fn post_create(
_created: &Resource<Self::Config, Self::Info>,
created: &Resource<Self::Config, Self::Info>,
_update: &mut Update,
) -> anyhow::Result<()> {
if !created.config.server_id.is_empty() {
let server =
resource::get::<Server>(&created.config.server_id).await?;
update_cache_for_server(&server).await;
}
Ok(())
}
@@ -141,9 +148,14 @@ impl super::MonitorResource for Deployment {
}
async fn post_update(
_updated: &Self,
updated: &Self,
_update: &mut Update,
) -> anyhow::Result<()> {
if !updated.config.server_id.is_empty() {
let server =
resource::get::<Server>(&updated.config.server_id).await?;
update_cache_for_server(&server).await;
}
Ok(())
}

View File

@@ -90,6 +90,7 @@ impl super::MonitorResource for Procedure {
_created: &Resource<Self::Config, Self::Info>,
_update: &mut Update,
) -> anyhow::Result<()> {
refresh_procedure_state_cache().await;
Ok(())
}
@@ -111,6 +112,7 @@ impl super::MonitorResource for Procedure {
_updated: &Self,
_update: &mut Update,
) -> anyhow::Result<()> {
refresh_procedure_state_cache().await;
Ok(())
}

View File

@@ -99,6 +99,7 @@ impl super::MonitorResource for Repo {
_created: &Resource<Self::Config, Self::Info>,
_update: &mut Update,
) -> anyhow::Result<()> {
refresh_repo_state_cache().await;
Ok(())
}
@@ -120,6 +121,7 @@ impl super::MonitorResource for Repo {
_updated: &Self,
_update: &mut Update,
) -> anyhow::Result<()> {
refresh_repo_state_cache().await;
Ok(())
}