earaujoassis / space
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 1
func IsActive(name string) bool {
10 1
    memstore.Start()
11 1
    defer memstore.Close()
12 1
    if featureExists, _ := redis.Bool(memstore.Do("HEXISTS", "feature.gates", name)); !featureExists {
13 1
        return false
14
    }
15 1
    return true
16
}
17

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

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

Read our documentation on viewing source code .

Loading