mirror of
https://github.com/minio/minio.git
synced 2025-02-13 14:48:09 -05:00
Merge pull request #574 from fkautz/pr_out_adding_feature_flags
This commit is contained in:
commit
a4b4e9c148
30
pkg/featureflags/featureflag.go
Normal file
30
pkg/featureflags/featureflag.go
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package featureflags
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
var features = make(map[string]bool)
|
||||||
|
var lock = &sync.RWMutex{}
|
||||||
|
|
||||||
|
// Get feature will return true if the feature is enabled, otherwise false
|
||||||
|
func Get(feature string) bool {
|
||||||
|
lock.RLock()
|
||||||
|
defer lock.RUnlock()
|
||||||
|
res := features[feature]
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable a feature
|
||||||
|
func Enable(feature string) {
|
||||||
|
lock.Lock()
|
||||||
|
defer lock.Unlock()
|
||||||
|
features[feature] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable a feature
|
||||||
|
func Disable(feature string) {
|
||||||
|
lock.Lock()
|
||||||
|
defer lock.Unlock()
|
||||||
|
features[feature] = false
|
||||||
|
}
|
22
pkg/featureflags/featureflag_test.go
Normal file
22
pkg/featureflags/featureflag_test.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package featureflags
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestFeatureFlag(t *testing.T) {
|
||||||
|
foo := Get("foo")
|
||||||
|
if foo {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
Enable("foo")
|
||||||
|
foo = Get("foo")
|
||||||
|
if !foo {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
Disable("foo")
|
||||||
|
foo = Get("foo")
|
||||||
|
if foo {
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
6
pkg/featureflags/features.go
Normal file
6
pkg/featureflags/features.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package featureflags
|
||||||
|
|
||||||
|
const (
|
||||||
|
// MultipartPutObject ...
|
||||||
|
MultipartPutObject = "minio.multipart_put_object"
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user