A simple, generic rules engine.
Project description
Rules Engine
A simple, generic rules engine. Inspired by Martin Fowler's 2009 blog post.
Installation
Install the package funnel_rules_engine
version 1.1+
from PyPi.
The recommended requirements.txt
line is funnel_rules_engine~=1.1
.
Current Functionality
Rule
A combination of a condition and an action, both of which are callables such as functions or lambdas.
Otherwise
Special case of Rule where the action always fires. Suitable as a catch-all last rule.
NoAction
Special case of Rule where None
is returned if the condition is met. Useful for halting the execution of .run()
RulesEngine
A generic rules engine that accepts a list of Rule
s and some input to apply the rules to. The rules engine can either apply the first rule that matches (run
) or all the rules that matches (run_all
). In addition, rules can be evaluated and executed in parallel (run_all_in_parallel
).
For more on rules engines, see Martin Fowler's blog post.
run
Only apply the first rule that matches and return its result. This is comparable to the behaviour of a structured switch statement or an arbitrary conditional statement.
run_all
Apply all rules that match. The result is returned as a list.
run_all_in_parallel
Evaluate and apply all rules in parallel. The result is returned as a list.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for funnel_rules_engine-1.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 621b72abd89864f8b9b717a4081006848f6f6d80449223b26af389c6909d6122 |
|
MD5 | 0d6c9e40d4c97eb0ee07c0abc0114214 |
|
BLAKE2b-256 | ed06efeb352e4e3a1b28b79855b9cb21bb4bab44216f5b38b62a63ff8bb4562b |