...
A targeting object represents a set of rules which that need to be evaluated, in order to retrieve which outputs the best-fit variation for a particular flag. Rulesets need to be evaluated in priority order. The first matching rule will dictate the resulting output (i.e. the recommended variation).
Data Models
Evaluation Engine
The ruleset evaluation engine is essentially a method used to select selects the variation for in which the first rule that is satisfied. It can be defined recursively in 4 lines. Note that the following bellow below is just pseudo-code aimed to illustrate the core logic that is used for flag evaluation.
Code Block |
---|
evaluate(ruleset, fallthrough_variation) :: (Ruleset, Variation) -> Variation if (ruleset is empty) return fallthrough_variation cons {condition, identity, segement, variation} = ruleset.pop() if (<condition> matches <identity | segment>) then return variation return evaluate(ruleset, fallthrough_variation) |