Skip to content

Commit

Permalink
spi-stats:fix schedule callback_headers Tardis-Context.
Browse files Browse the repository at this point in the history
  • Loading branch information
ljl committed Dec 11, 2024
1 parent bbaafed commit b539aba
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions backend/spi/spi-stats/src/serv/pg/stats_pg_conf_fact_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tardis::{
sea_orm::Value,
},
web::web_resp::TardisPage,
TardisFunsInst,
TardisFuns, TardisFunsInst,
};

use crate::{
Expand Down Expand Up @@ -71,6 +71,8 @@ VALUES
.await?;
conn.commit().await?;
//handle sync fact task
let mut callback_headers: HashMap<String, String> = HashMap::new();
callback_headers.insert("Tardis-Context".to_string(), TardisFuns::crypto.base64.encode(TardisFuns::json.obj_to_string(&ctx)?));
ScheduleClient::add_or_modify_sync_task(
AddOrModifySyncTaskReq {
code: format!("{}_{}", SYNC_FACT_TASK_CODE, add_req.key),
Expand All @@ -79,7 +81,7 @@ VALUES
callback_method: "PUT".to_string(),
callback_body: None,
enable: add_req.is_sync.unwrap_or_default(),
callback_headers: HashMap::new(),
callback_headers,
},
funs,
ctx,
Expand Down Expand Up @@ -156,15 +158,17 @@ WHERE key = $1
.await?;
conn.commit().await?;
//handle sync fact task
let mut callback_headers: HashMap<String, String> = HashMap::new();
callback_headers.insert("Tardis-Context".to_string(), TardisFuns::crypto.base64.encode(TardisFuns::json.obj_to_string(&ctx)?));
ScheduleClient::add_or_modify_sync_task(
AddOrModifySyncTaskReq {
code: format!("{}_{}", SYNC_FACT_TASK_CODE, fact_conf_key),
enable: modify_req.is_sync.unwrap_or_default(),
cron: modify_req.sync_cron.clone().unwrap_or("".to_string()),
callback_url: format!("{}/ci/{}/sync", funs.conf::<StatsConfig>().base_url, fact_conf_key),
callback_headers: HashMap::new(),
callback_method: "PUT".to_string(),
callback_body: None,
callback_headers,
},
funs,
ctx,
Expand Down

0 comments on commit b539aba

Please sign in to comment.