Documentation
¶
Overview ¶
Package evalcore provides the hashing, context conversion and JSON helpers of the core module.
Index ¶
- func BuildHash(flagName, bucketingKey string, maxPercentage uint32) uint32
- func Contains(s []string, str string) bool
- func ContextToMap(ctx ffcontext.Context) map[string]any
- func ContextToMapInto(dst map[string]any, ctx ffcontext.Context) map[string]any
- func ConvertEvaluationCtxFromRequest(targetingKey string, custom map[string]any) ffcontext.EvaluationContext
- func GetNestedFieldValue(ctx map[string]any, bucketingKey string) (any, error)
- func Hash(s string) uint32
- func IsIntegral(val float64) bool
- func IsJSONObject(input string) bool
- func JSONTypeExtractor(variation any) string
- func StrTrim(query string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildHash ¶
BuildHash is building the hash based on the different properties of the evaluation.
func ContextToMap ¶
ContextToMap convert the context to a MAP to use the query on it.
func ContextToMapInto ¶
ContextToMapInto is ContextToMap filling (and returning) the empty map dst, that the caller can reuse to avoid allocating a map for every evaluation.
func ConvertEvaluationCtxFromRequest ¶
func ConvertEvaluationCtxFromRequest( targetingKey string, custom map[string]any, ) ffcontext.EvaluationContext
ConvertEvaluationCtxFromRequest convert the result of an unmarshal request from the API to a ffcontext.EvaluationContext.
func GetNestedFieldValue ¶
GetNestedFieldValue returns the value from a nested path in the given map. If the path does not exist or an error occurs, it returns an error.
func IsIntegral ¶
IsIntegral returns true if the float is an integer.
func IsJSONObject ¶
IsJSONObject checks if input is a valid JSON.
func JSONTypeExtractor ¶
JSONTypeExtractor returns the JSON type name of the variation value.
func StrTrim ¶
StrTrim returns query as a single line, for the rules-format grammar: the leading spaces of every line, the line ends (LF or CRLF) and the blank lines are removed. Two lines are joined with a space unless the text already has a separator there (the previous line ends with a space) or the join cannot merge two tokens (after an opening bracket, before a closing bracket or a comma). A line break inside a quoted value becomes exactly one space (a space that already ends the line is reused). A query on one line only loses its leading spaces.
It must not be used on a JsonLogic query: that is JSON, which ignores whitespace between tokens and rejects a newline inside a string, so it is read as written.
Types ¶
This section is empty.