Feature Flags Try it

Feature flags are the greatest thing in the world and 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. Each feature flag can be set to anywhere from 0 to 100% on.

feature flag UI

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.

client = Prefab::Client.new(api_key: "ACCT_ID|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 client = new PrefabCloudClient();
// Create a flag that is on for 10% of traffic, the entire beta group and user:1
client.setFeatureFlag("MyFeature", 0.1, ["betas", "user:1"]);

flag = client.getFeatureFlag(featureName);
flag.isOn("MyFeature") // returns yes 10 pct of the time

// A single user should get the same result each time
flag.isOn("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
flag.isOn("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 will subscribe to changes from the API. The general purpose Prefab config system will then push changes down to your clients. The expected latency is < 10 ms. Feature flags are built on top of the Prefab config store so all reliability notes are applicable for Feature Flags as well.