Files
dsl_flow/dsl-flow/examples/basic.rs
ayou 81da0fe61f feat: 重构项目结构并添加核心功能
refactor: 将代码按功能模块重新组织到 core/runtime/control 等目录
feat(core): 添加 Context、FlowNode 等核心 trait 和类型
feat(runtime): 实现 FlowEngine 和状态管理
feat(control): 添加顺序/并行/条件控制流节点
feat(nodes): 实现 HTTP/DB/MQ 等业务节点
docs: 更新 README 添加架构说明和快速开始示例
test: 添加性能测试脚本和示例代码
2025-12-14 23:50:40 +08:00

19 lines
780 B
Rust

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(())
}