Skip to main content

RuntimeEngine

Struct RuntimeEngine 

Source
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

Source

pub fn new( rules_path: PathBuf, pipelines: Vec<Pipeline>, corr_config: CorrelationConfig, include_event: bool, ) -> Self

Source

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().

Source

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().

Source

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.

Source

pub fn source_resolver(&self) -> Option<&Arc<dyn SourceResolver>>

Get the source resolver, if one is configured.

Source

pub fn set_allow_remote_include(&mut self, allow: bool)

Allow include directives to reference HTTP/NATS sources.

Source

pub fn allow_remote_include(&self) -> bool

Whether remote includes are allowed.

Source

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.

Source

pub fn pipeline_paths(&self) -> &[PathBuf]

Return the pipeline file paths (used by the daemon to set up watchers).

Source

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.

Source

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.

Source

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.

Source

pub fn stats(&self) -> EngineStats

Return summary statistics about the current engine state.

Source

pub fn rules_path(&self) -> &Path

Return the path from which rules are loaded.

Source

pub fn pipelines(&self) -> &[Pipeline]

Return the configured processing pipelines.

Source

pub fn corr_config(&self) -> &CorrelationConfig

Return the correlation configuration.

Source

pub fn include_event(&self) -> bool

Whether detection results include the matched event.

Source

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).

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnyExt for T
where T: Any + ?Sized,

Source§

fn downcast_ref<T>(this: &Self) -> Option<&T>
where T: Any,

Attempts to downcast this to T behind reference
Source§

fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>
where T: Any,

Attempts to downcast this to T behind mutable reference
Source§

fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>
where T: Any,

Attempts to downcast this to T behind Rc pointer
Source§

fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>
where T: Any,

Attempts to downcast this to T behind Arc pointer
Source§

fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>
where T: Any,

Attempts to downcast this to T behind Box pointer
Source§

fn downcast_move<T>(this: Self) -> Option<T>
where T: Any, Self: Sized,

Attempts to downcast owned Self to T, useful only in generic context as a workaround for specialization
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Chain<T> for T

Source§

fn len(&self) -> usize

The number of items that this chain link consists of.
Source§

fn append_to(self, v: &mut Vec<T>)

Append the elements in this link to the chain.
Source§

impl<T, X> CoerceTo<T> for X
where T: CoerceFrom<X> + ?Sized,

Source§

fn coerce_rc_to(self: Rc<X>) -> Rc<T>

Source§

fn coerce_box_to(self: Box<X>) -> Box<T>

Source§

fn coerce_ref_to(&self) -> &T

Source§

fn coerce_mut_to(&mut self) -> &mut T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more