Documentation ¶
Index ¶
- Constants
- Variables
- func GetNormalizedNumber(identifier string, bucketBy string) int
- func GetNormalizedNumberWithNormalizer(identifier string, bucketBy string, normalizer int) int
- func GetStructFieldValue(target interface{}, attr string) reflect.Value
- type Clause
- type Clauses
- type Distribution
- type Evaluation
- type Evaluator
- func (e Evaluator) BoolVariation(identifier string, target *Target, defaultValue bool) (bool, error)
- func (e Evaluator) Evaluate(identifier string, target *Target) (FlagVariation, error)
- func (e Evaluator) EvaluateAll(target *Target) (FlagVariations, error)
- func (e Evaluator) IntVariation(identifier string, target *Target, defaultValue int) (int, error)
- func (e Evaluator) JSONVariation(identifier string, target *Target, defaultValue map[string]interface{}) (map[string]interface{}, error)
- func (e Evaluator) NumberVariation(identifier string, target *Target, defaultValue float64) (float64, error)
- func (e Evaluator) StringVariation(identifier string, target *Target, defaultValue string) (string, error)
- type FeatureConfig
- func (fc *FeatureConfig) BoolVariation(target *Target) (Variation, error)
- func (fc FeatureConfig) Evaluate(target *Target) (Evaluation, error)
- func (fc FeatureConfig) EvaluateWithPreReqFlags(target *Target, prereqFlags map[string]FeatureConfig) (Evaluation, error)
- func (fc *FeatureConfig) GetKind() reflect.Kind
- func (fc FeatureConfig) GetSegmentIdentifiers() StrSlice
- func (fc FeatureConfig) GetVariationName(target *Target) string
- func (fc *FeatureConfig) IntVariation(target *Target) (Variation, error)
- func (fc *FeatureConfig) JSONVariation(target *Target) (Variation, error)
- func (fc *FeatureConfig) NumberVariation(target *Target) (Variation, error)
- func (fc *FeatureConfig) StringVariation(target *Target) (Variation, error)
- type FeatureState
- type FlagVariation
- type FlagVariations
- type PostEvalData
- type PostEvaluateCallback
- type Prerequisite
- type Query
- type Segment
- type SegmentRules
- type Segments
- type Serve
- type ServingRule
- type ServingRules
- type StrSlice
- type Tag
- type Target
- type Variation
- type VariationMap
- type Variations
- type WeightedVariation
Constants ¶
const (
// OneHundred MAX value for bucket
OneHundred = 100
)
Variables ¶
var ( // ErrQueryProviderMissing ... ErrQueryProviderMissing = errors.New("query field is missing in evaluator") // ErrVariationNotFound ... ErrVariationNotFound = errors.New("variation not found") // ErrEvaluationFlag ... ErrEvaluationFlag = errors.New("error while evaluating flag") // ErrFlagKindMismatch ... ErrFlagKindMismatch = errors.New("flag kind mismatch") )
var (
ErrNilFlag = errors.New("flag is nil")
)
Functions ¶
func GetNormalizedNumber ¶
GetNormalizedNumber returns normalized value with normalizer OneHundred
func GetNormalizedNumberWithNormalizer ¶
GetNormalizedNumberWithNormalizer returns a murmur hash value based on input arguments
func GetStructFieldValue ¶
GetStructFieldValue returns struct field value or simple value using attr field
Types ¶
type Clauses ¶
type Clauses []Clause
Clauses slice
type Distribution ¶
type Distribution struct { BucketBy string Variations []WeightedVariation }
Distribution object used for Percentage Rollout evaluations
func (*Distribution) GetKeyName ¶
func (d *Distribution) GetKeyName(target *Target) string
GetKeyName returns variation identifier based on target
type Evaluation ¶
Evaluation object is in most cases returned value from evaluation methods and contains results of evaluated feature flag for target object
type Evaluator ¶ added in v0.0.25
type Evaluator struct {
// contains filtered or unexported fields
}
Evaluator engine evaluates flag from provided query
func NewEvaluator ¶ added in v0.0.25
func NewEvaluator(query Query, postEvalCallback PostEvaluateCallback, logger logger.Logger) (*Evaluator, error)
NewEvaluator constructs evaluator with query instance
func (Evaluator) BoolVariation ¶ added in v0.0.25
func (e Evaluator) BoolVariation(identifier string, target *Target, defaultValue bool) (bool, error)
BoolVariation returns boolean evaluation for target
func (Evaluator) Evaluate ¶ added in v0.1.4
func (e Evaluator) Evaluate(identifier string, target *Target) (FlagVariation, error)
Evaluate exposes evaluate to the caller.
func (Evaluator) EvaluateAll ¶ added in v0.1.5
func (e Evaluator) EvaluateAll(target *Target) (FlagVariations, error)
EvaluateAll evaluates all the flags
func (Evaluator) IntVariation ¶ added in v0.0.25
IntVariation returns int evaluation for target
func (Evaluator) JSONVariation ¶ added in v0.0.25
func (e Evaluator) JSONVariation(identifier string, target *Target, defaultValue map[string]interface{}) (map[string]interface{}, error)
JSONVariation returns json evaluation for target
type FeatureConfig ¶
type FeatureConfig struct { DefaultServe Serve Environment string Feature string Kind string OffVariation string Prerequisites []Prerequisite Project string Rules ServingRules State FeatureState VariationToTargetMap []VariationMap Variations Variations Segments map[string]*Segment `json:"-"` }
FeatureConfig object is actually where feature flag evaluation happens. It contains all data like rules, default values, variations and segments
func (*FeatureConfig) BoolVariation ¶
func (fc *FeatureConfig) BoolVariation(target *Target) (Variation, error)
BoolVariation returns boolean evaluation for target
func (FeatureConfig) Evaluate ¶
func (fc FeatureConfig) Evaluate(target *Target) (Evaluation, error)
Evaluate feature flag and return Evaluation object
func (FeatureConfig) EvaluateWithPreReqFlags ¶ added in v0.0.25
func (fc FeatureConfig) EvaluateWithPreReqFlags(target *Target, prereqFlags map[string]FeatureConfig) (Evaluation, error)
EvaluateWithPreReqFlags evaluates a feature flag against any flags that may be prerequisites returns an Evaluation object
func (*FeatureConfig) GetKind ¶
func (fc *FeatureConfig) GetKind() reflect.Kind
GetKind returns kind of feature flag
func (FeatureConfig) GetSegmentIdentifiers ¶
func (fc FeatureConfig) GetSegmentIdentifiers() StrSlice
GetSegmentIdentifiers returns all segments
func (FeatureConfig) GetVariationName ¶
func (fc FeatureConfig) GetVariationName(target *Target) string
GetVariationName returns variation identifier for target
func (*FeatureConfig) IntVariation ¶
func (fc *FeatureConfig) IntVariation(target *Target) (Variation, error)
IntVariation returns int evaluation for target
func (*FeatureConfig) JSONVariation ¶
func (fc *FeatureConfig) JSONVariation(target *Target) (Variation, error)
JSONVariation returns json evaluation for target
func (*FeatureConfig) NumberVariation ¶
func (fc *FeatureConfig) NumberVariation(target *Target) (Variation, error)
NumberVariation returns number evaluation for target
func (*FeatureConfig) StringVariation ¶
func (fc *FeatureConfig) StringVariation(target *Target) (Variation, error)
StringVariation returns string evaluation for target
type FeatureState ¶
type FeatureState string
FeatureState represents feature flag ON or OFF state
const ( // FeatureStateOff represents OFF state FeatureStateOff FeatureState = "off" // FeatureStateOn represents ON state FeatureStateOn FeatureState = "on" )
type FlagVariation ¶ added in v0.1.5
type FlagVariation struct { FlagIdentifier string Kind rest.FeatureConfigKind Variation rest.Variation }
FlagVariation contains all required for ff-server to evaluate.
type FlagVariations ¶ added in v0.1.5
type FlagVariations []FlagVariation
FlagVariations list of FlagVariations
type PostEvalData ¶ added in v0.0.25
type PostEvalData struct { FeatureConfig *rest.FeatureConfig Target *Target Variation *rest.Variation }
PostEvalData holds information for post evaluation processing
type PostEvaluateCallback ¶ added in v0.0.25
type PostEvaluateCallback interface {
PostEvaluateProcessor(data *PostEvalData)
}
PostEvaluateCallback interface can be used for advanced processing of evaluated data
type Prerequisite ¶
Prerequisite object
type Query ¶ added in v0.0.25
type Query interface { GetSegment(identifier string) (rest.Segment, error) GetFlag(identifier string) (rest.FeatureConfig, error) GetFlags() ([]rest.FeatureConfig, error) GetFlagMap() (map[string]*rest.FeatureConfig, error) }
Query provides methods for segment and flag retrieval
type Segment ¶
type Segment struct { // Unique identifier for the target segment. Identifier string // Name of the target segment. Name string `json:"name"` CreatedAt *int64 ModifiedAt *int64 Environment *string Excluded StrSlice Included StrSlice // An array of rules that can cause a user to be included in this segment. Rules SegmentRules Tags []Tag Version int64 }
Segment object used in feature flag evaluation. Examples: beta users, premium customers
type SegmentRules ¶
type SegmentRules Clauses
SegmentRules is a set of clauses to determine if a target should be included in the segment.
func (SegmentRules) Evaluate ¶
func (c SegmentRules) Evaluate(target *Target, segments Segments) bool
Evaluate SegmentRules. This determines if a segment rule is being used to include a target with the segment. SegmentRules are similar to ServingRules except a ServingRule can contain multiple clauses but a Segment rule only contains one clause.
type ServingRule ¶
ServingRule object
type ServingRules ¶
type ServingRules []ServingRule
ServingRules slice of ServingRule
func (ServingRules) GetVariationName ¶
func (sr ServingRules) GetVariationName(target *Target, segments Segments, defaultServe Serve) string
GetVariationName returns variation identifier or defaultServe
type StrSlice ¶
type StrSlice []string
StrSlice helper type used for string slice operations
func (StrSlice) ContainsSensitive ¶
ContainsSensitive checks if slice contains string
type Target ¶
type Target struct { Identifier string Name string Anonymous *bool Attributes *map[string]interface{} }
Target object
func (Target) GetAttrValue ¶
GetAttrValue returns value from target with specified attribute
type Variation ¶
Variation object
type VariationMap ¶
VariationMap object is variation which belongs to segments and targets
type Variations ¶
type Variations []Variation
Variations slice of variation
func (Variations) FindByIdentifier ¶
func (v Variations) FindByIdentifier(identifier string) *Variation
FindByIdentifier returns Variation with identifier if exist in variations
type WeightedVariation ¶
WeightedVariation represents Percentage Rollout data