Crates.io | open-feature-ofrep |
lib.rs | open-feature-ofrep |
version | 0.0.4 |
created_at | 2025-07-28 18:08:24.669457+00 |
updated_at | 2025-08-11 11:47:08.559162+00 |
description | The official OpenFeature Remote Evaluation Protocol (OFREP) provider for OpenFeature. |
homepage | https://openfeature.dev/ |
repository | https://github.com/open-feature/rust-sdk-contrib |
max_upload_size | |
id | 1771446 |
size | 100,376 |
A Rust implementation of the OpenFeature OFREP provider, enabling dynamic feature flag evaluation in your applications.
This provider allows to connect to any feature flag management system that supports OFREP.
Add the dependency in your Cargo.toml
:
cargo add open-feature-ofrep
cargo add open-feature
Then integrate it into your application:
use std::time::Duration;
use open_feature::provider::FeatureProvider;
use open_feature::EvaluationContext;
use open_feature_ofrep::{OfrepProvider, OfrepOptions};
use reqwest::header::{HeaderMap, HeaderValue};
#[tokio::main]
async fn main() {
let mut headers = HeaderMap::new();
headers.insert("color", HeaderValue::from_static("yellow"));
let provider = OfrepProvider::new(OfrepOptions {
base_url: "http://localhost:8016".to_string(),
headers: headers.clone(),
connect_timeout: Duration::from_secs(4),
..Default::default()
}).await.unwrap();
let context = EvaluationContext::default()
.with_targeting_key("user-123")
.with_custom_field("color", "yellow");
let result = provider.resolve_bool_value("isColorYellow", &context).await.unwrap();
println!("Flag value: {}", result.value);
}
Configurations can be provided as constructor options. The following options are supported:
Option | Type / Supported Value | Default |
---|---|---|
base_url | string | http://localhost:8016 |
headers | HeaderMap | Empty Map |
connect_timeout | Duration | 10 seconds |
Apache 2.0 - See LICENSE for more information.