| Crates.io | policy-engine |
| lib.rs | policy-engine |
| version | 0.1.0 |
| created_at | 2023-03-09 06:59:39.910297+00 |
| updated_at | 2023-03-09 06:59:39.910297+00 |
| description | Policy Engine allows to dynamically evaluate and enforce policies easily. |
| homepage | https://github.com/SubconsciousCompute/policy-engine |
| repository | https://github.com/SubconsciousCompute/policy-engine |
| max_upload_size | |
| id | 805399 |
| size | 156,737 |
Policy Engine allows to dynamically evaluate and enforce rules written in a simple expression-like language.
Note: This is still under development.
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.
>, <, >=, <=, ==, !=