Skip to content

Commit

Permalink
flow: fix bug illegal response (#499)
Browse files Browse the repository at this point in the history
* flow:fix bug

* flow:fix

* flow:fix

* flow: fix & fmt

* flow: update

* flow: fix bug illegal response
  • Loading branch information
ZzIsGod1019 authored Oct 21, 2023
1 parent c8b6c9b commit 7ac557d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion middleware/flow/src/api/cc/flow_cc_inst_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl FlowCcInstApi {
let mut funs = flow_constants::get_tardis_inst();
FlowInstServ::check_transfer_vars(&flow_inst_id.0, &transfer_req.0, &funs, &ctx.0).await?;
funs.begin().await?;
let result = FlowInstServ::transfer(&flow_inst_id.0, &transfer_req.0, &funs, &ctx.0).await?;
let result = FlowInstServ::transfer(&flow_inst_id.0, &transfer_req.0, false, &funs, &ctx.0).await?;
funs.commit().await?;
TardisResp::ok(result)
}
Expand Down
16 changes: 13 additions & 3 deletions middleware/flow/src/api/ci/flow_ci_inst_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use tardis::web::context_extractor::TardisContextExtractor;
use tardis::web::poem_openapi;
use tardis::web::poem_openapi::payload::Json;
use tardis::web::web_resp::{TardisApiResult, TardisResp, Void};
use tardis::{log, tokio};

use crate::dto::flow_inst_dto::{FlowInstBatchBindReq, FlowInstBatchBindResp, FlowInstBindReq, FlowInstStartReq};
use crate::flow_constants;
Expand Down Expand Up @@ -53,9 +54,18 @@ impl FlowCiInstApi {
#[oai(path = "/trigger_front_action", method = "get")]
async fn trigger_front_action(&self) -> TardisApiResult<Void> {
let mut funs = flow_constants::get_tardis_inst();
funs.begin().await?;
FlowInstServ::trigger_front_action(&funs).await?;
funs.commit().await?;
tokio::spawn(async move {
funs.begin().await.unwrap();
match FlowInstServ::trigger_front_action(&funs).await {
Ok(_) => {
log::trace!("[Flow.Inst] add log success")
}
Err(e) => {
log::warn!("[Flow.Inst] failed to add log:{e}")
}
}
funs.commit().await.unwrap();
});

TardisResp::ok(Void {})
}
Expand Down
11 changes: 9 additions & 2 deletions middleware/flow/src/serv/flow_inst_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,10 +585,16 @@ impl FlowInstServ {
Ok(())
}

pub async fn transfer(flow_inst_id: &str, transfer_req: &FlowInstTransferReq, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<FlowInstTransferResp> {
pub async fn transfer(
flow_inst_id: &str,
transfer_req: &FlowInstTransferReq,
skip_filter: bool,
funs: &TardisFunsInst,
ctx: &TardisContext,
) -> TardisResult<FlowInstTransferResp> {
// record updated instance id
let mut updated_instance_list: Vec<String> = Vec::new();
let result = Self::do_transfer(flow_inst_id, transfer_req, &mut updated_instance_list, false, funs, ctx).await;
let result = Self::do_transfer(flow_inst_id, transfer_req, &mut updated_instance_list, skip_filter, funs, ctx).await;

for updated_instance_id in updated_instance_list {
Self::do_front_change(&updated_instance_id, ctx, funs).await?;
Expand Down Expand Up @@ -1253,6 +1259,7 @@ impl FlowInstServ {
message: None,
vars: None,
},
true,
funs,
ctx,
)
Expand Down
2 changes: 2 additions & 0 deletions middleware/flow/tests/test_flow_scenes_fsm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use tardis::basic::dto::TardisContext;
use tardis::basic::result::TardisResult;
use tardis::log::info;
use tardis::serde_json::json;
use tardis::tokio;
use tardis::web::poem_openapi::types::Type;
use tardis::web::web_resp::{TardisPage, Void};
use tardis::TardisFuns;
Expand Down Expand Up @@ -776,6 +777,7 @@ pub async fn test(flow_client: &mut TestHttpClient, _kv_client: &mut TestHttpCli
)
.await;
let _: Void = flow_client.get("/ci/inst/trigger_front_action").await;
tokio::time::sleep(tokio::time::Duration::from_secs(10)).await;
let state_and_next_transitions: Vec<FlowInstFindStateAndTransitionsResp> = flow_client
.put(
"/cc/inst/batch/state_transitions",
Expand Down

0 comments on commit 7ac557d

Please sign in to comment.