Skip to content
golang feature toggle library - a library to help make golang feature toggling clean and easy
Go Shell
Branch: master
Clone or download

Latest commit

Latest commit 137362d Oct 17, 2015

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Godeps
engines final touch Dec 10, 2014
sample adding FlipP function Dec 12, 2014
.gitignore
README.md
coverage
flipper.go
flipper_test.go adding a better syntax option Apr 1, 2015
testCoverage adjusting testCoverage script Dec 4, 2014
toggle.go
toggle_suite_test.go
toggle_test.go adding FlipP function Dec 12, 2014
wercker.yml

README.md

toggle

wercker status

GoDoc

CoverageStatus

supports env_variable backed toggling.

It can also be updated via a pubsub interface (tested w/ redis)

2 engines for toggle backing are included

- Local Engine (only env variable backed)
- Local Engine PubSub (env variable backed w/ updates via redis pubsub)

can be extended to support any 3rd party backing engine

func Flip(flg string, defaultFeature, newFeature interface{}, iargs ...interface{}) (responseInterfaceArray []interface{}) {}

func SetFeatureStatus(featureSignature, featureStatus string) (err error) {}

func IsActive(featureSignature string) (active bool) {}

func Close() {}

func Init(ns string, engine storageinterface.StorageEngine) {}

func ShowFeatures() map[string]*Feature {}

func RegisterFeature(featureSignature string) (err error) {}

func GetFullFeatureSignature(partialSignature string) (fullSignature string) {}

func RegisterFeatureWithStatus(featureSignature, statusValue string) (err error) {}

type Feature struct { name string Status string filter func(...interface{}) bool settings map[string]interface{} } func (s *Feature) UpdateStatus(newStatus string) {}

type DefaultEngine struct

func (s *DefaultEngine) GetFeatureStatusValue(featureSignature string) (status string, err error)

Sample usage: (./sample/main.go)

package main

import (
	"fmt"

	"github.com/xchapter7x/goutil/unpack"
	"github.com/xchapter7x/toggle"
)

func TestA(s string) (r string) {
	r = fmt.Sprintln("testa", s)
	fmt.Println(r)
	return
}

func TestB(s string) (r string) {
	r = fmt.Sprintln("testb", s)
	fmt.Println(r)
	return
}

func main() {
	toggle.Init("MAINTEST", nil)
	toggle.RegisterFeature("test")
	output := ""
	_, err := tgl.Flag("test").
			On(testB).
			Off(testA).
			Args("argstring").
			Returns(&output).
			Run()
	fmt.Println(output)
}

// or

func mainAlt() {
	toggle.Init("MAINTEST", nil)
	toggle.RegisterFeature("test")
	f := toggle.Flip("test", TestA, TestB, "argstring")
	var output string
	unpack.Unpack(f, &output)
	fmt.Println(output)

}
$ test=true go run sample/main.go
testb argstring

testb argstring



$ go run sample/main.go
testa argstring

testa argstring
You can’t perform that action at this time.