Crates.io | spotify_confidence_sdk |
lib.rs | spotify_confidence_sdk |
version | 0.1.2 |
source | src |
created_at | 2024-06-05 11:35:50.336448 |
updated_at | 2024-07-08 12:26:31.999621 |
description | Confidence SDK for Rust |
homepage | https://confidence.spotify.com/ |
repository | https://github.com/spotify/confidence-sdk-rust |
max_upload_size | |
id | 1262679 |
size | 57,092 |
Rust implementation of the Confidence.
first, we need to setup the api config which contains a api_key
and a region
:
let api_config = APIConfig { api_key: "YOUR_API_KEY".to_string(), region: YOUR_REGION };
let confidence = Confidence::new(api_config)
after this initial setup we can start accessing the flags. Every time any of flags are asked, the sdk fetches them from the network and resolve the asked property.
The schema of the property plays a crucial role in resolving the property, if the schema type matches the asked type, the value will be returned otherwise
we expect an MismatchType
error from the EvaluationError
.
// wrong type, should return error
let details_string = confidence.get_flag("hawkflag.message", "default".to_string()).await;
println!("details string -> {:?}", details_string);
we can send custom events to the confidence sdk like following:
confidence.track("[EVENT-NAME]", HashMap::new());