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

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


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.3.tar.gz (2.1 kB view details)

Uploaded Source

Built Distribution

sauron_rule_engine-0.1.3-py3-none-any.whl (2.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sauron-rule-engine-0.1.3.tar.gz
  • Upload date:
  • Size: 2.1 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.3.tar.gz
Algorithm Hash digest
SHA256 4511895899bdb41d9d507c7189c396a28746782f2eb1b657bff1bbc5a5b5f096
MD5 dd4b29bcce3406781e04d53076c8c7b9
BLAKE2b-256 7226859aa0a09eab1cf48212fc99756deea45dd4461e867632079f0ac99a31be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sauron_rule_engine-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 16243912258e281791ef334c88c412254a6c5a93acb82d513bfd2282c92445a5
MD5 910d06dc59022116323798fc1e92ba67
BLAKE2b-256 2882893c38ddc134c88920a231d7706a8fe8812abbad48a86ff14e24bfec51f1

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