use open_feature::{EvaluationContext, OpenFeature};
use spotify_confidence_openfeature_provider_local::{ConfidenceProvider, ProviderOptions};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create provider options with your client secret
let options = ProviderOptions::new("your-client-secret");
// Create the Confidence provider
let provider = ConfidenceProvider::new(options)?;
// Set the provider on the OpenFeature singleton
OpenFeature::singleton_mut()
.await
.set_provider(provider)
.await;
// Create an OpenFeature client
let client = OpenFeature::singleton().await.create_client();
// Create evaluation context with user attributes for targeting
let context = EvaluationContext::default()
.with_targeting_key("user-123")
.with_custom_field("country", "US")
.with_custom_field("plan", "premium");
// Evaluate a boolean flag
let enabled = client
.get_bool_value("my-feature-flag.enabled", Some(&context), None)
.await
.unwrap_or(false);
println!("Flag value: {}", enabled);
Ok(())
}