Feature Flags Try it

Feature flags are the greatest thing in the world so when we built them for ourselves at Prefab.cloud we decided to make the same APIs we use internally available to all.

Feature flags can be created and controlled from within the Prefab.cloud UI or via code. Each feature flag can be set to anywhere from 0 to 100% on.

feature flag UI

Whitelist

Additionally each feature flag can have an array of whitelisted tokens. When you call feature_is_on_for? you can pass in a token as well as additional attributes and if they match they will have the feature turned on.

Precedence

When a feature flag is evaluated, inclusion in the whitelist take priority to the percentage rollout, ie if you have rolled it out to 0% of people, but the user is in the whitelist then that feature will be ON.

client = Prefab::Client.new(api_key: "ACCT|APIKEY")
@feature_flags = client.feature_flag_client

# Create a flag that is on for 10% of traffic, the entire beta group and user:1
@feature_flags.upsert(Prefab::FeatureFlag.new(feature: "MyFeature", pct: 0.1, whitelisted: ["betas", "user:1"]))

# Use Flags By Themselves
puts @feature_flags.feature_is_on? "MyFeature"  # returns yes 10 pct of the time

# A single user should get the same result each time
puts @feature_flags.feature_is_on? "MyFeature", "user:1123" # with 10% probability user1123 will return yes, and if they do they always will

# Utilize the whitelisted attributes to easily feature flag groups of people
puts @feature_flags.feature_is_on_for? "MyFeature", "user:234", attributes: ["betas"]}"
PrefabCloudClient.Builder builder = new PrefabCloudClient.Builder();
final PrefabCloudClient prefabCloudClient = new PrefabCloudClient(builder);
final FeatureFlagClient featureFlagClient = prefabCloudClient.featureFlagClient();

//Create a flag that is on for 10 % of traffic, the entire beta group and user:1
featureFlagClient.upsert("MyFeature", Prefab.FeatureFlag.newBuilder()
    .setPct(0.1)
    .addWhitelisted("betas")
    .addWhitelisted("user:1")
    .build());

//returns yes 10 pct of the time
print(featureFlagClient.featureIsOn("MyFeature"));

//A single user should get the same result each time
//with 10 % probability user1123 will return yes, and if they do they always will
print(featureFlagClient.featureIsOnFor("MyFeature",
                                        Optional.of("user:1123"),
                                        Lists.newArrayList()));

//Utilize the whitelisted attributes to easily feature flag groups of people
print(featureFlagClient.featureIsOnFor("MyFeature",
                                        Optional.of("user:234"),
                                        Lists.newArrayList("betas")));
var prefab = new PrefabCloudClient();

prefab.featureFlagIsOn("MyFeature") // returns yes 10 pct of the time

// A single user should get the same result each time
prefab.featureFlagIsOn("MyFeature", "user:1123") //with 10% probability user1123 will return yes, and if they do they always will

//Utilize the whitelisted attributes to easily feature flag groups of people
prefab.featureFlagIsOn("user:234", ["betas"])

Implementation

Feature flags are stored in process so are lightning fast (no API calls when you access them).

When your feature flag client boots, it creates a local hashmap which will hold the config. The general purpose Prefab config system will then push & pull changes down to your clients. The expected latency is 1 minute for Free and SideProject tiers. Instant updates are available for other plans with expected latency < 10 ms.

Feature flags are built on top of the Prefab config store so all reliability notes are applicable for Feature Flags as well, which will vary by service tier.