feat(flow): 新增分组执行与异步模式支持
refactor(executors): 将 Rhai 引擎评估逻辑迁移至 script_rhai 模块 docs: 添加 Flow 架构文档与示例 JSON feat(i18n): 新增前端多语言支持 perf(axios): 优化 token 刷新与 401 处理逻辑 style: 统一代码格式化与简化条件判断
This commit is contained in:
@ -301,6 +301,8 @@ async fn run_internal(
|
||||
.or_else(|| design.get("execution_mode").and_then(|v| v.as_str()))
|
||||
.unwrap_or("sync");
|
||||
exec_mode = parse_execution_mode(mode_str);
|
||||
let bounded_limit = design.get("concurrencyLimit").and_then(|v| v.as_u64()).map(|x| x as usize);
|
||||
let _ = bounded_limit;
|
||||
(chain_from_json, ctx)
|
||||
} else {
|
||||
let dsl = match serde_yaml::from_str::<FlowDSL>(&doc.yaml) {
|
||||
@ -344,7 +346,12 @@ async fn run_internal(
|
||||
|
||||
// 执行
|
||||
let drive_res = engine
|
||||
.drive(&chain, ctx, DriveOptions { execution_mode: exec_mode.clone(), event_tx, ..Default::default() })
|
||||
.drive(&chain, ctx, DriveOptions {
|
||||
execution_mode: exec_mode.clone(),
|
||||
event_tx,
|
||||
bounded_limit: if matches!(exec_mode, ExecutionMode::AsyncBounded) { design_concurrency_limit(&doc.design_json) } else { None },
|
||||
..Default::default()
|
||||
})
|
||||
.await;
|
||||
|
||||
match drive_res {
|
||||
@ -446,6 +453,16 @@ fn merge_json(a: &mut serde_json::Value, b: &serde_json::Value) {
|
||||
fn parse_execution_mode(s: &str) -> ExecutionMode {
|
||||
match s.to_ascii_lowercase().as_str() {
|
||||
"async" | "async_fire_and_forget" | "fire_and_forget" => ExecutionMode::AsyncFireAndForget,
|
||||
"queued" | "queue" => ExecutionMode::AsyncQueued,
|
||||
"bounded" | "parallel_bounded" | "bounded_parallel" => ExecutionMode::AsyncBounded,
|
||||
_ => ExecutionMode::Sync,
|
||||
}
|
||||
}
|
||||
|
||||
fn design_concurrency_limit(design_json: &Option<serde_json::Value>) -> Option<usize> {
|
||||
design_json
|
||||
.as_ref()
|
||||
.and_then(|d| d.get("concurrencyLimit"))
|
||||
.and_then(|v| v.as_u64())
|
||||
.map(|x| x as usize)
|
||||
}
|
||||
Reference in New Issue
Block a user