experiment-evaluation
2.3.0indexedCross-platform experiment evaluation engine shares evaluation code across SDKs lacking native implementations, like Ruby and Python. Supports JSON input/output and native interoperability using serialization.
Cross-platform experiment evaluation engine shares evaluation code across SDKs lacking native implementations, like Ruby and Python. Supports JSON input/output and native interoperability using serialization.
Multiplatform (JVM, Node.js, Native) implementation of the experiment evaluation engine. The purpose of this library is to share the same evaluation code across local-evaluation experiment SDKs which don't have a language-native implementation (Ruby, Python).
This may take some time.
./gradlew assemble
evaluation-coreThe core evaluation engine with public data types exposed. Used by other kotlin mulitplatform modules/libraries and JVM targets. This code is pure multiplatform kotlin, without any dependencies.
evaluation-interopModule which supports better interoperability with native targets. Uses kotlinx serialization to serialize data across the native interface.
This module exposes a single function evaluate which takes JSON String inputs and outputs. The caller is in charge of building the json objects and parsing the result.
fun evaluate(rules: String, user: String): String
This kotlin function maps to an equivalent function in C:
const char* (*evaluate)(const char* rules, const char* user);
This string returned from the call to evaluate must be freed by calling the DisposeString utility function.
void (*DisposeString)(const char* string);
These functions are wrapped in structures generated by kotlin (some functions omitted):
typedef struct {
/* Dispose string function. */
void (*DisposeString)( * );
* (*evaluate)( * rules, * user);
} root;
} kotlin;
} libevaluation_interop_ExportedSymbols;
libevaluation_interop_ExportedSymbols* ;
Here's a full example of calling evaluate, then DisposeString in C:
#include "libevaluation_interop_api.h"
#include "stdio.h"
int {
libevaluation_interop_ExportedSymbols* lib = libevaluation_interop_symbols();
* rules = ;
* user = ;
* response = lib->kotlin.root.evaluate(rules, user);
(, response);
lib->DisposeString(response);
;
}
Native static and dynamic libraries are built for specific operating systems and architectures. For dynamic libraries, MacOS targets generate .dylib files while linux targets generate .so files. Outputs are generated for debug and release build flavors. Debug flavor outputs will contain additional debug info when the native code crashes (kotlin stack traces, register dump, etc).
# Dynamic Libraries
build/bin/<target>/<flavor>Shared/libevaluation_interop.<file>
build/bin/<target>/<flavor>Shared/libevaluation_interop_api.h
# Static Libraries
build/bin/<target>/<flavor>Static/libevaluation_interop.a
build/bin/<target>/<flavor>Static/libevaluation_interop_api.h
<target>
macosX64: MacOS with Intel ChipmacosArm64: MacOS with M1 / Apple Silicon ChiplinuxX64: Linux with Intel/AMD (x64)linuxArm64: Linux with Arm Chip<flavor>
debug: larger, slower binaries with additional debug output on crash (stack traces, register dump, etc.)release: smaller, faster binaries without additional debug output on crash.<file>
dylib: output file type for macOSso: output file type for linuxSurfaced from shared tags and platforms — no rankings paid for.