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
Heavily inspired on FastAPI
Install
pip install sauron-rule-engine
Use it
A simple example of the usage
from sauron_rule_engine.rule_engine import RuleEngine
#instantiate your engine
engine = RuleEngine()
#just a dumb variable so we can see the actions in use
number_to_be_incremented = 1
@engine.condition
def is_smaller_than(compared_to: int) -> bool:
return number_to_be_incremented < compared_to
@engine.action
def increment_number() -> None:
nonlocal number_to_be_incremented
number_to_be_incremented += 1
# Then just use your engine
if __name__ == "__main__":
print(number_to_be_incremented)
## 1
engine.run(json_rule_can_increment)
print(number_to_be_incremented)
## 2
engine.run(json_rule_can_increment)
print(number_to_be_incremented)
## 2
Features coming to town
- Exporting a json string with the conditions and actions in a given engine
- Exported conditions and actions should include sane typing and docstring exposure
- Support pydantic types
- Support for choices fields with enum
- Support for complex types with hints to the frontend (like a range for an int type
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.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 168406f43e5ba6557dbcaddfd2355f1a0433f7883f245fc4cc445e5211e39508 |
|
MD5 | 13dcc2be7a8d640ca2068ce1908bdf58 |
|
BLAKE2b-256 | 6b98580745b0bf735329c8efcbc5a0cc41fdee051e6f5a780a2efeeacde817c2 |