#policy #rules #rule #rule-engine #parser #programming-language

yanked policy-engine

Policy Engine allows to dynamically evaluate and enforce policies easily

1 unstable release

0.1.0 Mar 9, 2023

#51 in #rule

AGPL-3.0

120KB
460 lines

policy engine

Policy Engine allows to dynamically evaluate and enforce rules written in a simple expression-like language.

Note: This is still under development.

Example

extern crate policyengine;

use policyengine::services::Policy;
fn main() {

    let user_policy = "metric_a >= 100 && metric_b = 123";
    let mut policy = Policy::new();

    policy.predicate.rule = user_policy.to_string();

    let user_metric = "metric_a = 456 && metric_b = 123";
    policy.predicate.expression = user_metric.to_string();

    policy.action.on_success.path = "/path/to/success".to_string();
    policy.action.on_failure.path = "/path/to/failure".to_string();

    policy.run(); //returns true
}

See examples for more.

Currently supported operands

>, <, >=, <=, ==, !=


lib.rs:

Policy Engine allows to dynamically evaluate and enforce policies easily.

Currently, the crate has a parser.

Dependencies

~2.3–7.5MB
~49K SLoC