1
package feature
2

3
import (
4
    "github.com/garyburd/redigo/redis"
5
    "github.com/earaujoassis/space/memstore"
6
)
7

8
// IsActive is used to check if a feature-gate `name` is currently active (through Redis keys)
9 2
func IsActive(name string) bool {
10 2
    memstore.Start()
11 2
    defer memstore.Close()
12 2
    if featureExists, _ := redis.Bool(memstore.Do("HEXISTS", "feature.gates", name)); !featureExists {
13 2
        return false
14
    }
15 2
    return true
16
}
17

18
// Enable makes a feature-gate `name` currently active (through Redis keys)
19 2
func Enable(name string) {
20 2
    memstore.Start()
21 2
    defer memstore.Close()
22 2
    memstore.Do("HSET", "feature.gates", name, 1)
23
}
24

25
// Disable makes a feature-gate `name` currently inactive (through Redis keys)
26 2
func Disable(name string) {
27 2
    memstore.Start()
28 2
    defer memstore.Close()
29 2
    memstore.Do("HDEL", "feature.gates", name)
30
}

Read our documentation on viewing source code .

Loading