...

Source file src/edge-infra.dev/pkg/lib/featureflag/contexts.go

Documentation: edge-infra.dev/pkg/lib/featureflag

     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  // EnvironmentContext refers to an environment in LD, such as dev1, stage1... It is not
    22  // targeted to a specific Context within the environment, i.e. the value will depend on
    23  // the configured default or fallthough value.
    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  // BannerContext refers to a banner. The key is the banner id, such as ${banner_id},
    31  // referred to as bannerEdgeID in other places.
    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  // ClusterContext refers to a cluster. The key is the cluster id, such as ${cluster_uuid},
    39  // referred to as clusterEdgeID in other places.
    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  // StoreContext refers to a store. The key is the Store field from the EdgeInfo CM.
    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