-
Notifications
You must be signed in to change notification settings - Fork 1
Quick start
Here is how to get started:
ezrules is composed of two parts: ezrule manager
and ezrule executor
. The former is responsible for the UI for rule management that analysts can use to modify and maintain rules. The latter is a standalone rule execution enviroment that handles processing of events(e.g. transactions).
The below tutorial shows how to get started locally and on a on-premise k8s cluster. For both cases you will need a postgres database running and availbale to the both manager and executor.
If you do not have a local postgres instance running, you may need docker
running on your machine.
Install ezrules
with
pip install ezrules
First, get and get the database running:
docker run --rm -it --name postgresql16 -p 5432:5432 -e POSTGRES_PASSWORD=root -e POSTGRES_HOST_AUTH=trust -e LC_CTYPE=en_US.UTF-8 -e PG_HOST=localhost postgres:16.0-alpine3.18
This will pull postgres16
image and run it in a container.
Next, install the dependancies with pipenv install
and activate the new enviroment with pipenv shell
.
First, we need to setup the environment.
ezrules init-db --db-endpoint postgresql://postgres:root@localhost:5432/postgres
And then add a user to login with:
ezrules add-user --db-endpoint postgresql://postgres:root@localhost:5432/postgres --user-email [email protected] --password 123
In separate ternminal windows, run the manager and an executor instance, but before that, export the following env variables:
export DB_ENDPOINT=postgresql://postgres:root@localhost:5432/postgres
export APP_SECRET=123
ezrules manager --db-endpoint postgresql://postgres:root@localhost:5432/postgres
and the executor
ezrules evaluator --db-endpoint postgresql://postgres:root@localhost:5432/postgres
By default, the manager will start at http://0.0.0.0:8888. Go there and login with the details above. Then click Add rule
and create a test configuration as shown on the screenshot:
Click Submit
.
The new rule will be automatically picked up by the evaluator running in the second terminal. Test your new rule with
curl -X POST -H "Content-Type: application/json" -d '{"age": 25, "amount": 950}' http://localhost:9999/evaluate
This will return ["CANCEL"]