Expand description
Client for the FluxGate feature toggle edge server.
It evaluates flags over OFREP, the OpenFeature Remote Evaluation Protocol, authenticated with a FluxGate client’s SDK key.
use fluxgate::{EvaluationContext, FluxGateClient};
let fluxgate = FluxGateClient::new("https://edge.example.com", &std::env::var("FLUXGATE_SDK_KEY").unwrap())?;
let user = EvaluationContext::new("user-1").with("country", "CA").with("user_tier", "plus");
if fluxgate.is_enabled("new-checkout", &user).await {
// ...
}
let theme = fluxgate.evaluate("checkout-theme", "classic".to_owned(), &user).await;
println!("{} (variant {:?}, reason {})", theme.value, theme.variant, theme.reason);FluxGateClientmakes one OFREP call per flag and context, cached for 30 seconds. Evaluations never fail: on any error they return your default value with anErrorCode.FlagSnapshot, fromFluxGateClient::watch, loads every flag for one context in one call and polls for changes; evaluations against it are synchronous.blocking(featureblocking) is a synchronous client for code without an async runtime.openfeature(featureopenfeature) is an OpenFeature provider.
§Feature flags
rustls(default): TLS through rustls.native-tls: TLS through the operating system’s library.blocking: theblockingmodule.openfeature: theopenfeaturemodule.
Modules§
- blocking
blocking - A synchronous client, for code without an async runtime.
- openfeature
openfeature - An OpenFeature provider.
Structs§
- Bulk
Evaluation - The result of a bulk evaluation.
- Error
- A failed call to the edge.
- Evaluation
Context - Who a flag is evaluated for.
- Flag
Evaluation - The outcome of one flag evaluation. On error,
valueis the default you passed. - Flag
Snapshot - Every flag of the client’s team, evaluated for one context and kept up to date by polling.
- Flux
Gate Client - Evaluates FluxGate flags against an edge server over OFREP.
- Flux
Gate Client Builder - Settings for a
FluxGateClient. Create it withFluxGateClient::builder. - Resolved
Flag - One flag as the edge resolved it, before it is converted to the caller’s type.
Enums§
- Config
Error - Invalid settings for a
FluxGateClient. - Error
Code - Why an evaluation failed. Matches OpenFeature’s error codes where they overlap.
- Snapshot
Status - The state of a
FlagSnapshot. - Value
- JSON values, as flags and context attributes hold them. Represents any valid JSON value.
Traits§
- Flag
Value - A type a flag can be read as:
bool,String,i64,f64orserde_json::Value.