-
Notifications
You must be signed in to change notification settings - Fork 0
/
featureflag.go
54 lines (45 loc) · 1.29 KB
/
featureflag.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package pkg
import (
"crypto/tls"
"fmt"
"net/http"
"github.com/Unleash/unleash-client-go/v3"
"github.com/Unleash/unleash-client-go/v3/context"
)
func Run() {
ctx := context.Context{
UserId: AppConfig.UserId,
Properties: map[string]string{"Fund": "fundo"},
}
enabled := unleash.IsEnabled(AppConfig.FlagName, unleash.WithContext(ctx))
fmt.Printf("%s is %v\n", AppConfig.FlagName, enabled)
}
func InitUnleash() {
if err := unleash.Initialize(
unleash.WithListener(&unleash.DebugListener{}),
unleash.WithAppName(AppConfig.AppName),
unleash.WithUrl(AppConfig.Url),
unleash.WithProjectName(AppConfig.ProjectName),
unleash.WithEnvironment(AppConfig.Environment),
unleash.WithCustomHeaders(http.Header{"Authorization": { AppConfig.Authorization }}),
); err != nil {
panic(err)
}
unleash.WaitForReady()
}
func InitGitLab() {
transCfg := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
cli := &http.Client{Transport: transCfg}
if err := unleash.Initialize(
unleash.WithListener(&unleash.DebugListener{}),
unleash.WithAppName(AppConfig.AppName),
unleash.WithUrl(AppConfig.Url),
unleash.WithInstanceId(AppConfig.InstanceId),
unleash.WithHttpClient(cli),
); err != nil {
panic(err)
}
unleash.WaitForReady()
}