All Projects → jimdoescode → Feature

jimdoescode / Feature

A feature flag implementation in Go

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Feature

jest-launchdarkly-mock
Easily unit test LaunchDarkly feature flagged components with jest
Stars: ✭ 14 (-51.72%)
Mutual labels:  feature-flags
unleash-client-php
Unleash client SDK for PHP
Stars: ✭ 24 (-17.24%)
Mutual labels:  feature-flags
Sail
Sail is a lightweight Rails engine that brings an admin panel for managing configuration settings on a live Rails app
Stars: ✭ 484 (+1568.97%)
Mutual labels:  feature-flags
toggler
toggler is a feature flag service to decouple deployment, feature enrollment and experiments
Stars: ✭ 27 (-6.9%)
Mutual labels:  feature-flags
python-client
Python SDK client for Split Software
Stars: ✭ 12 (-58.62%)
Mutual labels:  feature-flags
Flags
⛳️ Feature Flags for Next.js
Stars: ✭ 277 (+855.17%)
Mutual labels:  feature-flags
erlang-server-sdk
LaunchDarkly Server-Side SDK for Erlang/Elixir
Stars: ✭ 16 (-44.83%)
Mutual labels:  feature-flags
Ember Api Feature Flags
API based, read-only feature flags for Ember
Stars: ✭ 11 (-62.07%)
Mutual labels:  feature-flags
growthbook
Open Source Feature Flagging and A/B Testing Platform
Stars: ✭ 2,342 (+7975.86%)
Mutual labels:  feature-flags
Feature Flags
Feature flags API written in Go
Stars: ✭ 375 (+1193.1%)
Mutual labels:  feature-flags
road-to-orleans
This repository illustrates the road to orleans with practical, real-life examples. From most basic, to more advanced techniques.
Stars: ✭ 55 (+89.66%)
Mutual labels:  feature-flags
ios-client-sdk
LaunchDarkly Client-side SDK for iOS (Swift and Obj-C)
Stars: ✭ 45 (+55.17%)
Mutual labels:  feature-flags
Unleash
Unleash is the open source feature toggle service.
Stars: ✭ 4,679 (+16034.48%)
Mutual labels:  feature-flags
ruby-server-sdk
LaunchDarkly Server-side SDK for Ruby
Stars: ✭ 25 (-13.79%)
Mutual labels:  feature-flags
Fun with flags
Feature Flags/Toggles for Elixir
Stars: ✭ 554 (+1810.34%)
Mutual labels:  feature-flags
featurehub
FeatureHub - cloud native feature flags, A/B testing and remote configuration service. Real-time streaming feature updates. Provided with Java, JavaScript, Go, .Net, Android and Flutter SDKs.
Stars: ✭ 136 (+368.97%)
Mutual labels:  feature-flags
Tweek
Tweek - an open source feature manager
Stars: ✭ 268 (+824.14%)
Mutual labels:  feature-flags
Babel Plugin Debug Macros
Stars: ✭ 14 (-51.72%)
Mutual labels:  feature-flags
Featuretoggle
Simple, reliable feature toggles in .NET
Stars: ✭ 641 (+2110.34%)
Mutual labels:  feature-flags
Flopflip
🎚Flip or flop features in your React application in real-time backed by flag provider of your choice 🚦
Stars: ✭ 334 (+1051.72%)
Mutual labels:  feature-flags

Go Feature Flags

This is a simple feature flagging library. It allows you to enable a feature for a certain percentage of a group or a population.

Create a new feature flag by using the feature.NewFlag method. Provide the feature name and the threshold for how often the feature should be enabled.

flag := feature.NewFlag("my new great feature", 0.25)

How's it work?

Feature flagging works by taking the group's identifier combining it with the name of the flag and reducing that hash to a value between 0 and 1. If that value is less than the threshold set for the flag then the feature is enabled. Otherwise it's disabled. This allows you to execute experiments on certain groups or cautiously roll out a new feature.

Groups

The groups interface is what will let you consistently bucket a feature.

type User struct {
	id uint
	isAdmin bool
	...
}

func (u *User) GetGroupIdentifier() []byte {
	buf := make([]byte, 8)
	binary.PutUvarint(buf, u.id)
	return buf
}

func (u *User) AlwaysEnabled() bool {
	return u.isAdmin //Admins should have all feature flags enabled.
}

It's important that the GetGroupIdentifier method should return byte slices that are unique to each member. In the example, the group identifier is the id field given to each User in the database. This works great because it shouldn't change and is unique to each user.

Once you've satified the interface you can use the EnabledFor method.

flag := feature.NewFlag("my new great feature", 0.25)
user := &User{123, false, ...} // This would be fetched from a db or something
if flag.EnabledFor(user) {
	// Do feature
} else {
	// Don't do feature
}

In our example the feature is enabled for 25% of the users. Those users within the 25% threshold will always have the feature enabled. Increasing the threshold percentage will increase the number of users who can see the feature, decreasing will reduce the number of users who can see the feature. Decreasing the threshold to 10% will mean that the 15% of users who saw the feature when the threshold was at 25% will now not see the feature.

Certain groups might need to always have a feature flag enabled. This can be done by returning true for the AlwaysEnabled method of the feature.Group interface. In our example if a user has the isAdmin flag set to true then that user will have access to all features.

Random flagging

If you don't need consistent bucketing then you can use the the Enabled function. This function will randomly return that a feature is enabled but the number of enabled vs disabled results will converge on the flag's threshold. In our case that's 25%. Which means that if we called Enabled 100 times then ~25 of those calls would return true.

if flag.Enabled() {
	// Do feature
} else {
	// Don't do feature
}

Additional Documentation

GoDoc: https://godoc.org/github.com/jimdoescode/feature

Credit where it's due

The technique for reducing an identifier to a boolean comes from this Etsy feature library which was written in PHP.

All the code in this repo is licensed under the MIT license

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].