Installation
Basic usage
Loader
ZenEngine accepts an optional ZenLoader that serves decisions by key. Use the static, filesystem, or zip variants for common backends, or callback for custom loading logic.
Static
Register decisions in memory. Use this for rules shipped in your app bundle:File system
Load decisions from files under a root directory, such as the Documents directory. Keys resolve to paths relative to the root:Zip archive
Pass the bytes of a zip archive. Every.json entry becomes a decision keyed by its path within the archive. This pairs naturally with BRMS release ZIPs - download the release once and hand the bytes to the engine:
Custom loader
For any other backend, implementZenDecisionLoaderCallback and wrap it in the callback variant:
nil from the callback reports the key as not found.
Batch evaluation
Evaluate many requests in one call. Each result reports its own success or failure, so one bad input never fails the batch:Async/Await
Evaluation functions are async, integrating natively with Swift concurrency: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.
Task or Task.detached to avoid blocking the main thread during evaluation.
Bundle fallback decisions. Include decisions in your app bundle as fallback for first launch or network failures.