pub struct RuleEngine { /* private fields */ }Expand description
The core rule engine that evaluates rules against data batches.
RuleEngine is the main entry point for using FuseRule. It manages
rules, state, agents, and provides methods to process data batches.
§Example
use fuse_rule::{RuleEngine, config::FuseRuleConfig};
use arrow::array::Float64Array;
use arrow::datatypes::{DataType, Field, Schema};
use arrow::record_batch::RecordBatch;
use std::sync::Arc;
// Create engine from configuration
let config = FuseRuleConfig::from_file("config.yaml")?;
let mut engine = RuleEngine::from_config(config).await?;
// Create a test batch
let schema = Schema::new(vec![Field::new("price", DataType::Float64, true)]);
let batch = RecordBatch::try_new(
Arc::new(schema),
vec![Arc::new(Float64Array::from(vec![150.0, 50.0]))],
)?;
// Process a batch of data
let traces = engine.process_batch(&batch).await?;Implementations§
Source§impl RuleEngine
impl RuleEngine
pub fn new( evaluator: Box<dyn RuleEvaluator>, state: Box<dyn StateStore>, schema: Arc<Schema>, max_pending_batches: usize, agent_concurrency: usize, ) -> Self
pub fn get_or_create_circuit_breaker( &mut self, agent_name: &str, ) -> Arc<CircuitBreaker>
pub async fn from_config(config: FuseRuleConfig) -> Result<Self>
pub async fn reload_from_config(&mut self, config: FuseRuleConfig) -> Result<()>
pub fn schema(&self) -> Arc<Schema>
pub fn add_agent(&mut self, name: String, agent: Arc<dyn Agent>)
pub async fn add_rule(&mut self, rule: Rule) -> Result<()>
pub async fn update_rule(&mut self, rule_id: &str, new_rule: Rule) -> Result<()>
pub async fn toggle_rule(&mut self, rule_id: &str, enabled: bool) -> Result<()>
pub async fn process_batch( &mut self, batch: &RecordBatch, ) -> Result<Vec<EvaluationTrace>>
Auto Trait Implementations§
impl Freeze for RuleEngine
impl !RefUnwindSafe for RuleEngine
impl Send for RuleEngine
impl Sync for RuleEngine
impl Unpin for RuleEngine
impl !UnwindSafe for RuleEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more