#unleash #sdk #domain #experimental #extracted #yggdrasil #own

unleash-yggdrasil

This is the Unleash SDK domain logic extracted into a library to facilitate building your own Unleash SDKs in anything, anywhere

33 releases (13 breaking)

0.14.1 Nov 27, 2024
0.13.3 Oct 22, 2024
0.13.0 Jul 19, 2024
0.11.0 Feb 29, 2024
0.5.3 Mar 3, 2023

#104 in Math

Download history 8/week @ 2024-08-26 166/week @ 2024-09-02 14/week @ 2024-09-09 290/week @ 2024-09-16 62/week @ 2024-09-23 64/week @ 2024-09-30 14/week @ 2024-10-07 33/week @ 2024-10-14 203/week @ 2024-10-21 186/week @ 2024-10-28 7/week @ 2024-11-04 7/week @ 2024-11-11 18/week @ 2024-11-18 187/week @ 2024-11-25 91/week @ 2024-12-02

303 downloads per month
Used in 3 crates

MIT license

155KB
4K SLoC

Yggdrasil

Yggdrasil is a Rust project designed to create the core of the Unleash SDK domain logic in a single language. This crate is the Rust logic extracted into a standalone crate so that the logic can be used natively inside a Rust application. This is a very experimental crate, so if you're looking to connect a Rust application to Unleash, you should use the official Rust SDK instead, the API and philosophy here are subject to change until this is in stable.

Using Yggdrasil in a Rust project

The heart of Yggdrasil is the EngineState struct, this is a lightweight struct that does very little on its own, it's cheap to create but you probably only need/want one of them:


let engine = EngineState::default();

The engine needs to be populated with an Unleash response before it will return anything useful. The shape of the data here should be identical to the response returned by Unleash, if you'd like to handroll your own data, you can check out the format of the ClientFeatures struct here.


let spec_data = "";// Some json blob, matching the Unleash format

let unleash_data: ClientFeatures = serde_json::from_str(&spec_data).unwrap();

engine.take_state(unleash_data);

Now you can query the engine for a given toggle:

let context = InnerContext::default();

let enabled = engine.is_enabled("my-toggle-name", &context);

//Do something with the enabled state here

Releasing

cargo smart-release -u -b patch unleash-yggdrasil

Dependencies

~6–30MB
~451K SLoC