A declarative rules engine.
Project description
Rulent
Rulent is a python in-memory latency events engine that uses a set of declarative rules and triggers actions (outcomes).
Quick Start
Here is a sample implementation using rulent with FastAPI:
from fastapi import FastAPI
from .import models
import rulent
app = FastAPI()
rulent.load_rules()
@app.post("/validate")
async def validate(request: models.EventRequest):
print(request)
return rulent.validate_data(dict(request))
@app.get("/reload")
async def reload_engine():
rulent.load_rules()
return {
"status": "success",
"message": "Conditions reloaded successfully",
}
Make sure you have a folder called "events" with atleast one YAML file like the below example:
events:
click:
rules-operator: "and"
rules:
- rule: "Name Check"
conditions:
- "person.name": "James"
- rule: "Age Check"
conditions:
- "person.age": "42"
- You can programatically create this folder and sample file using rulent.init(). This needs to be used only once.
Key Components
The main components of the event engine are as below.
The Web API
This is for ingesting events. This acts as the entry point for new events to be received and validation against rules.
Events
Events are specific, explicitly sent, pieces of information sent with the payload. This sets the foundation for the rules engine to process rules based on the event.
Rules
These are the rules that need to be applied on the JSON payload. This has support for dot notation. The rules can be combined using rules-operator: "or".
A sample rules block:
events:
click:
rules-operator: "and"
rules:
- rule: "Name Check"
conditions:
- "person.name": "James"
- rule: "Age Check"
conditions:
- "person.age": "42"
Outcomes
Once the payloads have been processed against rules, matched payloads can initiate actions. Actions are bundled together as outcomes.
Note: Actions are executed asynchronously.
Actions
Actions that are part of outcomes can be extended by navigating to the logic folder and actions.go file. Currently, this has access to outcomes and the payloads that were received.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rulent-0.0.2.tar.gz.
File metadata
- Download URL: rulent-0.0.2.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db555bf8e0f1d328ae1b89f2443879d5b8666d302ae42f7d4bd761de91454835
|
|
| MD5 |
7220daad0d75204f265f284bda044f9c
|
|
| BLAKE2b-256 |
e055ea68748bb2ac83ae735d0aee134eb0c2d16a5a8cf3571ad57cb53baa61d3
|
File details
Details for the file rulent-0.0.2-py3-none-any.whl.
File metadata
- Download URL: rulent-0.0.2-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0aefaa2cfd987d0c53c0d09b384cf36abd37e1799e7b3ac2fe56a3a21ed40b54
|
|
| MD5 |
8f722785a79b02c197b49f0e6add34c3
|
|
| BLAKE2b-256 |
1876fbcceee97666d773c6a39e67b584943bf3b5160f64128597b32d651e8b12
|