Skip to main content

A simple rule engine implemented in python

Project description

Sauron Rule engine - One engine to rule them all

Twitter: joaovoce

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sauron-rule-engine-0.1.4.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

sauron_rule_engine-0.1.4-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file sauron-rule-engine-0.1.4.tar.gz.

File metadata

  • Download URL: sauron-rule-engine-0.1.4.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.16 CPython/3.6.7 Darwin/18.6.0

File hashes

Hashes for sauron-rule-engine-0.1.4.tar.gz
Algorithm Hash digest
SHA256 6d34159e9f54f22c20c8ecb884bd616688c9dd4aea94714515b62643c834900e
MD5 203764b93423fd38937c22b74b6130d8
BLAKE2b-256 aa73b25eda2768405c227cc191f4a382af1c1382ceca35801193e925b9adf190

See more details on using hashes here.

File details

Details for the file sauron_rule_engine-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for sauron_rule_engine-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 168406f43e5ba6557dbcaddfd2355f1a0433f7883f245fc4cc445e5211e39508
MD5 13dcc2be7a8d640ca2068ce1908bdf58
BLAKE2b-256 6b98580745b0bf735329c8efcbc5a0cc41fdee051e6f5a780a2efeeacde817c2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page