A simple rule engine implemented in python
Project description
Sauron Rule engine - One engine to rule them all
A simple rule engine to be used in python, it is based on simple rules and actions that can be chained with each other. The idea is to run the rule processor on events and have it mutate data or trigger actions
Install
pip install sauron-rule-engine
Use it
A simple example of the usage
from sauron_rule_engine.rule_engine import GenericRuleProcessor
class CounterRuleProcessor(GenericRuleProcessor):
# CONDITIONS
@staticmethod
def counter_lt(value):
return counter < value
# ACTIONS
@staticmethod
def increment_counter():
global counter
counter += 2
counter = 0
input_rule1 = {
"when": "event 1",
"condition": "counter_lt",
"value": 1,
"action": "increment_counter",
}
if __name__ == "__main__":
print(f"counter value: {counter}")
processor = CounterRuleProcessor()
processor.run(input_rule1)
print(f"counter value: {counter}")
processor.run(input_rule1)
print(f"counter value: {counter}")
Author
👤 João Ricardo Lhullier Lugão
Show your support
Give a ⭐️ if this project helped you!
This README was generated with ❤️ by readme-md-generator
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for sauron_rule_engine-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16243912258e281791ef334c88c412254a6c5a93acb82d513bfd2282c92445a5 |
|
MD5 | 910d06dc59022116323798fc1e92ba67 |
|
BLAKE2b-256 | 2882893c38ddc134c88920a231d7706a8fe8812abbad48a86ff14e24bfec51f1 |