package featureflag import "github.com/launchdarkly/go-sdk-common/v3/ldcontext" const ( EnvironmentContextKind = "environment" BannerContextKind = "banner" BannerNameKind = "bannerName" ClusterContextKind = "cluster" ClusterNameKind = "clusterName" OrganizationKind = "organization" StoreContextKind = "store" UserContextKind = "user" ) type Contextualizer interface { Kind() ldcontext.Kind Key() string } // EnvironmentContext refers to an environment in LD, such as dev1, stage1... It is not // targeted to a specific Context within the environment, i.e. the value will depend on // the configured default or fallthough value. type EnvironmentContext struct{} func NewEnvironmentContext() EnvironmentContext { return EnvironmentContext{} } func (EnvironmentContext) Kind() ldcontext.Kind { return EnvironmentContextKind } func (c EnvironmentContext) Key() string { return "anonymous" } // BannerContext refers to a banner. The key is the banner id, such as ${banner_id}, // referred to as bannerEdgeID in other places. type BannerContext struct{ key string } func NewBannerContext(key string) BannerContext { return BannerContext{key: key} } func (BannerContext) Kind() ldcontext.Kind { return BannerContextKind } func (c BannerContext) Key() string { return c.key } // ClusterContext refers to a cluster. The key is the cluster id, such as ${cluster_uuid}, // referred to as clusterEdgeID in other places. type ClusterContext struct{ key string } func NewClusterContext(key string) ClusterContext { return ClusterContext{key: key} } func (ClusterContext) Kind() ldcontext.Kind { return ClusterContextKind } func (c ClusterContext) Key() string { return c.key } // StoreContext refers to a store. The key is the Store field from the EdgeInfo CM. type StoreContext struct{ key string } func NewStoreContext(key string) StoreContext { return StoreContext{key: key} } func (StoreContext) Kind() ldcontext.Kind { return StoreContextKind } func (c StoreContext) Key() string { return c.key }