Skip to main content

Crate fluxgate

Crate fluxgate 

Source
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);
  • FluxGateClient makes one OFREP call per flag and context, cached for 30 seconds. Evaluations never fail: on any error they return your default value with an ErrorCode.
  • FlagSnapshot, from FluxGateClient::watch, loads every flag for one context in one call and polls for changes; evaluations against it are synchronous.
  • blocking (feature blocking) is a synchronous client for code without an async runtime.
  • openfeature (feature openfeature) is an OpenFeature provider.

§Feature flags

  • rustls (default): TLS through rustls.
  • native-tls: TLS through the operating system’s library.
  • blocking: the blocking module.
  • openfeature: the openfeature module.

Modules§

blockingblocking
A synchronous client, for code without an async runtime.
openfeatureopenfeature
An OpenFeature provider.

Structs§

BulkEvaluation
The result of a bulk evaluation.
Error
A failed call to the edge.
EvaluationContext
Who a flag is evaluated for.
FlagEvaluation
The outcome of one flag evaluation. On error, value is the default you passed.
FlagSnapshot
Every flag of the client’s team, evaluated for one context and kept up to date by polling.
FluxGateClient
Evaluates FluxGate flags against an edge server over OFREP.
FluxGateClientBuilder
Settings for a FluxGateClient. Create it with FluxGateClient::builder.
ResolvedFlag
One flag as the edge resolved it, before it is converted to the caller’s type.

Enums§

ConfigError
Invalid settings for a FluxGateClient.
ErrorCode
Why an evaluation failed. Matches OpenFeature’s error codes where they overlap.
SnapshotStatus
The state of a FlagSnapshot.
Value
JSON values, as flags and context attributes hold them. Represents any valid JSON value.

Traits§

FlagValue
A type a flag can be read as: bool, String, i64, f64 or serde_json::Value.