Feature based rollout for Golang.
go get github.com/fbeline/rollout
rollout is a library used to create feature rollouts based on percentage.
usage examples:
-
You have a new feature and you want to expose that only for 5% of your userbase.
-
A/B tests.
The library is free of any persistence system, but I strongly recommend to you to persist the rollout state at disk instead make it hardcoded. In that way, you will be able to fast manipulate the rollout percentages and status.
import the rollout package
import "github.com/fbeline/rollout"
var foo = rollout.Feature{Name: "foo", Percentage: 0.5, Active: true, Whitelist: []string{}}
var bar = rollout.Feature{Name: "bar", Percentage: 0.7, Active: true, Whitelist: []string{}}
var features = []rollout.Feature{foo, bar}
var r = rollout.Create(features)
<rollout instance>.IsActive("featureName", "UserId")
The feature name is used as a unique key. If the feature exists it will be updated otherwise created.
var newFoo = rollout.Feature{Name: "foo", Percentage: 0.8, Active: true}
<rollout instance>.Set(newFoo)
<rollout instance>.IsFeatureActive("featureName")
<rollout instance>.Activate("featureName")
<rollout instance>.Deactivate("featureName")
The first value (f) is assigned the value stored under the feature name.The second value (ok) is a bool that is true if the feature exists, and false if not.
f, ok := <rollout instance>.Get("featureName")
<rollout instance>.GetAll()
MIT