-
-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathmain.go
45 lines (38 loc) · 1.07 KB
/
main.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
package main
import (
"context"
"fmt"
"github.com/thomaspoignant/go-feature-flag/ffcontext"
"log"
"log/slog"
"time"
"github.com/thomaspoignant/go-feature-flag/retriever/fileretriever"
ffclient "github.com/thomaspoignant/go-feature-flag"
)
func main() {
// Before running this code please check the flag.yaml file
// You can update the dates of the steps in the rollout to see it working.
err := ffclient.Init(ffclient.Config{
PollingInterval: 10 * time.Second,
LeveledLogger: slog.Default(),
Context: context.Background(),
Retriever: &fileretriever.Retriever{
Path: "examples/rollout_scheduled/flags.goff.yaml",
},
})
// Check init errors.
if err != nil {
log.Fatal(err)
}
// defer closing ffclient
defer ffclient.Close()
// create users
user := ffcontext.NewEvaluationContextBuilder("785a14bf-d2c5-4caa-9c70-2bbc4e3732a5").
AddCustom("beta", "true").
Build()
// Call multiple time the same flag to see the change in time.
for true {
time.Sleep(1 * time.Second)
fmt.Println(ffclient.BoolVariation("new-admin-access", user, false))
}
}