pub struct RuntimeEngine { /* private fields */ }Expand description
Wraps a CorrelationEngine (or a plain Engine) and provides the interface the runtime needs: process events, reload rules, and query state.
Implementations§
Source§impl RuntimeEngine
impl RuntimeEngine
pub fn new( rules_path: PathBuf, pipelines: Vec<Pipeline>, corr_config: CorrelationConfig, include_event: bool, ) -> Self
Sourcepub fn set_bloom_prefilter(&mut self, enabled: bool)
pub fn set_bloom_prefilter(&mut self, enabled: bool)
Enable or disable bloom-filter pre-filtering on the inner detection
engine. Off by default. Applies on the next load_rules(); pre-load
callers should set this before calling load_rules().
Sourcepub fn set_bloom_max_bytes(&mut self, max_bytes: usize)
pub fn set_bloom_max_bytes(&mut self, max_bytes: usize)
Override the bloom memory budget on the inner detection engine.
Applies on the next load_rules().
Sourcepub fn set_source_resolver(&mut self, resolver: Arc<dyn SourceResolver>)
pub fn set_source_resolver(&mut self, resolver: Arc<dyn SourceResolver>)
Set a source resolver for dynamic pipeline sources.
When set, load_rules() resolves dynamic sources and expands
${source.*} templates before compiling rules.
Sourcepub fn source_resolver(&self) -> Option<&Arc<dyn SourceResolver>>
pub fn source_resolver(&self) -> Option<&Arc<dyn SourceResolver>>
Get the source resolver, if one is configured.
Sourcepub fn set_allow_remote_include(&mut self, allow: bool)
pub fn set_allow_remote_include(&mut self, allow: bool)
Allow include directives to reference HTTP/NATS sources.
Sourcepub fn allow_remote_include(&self) -> bool
pub fn allow_remote_include(&self) -> bool
Whether remote includes are allowed.
Sourcepub fn set_pipeline_paths(&mut self, paths: Vec<PathBuf>)
pub fn set_pipeline_paths(&mut self, paths: Vec<PathBuf>)
Set the pipeline file paths used for hot-reload.
When paths are set, load_rules() re-reads pipeline YAML from disk
before rebuilding the engine. This enables pipeline hot-reload
alongside rule hot-reload.
Sourcepub fn pipeline_paths(&self) -> &[PathBuf]
pub fn pipeline_paths(&self) -> &[PathBuf]
Return the pipeline file paths (used by the daemon to set up watchers).
Sourcepub async fn resolve_dynamic_pipelines(&mut self) -> Result<(), String>
pub async fn resolve_dynamic_pipelines(&mut self) -> Result<(), String>
Resolve dynamic sources in all pipelines and expand templates.
This is the async entry point for source resolution. Call this before
load_rules() when you have an async context available, or let
load_rules() handle it synchronously via tokio::runtime::Handle.
Sourcepub fn load_rules(&mut self) -> Result<EngineStats, String>
pub fn load_rules(&mut self) -> Result<EngineStats, String>
Load (or reload) rules from the configured path.
On reload, correlation state is exported before replacing the engine and re-imported after, so in-flight windows and suppression state survive rule changes (entries for removed correlations are dropped).
If pipeline paths are set (via set_pipeline_paths),
pipelines are re-read from disk before rebuilding the engine. If any
pipeline file fails to parse, the entire reload is aborted and the
old engine remains active.
Dynamic pipeline sources are resolved if a source resolver is configured.
Sourcepub fn process_batch<E: Event + Sync>(
&mut self,
events: &[&E],
) -> Vec<ProcessResult>
pub fn process_batch<E: Event + Sync>( &mut self, events: &[&E], ) -> Vec<ProcessResult>
Process a batch of events using parallel detection + sequential correlation.
Delegates to Engine::evaluate_batch or CorrelationEngine::process_batch
depending on whether correlation rules are loaded.
Sourcepub fn stats(&self) -> EngineStats
pub fn stats(&self) -> EngineStats
Return summary statistics about the current engine state.
Sourcepub fn rules_path(&self) -> &Path
pub fn rules_path(&self) -> &Path
Return the path from which rules are loaded.
Sourcepub fn corr_config(&self) -> &CorrelationConfig
pub fn corr_config(&self) -> &CorrelationConfig
Return the correlation configuration.
Sourcepub fn include_event(&self) -> bool
pub fn include_event(&self) -> bool
Whether detection results include the matched event.
Sourcepub fn export_state(&self) -> Option<CorrelationSnapshot>
pub fn export_state(&self) -> Option<CorrelationSnapshot>
Export correlation state as a serializable snapshot.
Returns None if the engine is detection-only (no correlation state to persist).
Sourcepub fn import_state(&mut self, snapshot: &CorrelationSnapshot) -> bool
pub fn import_state(&mut self, snapshot: &CorrelationSnapshot) -> bool
Import previously exported correlation state.
Returns true if the import succeeded, false if the snapshot version
is incompatible. No-op (returns true) if the engine is detection-only.
Auto Trait Implementations§
impl Freeze for RuntimeEngine
impl !RefUnwindSafe for RuntimeEngine
impl Send for RuntimeEngine
impl Sync for RuntimeEngine
impl Unpin for RuntimeEngine
impl UnsafeUnpin for RuntimeEngine
impl !UnwindSafe for RuntimeEngine
Blanket Implementations§
Source§impl<T> AnyExt for T
impl<T> AnyExt for T
Source§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
T behind referenceSource§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
T behind mutable referenceSource§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
T behind Rc pointerSource§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
T behind Arc pointerSource§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
Source§impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
impl<T, X> CoerceTo<T> for Xwhere
T: CoerceFrom<X> + ?Sized,
fn coerce_rc_to(self: Rc<X>) -> Rc<T>
fn coerce_box_to(self: Box<X>) -> Box<T>
fn coerce_ref_to(&self) -> &T
fn coerce_mut_to(&mut self) -> &mut T
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>
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>
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