Expand description
§feature-flag
Server-side feature flag evaluation for async Rust services.
§Design rules
- No external RNG. Sticky bucketing is a SHA-256 of
(flag_id ‖ subject_id)mod 100 — deterministic, no entropy source, noranddep. - Tokio is assumed. Hot reload uses
tokio::fs+ an async watcher. - Cheap clones. The evaluator is
Arc-shaped under the hood, so handing it to many tasks is free. - Snapshot for tests. Build a
FlagSetin code, drop it into aFlagEvaluator, evaluate. No I/O required.
§Primitives
FlagSet— declarative collection of flags, deserialised from JSON.Flag— one named flag with default + ordered targetingRules.Rule— amatch_whenPredicateplus an outcome (Variantor percentage rollout).Predicate— small DSL of typed comparisons +all_of/any_of/not.Subject— the entity being evaluated (id + arbitrary attributes).FlagEvaluator— combines aFlagSetwith a sticky-bucketing function.HotReloader— watches a JSON file for changes and atomically swaps the evaluator’sFlagSet.
§Composes with
- reliability-toolkit-rs — wrap a rollout-controlled call in a circuit breaker + retry.
- slo-budget-tracker —
if your SLO is burning, flip the flag to
default_offfrom a remote config push.
Re-exports§
pub use error::FeatureFlagError;pub use evaluator::Evaluation;pub use evaluator::FlagEvaluator;pub use hot_reload::HotReloader;pub use model::Flag;pub use model::FlagSet;pub use model::Rule;pub use model::Variant;pub use predicate::Comparison;pub use predicate::Predicate;pub use subject::Subject;
Modules§
- error
- Crate-wide error type.
- evaluator
- The hot path.
FlagEvaluatorwraps aFlagSet(behind anArcSwap-style lock) and resolves(flag_id, subject)to a variant. - hot_
reload - File-backed hot reload for
FlagEvaluator. - model
- Flag / Rule / FlagSet types.
- predicate
- Targeting predicate DSL — typed comparisons + boolean combinators.
- subject
- The thing flags are evaluated against.