|
| 1 | +//! [Generated by cargo-readme: `cargo readme --no-title --no-license > README.md`]:: |
| 2 | +//! # OFREP Provider for OpenFeature |
| 3 | +//! |
| 4 | +//! A Rust implementation of the OpenFeature OFREP provider, enabling dynamic |
| 5 | +//! feature flag evaluation in your applications. |
| 6 | +//! |
| 7 | +//! This provider allows to connect to any feature flag management system that supports OFREP. |
| 8 | +//! |
| 9 | +//! ### Installation |
| 10 | +//! Add the dependency in your `Cargo.toml`: |
| 11 | +//! ```bash |
| 12 | +//! cargo add open-feature-ofrep |
| 13 | +//! cargo add open-feature |
| 14 | +//! ``` |
| 15 | +//! Then integrate it into your application: |
| 16 | +//! |
| 17 | +//! ```rust,no_run |
| 18 | +//! use std::time::Duration; |
| 19 | +//! use open_feature::provider::FeatureProvider; |
| 20 | +//! use open_feature::EvaluationContext; |
| 21 | +//! use open_feature_ofrep::{OfrepProvider, OfrepOptions}; |
| 22 | +//! use reqwest::header::{HeaderMap, HeaderValue}; |
| 23 | +//! |
| 24 | +//! #[tokio::main] |
| 25 | +//! async fn main() { |
| 26 | +//! let mut headers = HeaderMap::new(); |
| 27 | +//! headers.insert("color", HeaderValue::from_static("yellow")); |
| 28 | +//! |
| 29 | +//! let provider = OfrepProvider::new(OfrepOptions { |
| 30 | +//! base_url: "http://localhost:8016".to_string(), |
| 31 | +//! headers: headers.clone(), |
| 32 | +//! connect_timeout: Duration::from_secs(4), |
| 33 | +//! ..Default::default() |
| 34 | +//! }).await.unwrap(); |
| 35 | +//! |
| 36 | +//! let context = EvaluationContext::default() |
| 37 | +//! .with_targeting_key("user-123") |
| 38 | +//! .with_custom_field("color", "yellow"); |
| 39 | +//! |
| 40 | +//! let result = provider.resolve_bool_value("isColorYellow", &context).await.unwrap(); |
| 41 | +//! println!("Flag value: {}", result.value); |
| 42 | +//! } |
| 43 | +//! ``` |
| 44 | +//! |
| 45 | +//! ### Configuration Options |
| 46 | +//! Configurations can be provided as constructor options. The following options are supported: |
| 47 | +//! |
| 48 | +//! | Option | Type / Supported Value | Default | |
| 49 | +//! |-----------------------------------------|-----------------------------------|-------------------------------------| |
| 50 | +//! | base_url | string | http://localhost:8016 | |
| 51 | +//! | headers | HeaderMap | Empty Map | |
| 52 | +//! | connect_timeout | Duration | 10 seconds | |
| 53 | +//! |
| 54 | +//! ### License |
| 55 | +//! Apache 2.0 - See [LICENSE](./../../LICENSE) for more information. |
| 56 | +
|
1 | 57 | mod error;
|
2 | 58 | mod resolver;
|
3 | 59 |
|
|
0 commit comments