wp-reactor/
├── Cargo.toml # Workspace 根配置
├── crates/
│ ├── wf-lang/ # Window Schema / Rule 编译器
│ ├── wf-config/ # wfusion.toml 配置管理与校验
│ ├── wf-core/ # 核心 CEP / Window / Alert 逻辑
│ ├── wf-runtime/ # 运行时生命周期 / Receiver / Scheduler
│ └── wf-engine/ # `wfusion` CLI 逻辑库(实际二进制在 ../warp-fusion)
└── docs/
├── design/ # 设计文档
└── user-guide/ # 面向使用者的指南
CLI / 工具 workspace 位于相邻仓库 ../warp-fusion,负责产出 wfusion、wfgen、wfl 三个二进制。
Window Schema 解析器,负责解析 .wfs 文件中的窗口定义 DSL。
支持的字段类型:chars | digit | float | bool | time | ip | hex | array/T
示例 .wfs 文件:
window auth_events {
stream = "auth"
time = event_time
over = 30m
fields {
username: chars
sip: ip
event_time: time
}
}
运行时配置管理,负责加载、解析和校验 wfusion.toml 配置文件。
核心模块:
- types — 自定义类型(
HumanDuration、ByteSize、DistMode、EvictPolicy、LatePolicy) - window — 窗口配置(全局默认值 + 逐窗口覆盖 → 合并解析)
- source — 输入源配置(
tcp/file,支持ndjson/arrow_framed/arrow_ipc) - runtime — 执行器并行度、规则超时、schema/rule 文件路径
- fusion — 顶层配置组装与解析入口
- validate — 跨文件语义校验
示例 wfusion.toml:
mode = "daemon"
sinks = "sinks"
[[sources]]
type = "tcp"
name = "ingress_tcp"
listen = "tcp://127.0.0.1:9800"
[runtime]
executor_parallelism = 2
rule_exec_timeout = "30s"
schemas = "schemas/*.wfs"
rules = "rules/*.wfl"
[window_defaults]
evict_interval = "30s"
max_window_bytes = "256MB"
max_total_bytes = "2GB"
evict_policy = "time_first"
watermark = "5s"
allowed_lateness = "0s"
late_policy = "drop"
[window.auth_events]
mode = "local"
over_cap = "30m"批处理文件输入示例:
mode = "batch"
sinks = "sinks"
[[sources]]
type = "file"
path = "data/events.arrowf"
format = "arrow_framed"
[runtime]
executor_parallelism = 2
rule_exec_timeout = "30s"
schemas = "schemas/*.wfs"
rules = "rules/*.wfl"| 文件 | 职责 |
|---|---|
.wfs |
逻辑数据定义(window、field、time、over) |
.wfl |
检测规则(bind / match / join / yield) |
wfusion.toml |
物理参数(mode、max_bytes、watermark、sinks) |
用户文档入口见 docs/user-guide/index.md。
cargo build构建 CLI:
cargo build --manifest-path ../warp-fusion/Cargo.tomlcargo test运行 CLI / 工具测试:
cargo test --manifest-path ../warp-fusion/Cargo.toml| 依赖 | 用途 |
|---|---|
serde |
序列化 / 反序列化 |
toml |
TOML 配置解析 |
anyhow |
错误处理 |
winnow |
Parser combinator |