Documentation ¶
Index ¶
Constants ¶
const DefaultScope = "default"
DefaultScope the key in which default features are set. By default `dcdr/features/<DefaultScope>`/<feature-name>.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Feature ¶
type Feature struct { FeatureType FeatureType `json:"feature_type"` Key string `json:"key"` Namespace string `json:"namespace"` Scope string `json:"scope"` Value interface{} `json:"value"` Comment string `json:"comment"` UpdatedBy string `json:"updated_by"` }
Feature KV model for feature flags
func NewFeature ¶
func NewFeature(name string, value interface{}, comment string, user string, scope string, ns string) (f *Feature)
NewFeature create a Feature
func (*Feature) FloatValue ¶
FloatValue cast Value to float64
func (*Feature) GetNamespace ¶
GetNamespace formats the fully scoped namespace
type FeatureMap ¶
type FeatureMap struct {
Dcdr Root `json:"dcdr"`
}
FeatureMap contains a nested map of `Features` and `Info`.
func EmptyFeatureMap ¶
func EmptyFeatureMap() (fm *FeatureMap)
EmptyFeatureMap helper method for constructing an empty `FeatureMap`.
func NewFeatureMap ¶
func NewFeatureMap(bts []byte) (*FeatureMap, error)
NewFeatureMap constructs a `FeatureMap` for marshalled JSON.
func (*FeatureMap) ToJSON ¶
func (fm *FeatureMap) ToJSON() ([]byte, error)
ToJSON helper method for marshalling a `FeatureMap` to JSON.
type FeatureScopes ¶
type FeatureScopes map[string]interface{}
FeatureScopes the map of percentile and boolean K/Vs.
type FeatureType ¶
type FeatureType string
FeatureType accepted feature types
const ( // Percentile percentile `FeatureType` Percentile FeatureType = "percentile" // Boolean boolean `FeatureType` Boolean FeatureType = "boolean" // Invalid invalid `FeatureType` Invalid FeatureType = "invalid" // FeatureScope scoping for feature keys FeatureScope = "features" )
func ParseValueAndFeatureType ¶
func ParseValueAndFeatureType(v string) (interface{}, FeatureType)
ParseValueAndFeatureType string to type helper
type Info ¶
type Info struct { CurrentSHA string `json:"current_sha,omitempty"` LastModifiedDate int64 `json:"last_modfied_date,omitempty"` }
Info contains the metadata for the current `FeatureMap`.
type Root ¶
type Root struct { sync.RWMutex Info *Info `json:"info"` FeatureScopes FeatureScopes `json:"features"` }
Root wrapper struct for `Info` and `Features`.
func (*Root) CurrentSHA ¶
CurrentSHA accessor for the underlying `CurrentSHA` found in `Info`.
func (*Root) Defaults ¶
func (d *Root) Defaults() FeatureScopes
Defaults returns `Features` within the 'default' scope.
func (*Root) InScope ¶
func (d *Root) InScope(scope string) FeatureScopes
InScope returns the `Features` found within `scope`.
func (*Root) MergedScopes ¶
func (d *Root) MergedScopes(scopes ...string) FeatureScopes
MergedScopes given a slice of scopes in priority order will return a merged set of `Featured` including the 'default' scope.