...
1 package featureflag
2
3 import "github.com/launchdarkly/go-sdk-common/v3/ldcontext"
4
5 const (
6 EnvironmentContextKind = "environment"
7 BannerContextKind = "banner"
8 BannerNameKind = "bannerName"
9 ClusterContextKind = "cluster"
10 ClusterNameKind = "clusterName"
11 OrganizationKind = "organization"
12 StoreContextKind = "store"
13 UserContextKind = "user"
14 )
15
16 type Contextualizer interface {
17 Kind() ldcontext.Kind
18 Key() string
19 }
20
21
22
23
24 type EnvironmentContext struct{}
25
26 func NewEnvironmentContext() EnvironmentContext { return EnvironmentContext{} }
27 func (EnvironmentContext) Kind() ldcontext.Kind { return EnvironmentContextKind }
28 func (c EnvironmentContext) Key() string { return "anonymous" }
29
30
31
32 type BannerContext struct{ key string }
33
34 func NewBannerContext(key string) BannerContext { return BannerContext{key: key} }
35 func (BannerContext) Kind() ldcontext.Kind { return BannerContextKind }
36 func (c BannerContext) Key() string { return c.key }
37
38
39
40 type ClusterContext struct{ key string }
41
42 func NewClusterContext(key string) ClusterContext { return ClusterContext{key: key} }
43 func (ClusterContext) Kind() ldcontext.Kind { return ClusterContextKind }
44 func (c ClusterContext) Key() string { return c.key }
45
46
47 type StoreContext struct{ key string }
48
49 func NewStoreContext(key string) StoreContext { return StoreContext{key: key} }
50 func (StoreContext) Kind() ldcontext.Kind { return StoreContextKind }
51 func (c StoreContext) Key() string { return c.key }
52
View as plain text