MoonBit-native feature flag, segment targeting, rollout and validation toolkit
moon add WhisperJXH/moonflagsWhisperJXH/moonflagslet rollout = @moonflags.Rollout([
@moonflags.WeightedVariant("control", 6000),
@moonflags.WeightedVariant("beta", 4000),
], seed="checkout-v1")
let rule = @moonflags.Rule(
"paid-cn-users",
conditions=[
@moonflags.str_eq("country", "CN"),
@moonflags.bool_eq("paid", true),
],
rollout~,
reason="paid_user_rollout",
)
let flag = @moonflags.Flag(
"checkout_flow",
["control", "beta"],
"control",
rules=[rule],
)
let ctx = @moonflags.Context(user_key="user-42")
.with_str("country", "CN")
.with_bool("paid", true)
let result = flag.evaluate(ctx)moon check
moon build
moon test
moon run cmd/main
moon publish --dry-run#alias(new, deprecated="Use `Diagnostic()` instead")
fn Diagnostic::Diagnostic(severity : Severity, path : StringView, message : StringView) -> Diagnostic#alias(new, deprecated="Use `Rollout()` instead")
fn Rollout::Rollout(allocations : ArrayView[WeightedVariant], seed? : StringView) -> Rollout#alias(new, deprecated="Use `WeightedVariant()` instead")
fn WeightedVariant::WeightedVariant(variant : StringView, weight : Int) -> WeightedVariantfn rollout_bucket(seed : StringView, flag_key : StringView, user_key : StringView) -> IntMoonBit-native feature flag, segment targeting, rollout and validation toolkit