open-feature-ofrep

Crates.ioopen-feature-ofrep
lib.rsopen-feature-ofrep
version0.0.4
created_at2025-07-28 18:08:24.669457+00
updated_at2025-08-11 11:47:08.559162+00
descriptionThe official OpenFeature Remote Evaluation Protocol (OFREP) provider for OpenFeature.
homepagehttps://openfeature.dev/
repositoryhttps://github.com/open-feature/rust-sdk-contrib
max_upload_size
id1771446
size100,376
OpenFeature Bot (openfeaturebot)

documentation

https://docs.rs/open-feature-ofrep

README

OFREP Provider for OpenFeature

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.

Installation

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);
}

Configuration Options

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

License

Apache 2.0 - See LICENSE for more information.

Commit count: 33

cargo fmt