Skip to main content
Install the ZEN Engine and evaluate your first decision in Kotlin.

Installation

Basic usage

Loader

The loader pattern enables dynamic decision loading from any storage backend. Implement the ZenDecisionLoaderCallback interface with a suspend fun load(key: String): JsonBuffer? method. Use ConcurrentHashMap to cache decisions for optimal performance.

File system

AWS S3

Azure Blob Storage

Google Cloud Storage

Coroutines

Evaluation functions are suspend functions, integrating natively with Kotlin coroutines:

Error handling

Tracing

Enable tracing to inspect decision execution:

Expression utilities

Evaluate ZEN expressions outside of a decision context:

Performance note

The Kotlin bindings use JNA (Java Native Access) for interoperability with the native Rust engine. This introduces some overhead compared to native Rust or direct bindings. We plan to revisit this when the FFM (Foreign Function & Memory) API becomes more widely adopted.

Best practices

Use .use {} for resource management. ZenEngine implements AutoCloseable to release native resources.
Initialize the engine once. Create a single ZenEngine instance at application startup and reuse it for all evaluations. Implement a loader for dynamic decisions. The loader pattern centralizes decision loading logic and enables caching with ConcurrentHashMap. Leverage coroutines for parallel evaluation. Use async/awaitAll to evaluate multiple decisions concurrently.