Crates.io | configcat-openfeature-provider |
lib.rs | configcat-openfeature-provider |
version | 0.1.1 |
source | src |
created_at | 2024-08-08 16:04:59.158858 |
updated_at | 2024-08-08 16:29:17.196614 |
description | ConfigCat OpenFeature Provider for Rust |
homepage | https://configcat.com |
repository | https://github.com/configcat/openfeature-rust |
max_upload_size | |
id | 1329722 |
size | 74,928 |
This repository contains an OpenFeature provider that allows ConfigCat to be used with the OpenFeature Rust SDK.
Run the following Cargo command in your project directory:
cargo add configcat-openfeature-provider
Or add the following to your Cargo.toml
:
[dependencies]
configcat-openfeature-provider = "0.1"
The ConfigCatProvider
needs a pre-configured ConfigCat Rust SDK client:
use std::time::Duration;
use configcat::{Client, PollingMode};
use open_feature::OpenFeature;
use configcat_openfeature_provider::ConfigCatProvider;
#[tokio::main]
async fn main() {
// Acquire an OpenFeature API instance.
let mut api = OpenFeature::singleton_mut().await;
// Configure the ConfigCat SDK.
let configcat_client = Client::builder("<YOUR-CONFIGCAT-SDK-KEY>")
.polling_mode(PollingMode::AutoPoll(Duration::from_secs(60)))
.build()
.unwrap();
// Configure the provider.
api.set_provider(ConfigCatProvider::new(configcat_client)).await;
// Create a client.
let client = api.create_client();
// Evaluate a feature flag.
let is_awesome_feature_enabled = client
.get_bool_value("isAwesomeFeatureEnabled", None, None)
.await
.unwrap_or(false);
}
For more information about all the configuration options, see the Rust SDK documentation.
This repository contains a simple example application that you can run with:
cargo run --example print_eval
Contributions are welcome. For more info please read the Contribution Guideline.
ConfigCat is a feature flag and configuration management service that lets you separate releases from deployments. You can turn your features ON/OFF using ConfigCat Dashboard even after they are deployed. ConfigCat lets you target specific groups of users based on region, email or any other custom user attribute.
ConfigCat is a hosted feature flag service. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.