feat: 重构项目结构并添加核心功能

refactor: 将代码按功能模块重新组织到 core/runtime/control 等目录
feat(core): 添加 Context、FlowNode 等核心 trait 和类型
feat(runtime): 实现 FlowEngine 和状态管理
feat(control): 添加顺序/并行/条件控制流节点
feat(nodes): 实现 HTTP/DB/MQ 等业务节点
docs: 更新 README 添加架构说明和快速开始示例
test: 添加性能测试脚本和示例代码
This commit is contained in:
2025-12-14 23:50:40 +08:00
parent c24348c5c4
commit 81da0fe61f
43 changed files with 3421 additions and 698 deletions

View File

@ -0,0 +1,19 @@
use dsl_flow::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
tracing_subscriber::fmt().with_env_filter("info").init();
let store = InMemoryStateStore::default();
let engine = FlowEngine::new(store, FlowOptions { stateful: false, expr_engine: ExprEngineKind::Rhai });
let flow = Flow::new(sequence! {
expr_set(ExprEngineKind::Rhai, "1 + 2", "calc.sum"),
fork_join! {
expr_set(ExprEngineKind::Rhai, "ctx.calc.sum * 2", "calc.double"),
expr_set(ExprEngineKind::Rhai, "ctx.calc.sum * 3", "calc.triple")
}
});
let ctx = Context::new();
let out = engine.run_stateless(&flow, ctx).await?;
println!("{}", serde_json::to_string_pretty(&out.data)?);
Ok(())
}