Fast and concurrent-safe feature flags for golang based on Redis. Inspired by the ruby rollout gem.
go get github.com/salesloft/gorollout
package main
import (
"github.com/go-redis/redis/v7"
rollout "github.com/salesloft/gorollout"
)
var (
apples = rollout.NewFeature("apples")
bananas = rollout.NewFeature("bananas")
)
func main() {
// instantiate a feature manager with a redis client and namespace prefix
manager := rollout.NewManager(redis.NewClient(&redis.Options{}), "rollout")
// activate a feature
manager.Activate(apples)
// deactivate a feature
manager.Deactivate(apples)
// rollout a feature to 25% of teams
manager.ActivatePercentage(apples, 25)
// explicitly activate a feature for team with id 99
manager.ActivateTeam(99, apples)
// check if a feature is active, globally
manager.IsActive(apples)
// check if a feature is active for a specific team (randomize percentage disabled)
manager.IsTeamActive(99, apples, false)
// check multiple feature flags at once
manager.IsActiveMulti(apples, bananas)
}
gorollout also includes a command line interface for viewing and managing feature flags.
docker buildx create --use
docker buildx build --platform linux/amd64,linux/arm64/v8 -t salesloft/gorollout:v1.1.2 . --push