Installation
Basic usage
Loaders
Loaders let the engine resolve decisions by key -engine.Evaluate("pricing.json", ...) - instead of you reading files by hand. Set EngineConfig.Loader to a built-in loader config (StaticLoader, FilesystemLoader, or ZipLoader) or a custom callback.
Static
The static loader serves decisions from an in-memory map. Use it when your rules ship with the application or arrive as one payload:File system
The filesystem loader resolves keys against a root directory -pricing.json maps to ./rules/pricing.json:
Zip archive
The zip loader unpacks an archive in memory; every.json entry becomes a decision keyed by its path in the archive. This pairs naturally with release ZIPs downloaded from the BRMS or object storage:
Custom loader
For any other backend - a database, a remote API, per-tenant storage - pass a callback. Usesync.Map to cache at the source:
Batch evaluation
Evaluate many requests in one call. Each result reports its own success or failure, so one bad input never fails the batch:Error handling
Tracing
Enable tracing to inspect decision execution:Expression utilities
Evaluate ZEN expressions outside of a decision context:Best practices
Initialize the engine once. Create a singleZenEngine instance at application startup and reuse it for all evaluations.
Prefer built-in loaders. StaticLoader, FilesystemLoader, and ZipLoader cover most setups without custom code; reserve callback loaders for backends the built-ins can’t reach.
Call Dispose() on cleanup. Release engine and decision resources when your application terminates.