Documentation ¶
Index ¶
- Constants
- type AnyValue
- type Evaluators
- type Flags
- type FractionalEvaluator
- type IEvaluator
- type JSONEvaluator
- func (je *JSONEvaluator) GetState() (string, error)
- func (je *JSONEvaluator) ResolveAllValues(ctx context.Context, reqID string, context map[string]any) []AnyValue
- func (je *JSONEvaluator) ResolveBooleanValue(ctx context.Context, reqID string, flagKey string, context map[string]any) (value bool, variant string, reason string, metadata map[string]interface{}, ...)
- func (je *JSONEvaluator) ResolveFloatValue(ctx context.Context, reqID string, flagKey string, context map[string]any) (value float64, variant string, reason string, metadata map[string]interface{}, ...)
- func (je *JSONEvaluator) ResolveIntValue(ctx context.Context, reqID string, flagKey string, context map[string]any) (value int64, variant string, reason string, metadata map[string]interface{}, ...)
- func (je *JSONEvaluator) ResolveObjectValue(ctx context.Context, reqID string, flagKey string, context map[string]any) (value map[string]any, variant string, reason string, ...)
- func (je *JSONEvaluator) ResolveStringValue(ctx context.Context, reqID string, flagKey string, context map[string]any) (value string, variant string, reason string, metadata map[string]interface{}, ...)
- func (je *JSONEvaluator) SetState(payload sync.DataSync) (map[string]interface{}, bool, error)
- type JSONEvaluatorOption
- type LegacyFractionalEvaluatordeprecated
- type SemVerComparisonEvaluator
- type SemVerOperator
- type StringComparisonEvaluator
Constants ¶
const ( LegacyFractionEvaluationName = "fractionalEvaluation" LegacyFractionEvaluationLink = "https://flagd.dev/concepts/#migrating-from-legacy-fractionalevaluation" )
const ( StartsWithEvaluationName = "starts_with" EndsWithEvaluationName = "ends_with" )
const (
Disabled = "DISABLED"
)
const FractionEvaluationName = "fractional"
const (
SelectorMetadataKey = "scope"
)
const SemVerEvaluationName = "sem_ver"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnyValue ¶
type Evaluators ¶
type Evaluators struct {
Evaluators map[string]json.RawMessage `json:"$evaluators"`
}
type FractionalEvaluator ¶ added in v0.5.4
func NewFractionalEvaluator ¶ added in v0.5.4
func NewFractionalEvaluator(logger *logger.Logger) *FractionalEvaluator
func (*FractionalEvaluator) FractionalEvaluation ¶ added in v0.5.4
func (fe *FractionalEvaluator) FractionalEvaluation(values, data any) any
type IEvaluator ¶
type IEvaluator interface { GetState() (string, error) SetState(payload sync.DataSync) (map[string]interface{}, bool, error) ResolveBooleanValue( ctx context.Context, reqID string, flagKey string, context map[string]any) (value bool, variant string, reason string, metadata map[string]interface{}, err error) ResolveStringValue( ctx context.Context, reqID string, flagKey string, context map[string]any) ( value string, variant string, reason string, metadata map[string]interface{}, err error) ResolveIntValue( ctx context.Context, reqID string, flagKey string, context map[string]any) ( value int64, variant string, reason string, metadata map[string]interface{}, err error) ResolveFloatValue( ctx context.Context, reqID string, flagKey string, context map[string]any) ( value float64, variant string, reason string, metadata map[string]interface{}, err error) ResolveObjectValue( ctx context.Context, reqID string, flagKey string, context map[string]any) ( value map[string]any, variant string, reason string, metadata map[string]interface{}, err error) ResolveAllValues( ctx context.Context, reqID string, context map[string]any) (values []AnyValue) }
IEvaluator implementations store the state of the flags, do parsing and validation of the flag state and evaluate flags in response to handlers.
type JSONEvaluator ¶
func NewJSONEvaluator ¶
func NewJSONEvaluator(logger *logger.Logger, s *store.Flags, opts ...JSONEvaluatorOption) *JSONEvaluator
func (*JSONEvaluator) GetState ¶
func (je *JSONEvaluator) GetState() (string, error)
func (*JSONEvaluator) ResolveAllValues ¶
func (*JSONEvaluator) ResolveBooleanValue ¶
func (*JSONEvaluator) ResolveFloatValue ¶
func (*JSONEvaluator) ResolveIntValue ¶
func (*JSONEvaluator) ResolveObjectValue ¶
func (*JSONEvaluator) ResolveStringValue ¶
type JSONEvaluatorOption ¶ added in v0.5.4
type JSONEvaluatorOption func(je *JSONEvaluator)
func WithEvaluator ¶ added in v0.5.4
func WithEvaluator(name string, evalFunc func(interface{}, interface{}) interface{}) JSONEvaluatorOption
type LegacyFractionalEvaluator
deprecated
added in
v0.6.4
Deprecated: LegacyFractionalEvaluator is deprecated. This will be removed prior to v1 release.
func NewLegacyFractionalEvaluator ¶ added in v0.6.4
func NewLegacyFractionalEvaluator(logger *logger.Logger) *LegacyFractionalEvaluator
func (*LegacyFractionalEvaluator) LegacyFractionalEvaluation ¶ added in v0.6.4
func (fe *LegacyFractionalEvaluator) LegacyFractionalEvaluation(values, data interface{}) interface{}
type SemVerComparisonEvaluator ¶ added in v0.5.4
func NewSemVerComparisonEvaluator ¶ added in v0.5.4
func NewSemVerComparisonEvaluator(log *logger.Logger) *SemVerComparisonEvaluator
func (*SemVerComparisonEvaluator) SemVerEvaluation ¶ added in v0.5.4
func (je *SemVerComparisonEvaluator) SemVerEvaluation(values, _ interface{}) interface{}
SemVerEvaluation checks if the given property matches a semantic versioning condition. It returns 'true', if the value of the given property meets the condition, 'false' if not. As an example, it can be used in the following way inside an 'if' evaluation:
{ "if": [ { "sem_ver": [{"var": "version"}, ">=", "1.0.0"] }, "red", null ] }
This rule can be applied to the following data object, where the evaluation will resolve to 'true':
{ "version": "2.0.0" }
Note that the 'sem_ver' evaluation rule must contain exactly three items: 1. Target property: this needs which both resolve to a semantic versioning string 2. Operator: One of the following: '=', '!=', '>', '<', '>=', '<=', '~', '^' 3. Target value: this needs which both resolve to a semantic versioning string
type SemVerOperator ¶ added in v0.5.4
type SemVerOperator string
const ( Equals SemVerOperator = "=" NotEqual SemVerOperator = "!=" Less SemVerOperator = "<" LessOrEqual SemVerOperator = "<=" GreaterOrEqual SemVerOperator = ">=" Greater SemVerOperator = ">" MatchMajor SemVerOperator = "^" MatchMinor SemVerOperator = "~" )
type StringComparisonEvaluator ¶ added in v0.5.4
func NewStringComparisonEvaluator ¶ added in v0.5.4
func NewStringComparisonEvaluator(log *logger.Logger) *StringComparisonEvaluator
func (StringComparisonEvaluator) EndsWithEvaluation ¶ added in v0.5.4
func (sce StringComparisonEvaluator) EndsWithEvaluation(values, _ interface{}) interface{}
EndsWithEvaluation checks if the given property ends with a certain prefix. It returns 'true', if the value of the given property starts with the prefix, 'false' if not. As an example, it can be used in the following way inside an 'if' evaluation:
{ "if": [ { "ends_with": [{"var": "email"}, "faas.com"] }, "red", null ] }
This rule can be applied to the following data object, where the evaluation will resolve to 'true':
{ "email": "user@faas.com" }
Note that the 'ends_with' evaluation rule must contain exactly two items, which both resolve to a string value
func (*StringComparisonEvaluator) StartsWithEvaluation ¶ added in v0.5.4
func (sce *StringComparisonEvaluator) StartsWithEvaluation(values, _ interface{}) interface{}
StartsWithEvaluation checks if the given property starts with a certain prefix. It returns 'true', if the value of the given property starts with the prefix, 'false' if not. As an example, it can be used in the following way inside an 'if' evaluation:
{ "if": [ { "starts_with": [{"var": "email"}, "user@faas"] }, "red", null ] }
This rule can be applied to the following data object, where the evaluation will resolve to 'true':
{ "email": "user@faas.com" }
Note that the 'starts_with' evaluation rule must contain exactly two items, which both resolve to a string value