mirror of
https://github.com/block/buzz.git
synced 2026-10-28 21:11:48 +00:00
## Why Buzz server components need one typed feature-flag contract without forcing the open-source build to depend on LaunchDarkly. A staging or production relay must not be able to choose the wrong provider through runtime configuration. ## What - Adds typed boolean and signed `i64` flags with static, environment, and compile-gated LaunchDarkly evaluators. - Defines an executable relay artifact contract that compiles exactly one provider. - Rejects zero or multiple relay provider features at compile time. - Runs the LaunchDarkly feature tests and the provider compile matrix in the unit CI lane and fallback test script. ## How `buzz-feature-flags` stays provider-neutral. The future relay composition root will expose one build path per artifact feature: `static-feature-flags`, `environment-feature-flags`, or `launchdarkly-feature-flags`. Runtime configuration carries only settings for the selected provider. It never carries a provider name, fallback, or precedence rule. The crate still has no relay consumer. A locked compile fixture proves each singleton builds and every zero or multi-provider combination fails until the relay adopts this contract. This removes the proposed runtime `ProviderMode` and leaves one provider, one construction path, and one evaluator per artifact. ## Risk This PR still has no relay or app consumer, so it changes no user-visible behavior. Risk is limited to the new feature-flag crate, its compile contract, and its unit-test lane. ## Testing An external Rust consumer at `30cf968bfe85e82980fda7e63f5bebe649ca939f` exercised six environment-evaluator scenarios and 59 assertions. The compile-time correction adds no live consumer to exercise manually. ## Bigger picture When `buzz-relay` adopts this crate, its build manifests must map each distribution to one provider feature. That consumer PR must verify live Relay Proxy reachability, secret ingestion, lifecycle ownership, and user-visible behavior. Generated with Codex --------- Signed-off-by: tornquist <tornquist@squareup.com> Co-authored-by: Codex <noreply@openai.com> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
50 lines
1.3 KiB
Rust
50 lines
1.3 KiB
Rust
//! Typed feature-flag keys and declared defaults.
|
|
|
|
/// Typed boolean feature definition.
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub struct BooleanFlag {
|
|
key: &'static str,
|
|
default: bool,
|
|
}
|
|
|
|
impl BooleanFlag {
|
|
/// Construct a typed boolean flag from its stable key and declared default.
|
|
pub const fn new(key: &'static str, default: bool) -> Self {
|
|
Self { key, default }
|
|
}
|
|
|
|
/// Stable key for this flag.
|
|
pub const fn key(self) -> &'static str {
|
|
self.key
|
|
}
|
|
|
|
/// Declared default used when an evaluator is unavailable or cannot return a value.
|
|
pub const fn default(self) -> bool {
|
|
self.default
|
|
}
|
|
}
|
|
|
|
/// Typed integer feature definition.
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub struct IntegerFlag {
|
|
key: &'static str,
|
|
default: i64,
|
|
}
|
|
|
|
impl IntegerFlag {
|
|
/// Construct a typed integer flag from its stable key and declared default.
|
|
pub const fn new(key: &'static str, default: i64) -> Self {
|
|
Self { key, default }
|
|
}
|
|
|
|
/// Stable key for this flag.
|
|
pub const fn key(self) -> &'static str {
|
|
self.key
|
|
}
|
|
|
|
/// Declared default used when an evaluator is unavailable or cannot return a value.
|
|
pub const fn default(self) -> i64 {
|
|
self.default
|
|
}
|
|
}
|