fluxgate
Rust 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.
[]
= "1"
use ;
let fluxgate = new?;
let user = new.with.with;
if fluxgate.is_enabled.await
let theme = fluxgate.evaluate.await;
println!;
What's in the crate
FluxGateClient: one OFREP call per flag and context, with retries, timeouts and a 30-second cache. Evaluations never fail. On any error they return your default value with anerror_code. The client needs a Tokio runtime and is cheap to clone.FlagSnapshot, fromclient.watch(context): loads every flag for one context in one call and polls every 30 seconds withIf-None-Match, so an unchanged flag set costs a304. Reads are synchronous.subscribe()notifies you of changes.fluxgate::blocking(featureblocking): the same API for code without an async runtime.fluxgate::openfeature::FluxGateProvider(featureopenfeature): an OpenFeature provider for theopen-featurecrate.
| Feature | Default | |
|---|---|---|
rustls |
yes | TLS through rustls. |
native-tls |
no | TLS through the operating system's library. Use with default-features = false. |
blocking |
no | The synchronous client. |
openfeature |
no | The OpenFeature provider. |
Rust 1.85 or later.
SDK keys
Create a Backend client in the FluxGate admin UI (Clients). Its SDK key is
<clientId>.<apiKey>. Keep it secret.
How evaluation works
- Every evaluation needs a targeting key, the ID that decides the user's bucket in percentage
splits.
EvaluationContext::new("user-1")sets it. - The default value sets the expected type: a
bool,String,i64,f64orserde_json::Value(Value::Nullaccepts any flag). A boolean flag read with a string default is aTYPE_MISMATCH. - A flag that is disabled or not deployed for the client's environment answers
falsewith no variant, whatever its type. For non-boolean reads that yields your default value. - The edge remembers the variant it first served to a targeting key. After you change a flag's rules, a user who already got an answer can keep it.
See the repository for samples that run against a local FluxGate stack.
License
Apache License 2.0