TODO
Rule Engine written in Python.
Why? Why not.
Why the name? Good 'ol nerdy Star Wars reference in which the Empire rules the galaxy.
The provided data against which Empyre
will check Rules
/Matchers
.
A condition to be evaluated against the Context
, defined by:
- path: a json-path used to retrieve data from the
Context
- value: a value that will be matched against the path-retrieved value(s)
- op: the
Operator
that will be used to perform the matching between the above - comp: a
Comparator
telling if the evaluation should produceTrue
orFalse
- transform: an optional callable to modify the
Context
values before the match - matchers: a list of
Matchers
to be used with theand
/or
Operators
The expectation for a matcher to match or not. Can be either is
or not
.
The matching operation performed by a Matcher
.
Available operators are of different kinds: logical, comparison, membership and regex.
To be used with Matcher's child Matchers
and_
: all the child matchers should be Trueor_
: at least one child matcher should be True
A comparison between the context-extracted value (left hand) and the Matcher value (right hand):
eq
: equivalent to ==gt
: equivalent to >lt
: equivalent to <ge
: equivalent to >=le
: equivalent to <=
Checks that the context-extracted value is present in the Matcher value
in_
Check for a regex match of the Matcher's value against the context-extracted values
re
The output returned is all defined Matchers match. Can be of 4 kinds:
VALUE
: a fixed valueDATA
: a dynamic/nested container of values, either extracted from the context or fixedEVENT
: a DATA outcome with a fixed identifierRULE
: another Rule to be evaluated, for complex chains of evaluations
Represents a set of Matchers to be evaluated against the context that eventually produces a set of Outcomes. Defined by:
- matchers: a list of Matchers
- op: the
and_
/or_
condition to extract matcher's expected results - comp: a
Comparator
for the op's result