mirror of
https://github.com/gorules/zen.git
synced 2026-11-28 16:06:26 +00:00
- zen_expression::clock: Clock is now plain per-evaluation state (now, timezone, seed, per-row and per-item random streams in a RefCell arena), and EvalContext pairs an Rc<Clock> with the row mapping of the current call (direct, one stream, picked rows, loop items). The thread-local current clock, Origin/Origins, set_row/at_row and the stream map lookups are gone. - the compiled engine builds the context once per evaluation (pinning::single / pinning::batch) and carries it in NodeHandlerExtensions; graph states, bounds, loops, sub-decisions, tables and policies derive row/item contexts with rows()/at()/items() and pass them down. - lane runs (LaneRunner, Session, kernels, cells), builtins (At), date helpers and typed programs take the context or its clock explicitly; rand draws from the stream of the lane's row. - function hosts install Date/Math.random once per runtime and point them at the call's context with a scoped JsClock slot (v1 scripts, v1 batch sessions, v2 handlers, rows and zen.evaluate). - Workspace gains evaluate_pinned / evaluate_batch_pinned / evaluate_columns_pinned that read now/timezone/seed from EvaluationOptions. - d(...) with a zone-dependent argument is no longer folded at compile time; typed lowering folds only zone-independent date texts and checks the rest at run time with the evaluation's zone. - the interpreted engine and the stack VM use the host clock and unseeded fastrand as on release/2.2; functions/internal.rs is back to release/2.2. - tests: interleaved evaluations on one thread and on two threads see only their own clock and stream.
ZEN Expression Language
The expression language of ZEN Engine, the open-source Business Rules Engine (BRE) from GoRules.
ZEN expressions are readable by business users and fast enough for hot paths: a complete language for conditions, calculations and data transformation, with lexer, parser, compiler, VM, type checking and editor completions included in this crate.
use serde_json::json;
use zen_expression::evaluate_expression;
fn main() {
let result = evaluate_expression(
"sum(items) * multiplier",
json!({ "items": [10, 20, 30], "multiplier": 2 }).into(),
)
.unwrap();
// => 120
}
Reusable expressions compile once via compile_expression and evaluate repeatedly against different contexts.
Resources
- ZEN Expression Language reference - syntax, operators, built-in functions and date operations
- ZEN Engine - the rules engine built on this language
- GoRules - the platform around the open-source engine
- Online Editor - try expressions in the free editor with a built-in simulator