pub struct LogProcessor { /* private fields */ }Expand description
Thread-safe handle to the engine, swappable atomically for hot-reload.
Uses ArcSwap<Mutex<RuntimeEngine>> so that:
- Detection + correlation processing can acquire
&mut RuntimeEnginevia the innerMutex. - Hot-reload swaps the entire engine atomically without blocking in-flight
batches (they hold an
Arcto the old engine until their batch completes).
Implementations§
Source§impl LogProcessor
impl LogProcessor
Sourcepub fn new(engine: RuntimeEngine, metrics: Arc<dyn MetricsHook>) -> Self
pub fn new(engine: RuntimeEngine, metrics: Arc<dyn MetricsHook>) -> Self
Create a new processor wrapping the given engine and metrics hook.
Sourcepub fn swap_engine(&self, new_engine: RuntimeEngine)
pub fn swap_engine(&self, new_engine: RuntimeEngine)
Atomically replace the engine with a new one.
In-flight batches continue against the old engine (they hold an Arc
snapshot). New batches see the replacement on their next call to
process_batch_lines.
Sourcepub fn engine_snapshot(&self) -> Guard<Arc<Mutex<RuntimeEngine>>>
pub fn engine_snapshot(&self) -> Guard<Arc<Mutex<RuntimeEngine>>>
Load a snapshot of the current engine for use during reload.
The caller can lock the returned guard to export state, build a new
engine, import state, and then call swap_engine.
Sourcepub fn process_batch_lines(
&self,
batch: &[String],
event_filter: &EventFilter,
) -> Vec<ProcessResult>
pub fn process_batch_lines( &self, batch: &[String], event_filter: &EventFilter, ) -> Vec<ProcessResult>
Process a batch of raw input lines through the engine.
- Parses each line as JSON; on error, increments parse error metrics.
- Applies the
event_filterclosure to extract payloads. - Evaluates all payloads via
RuntimeEngine::process_batch. - Merges per-payload results back into per-line results.
- Updates metrics (events processed, latency, match counts).
Returns one ProcessResult per input line.
Sourcepub fn process_batch_with_format(
&self,
batch: &[String],
format: &InputFormat,
event_filter: Option<&EventFilter>,
) -> Vec<ProcessResult>
pub fn process_batch_with_format( &self, batch: &[String], format: &InputFormat, event_filter: Option<&EventFilter>, ) -> Vec<ProcessResult>
Process a batch of raw input lines using the specified input format.
Unlike process_batch_lines, this method
supports all input formats (JSON, syslog, plain, logfmt, CEF). The
event_filter only applies to JSON-decoded events (it extracts multiple
payloads from one JSON object, e.g. a records[] array). Non-JSON
formats produce exactly one event per line.
Returns one ProcessResult per input line.
Sourcepub fn reload_rules(&self) -> Result<EngineStats, String>
pub fn reload_rules(&self) -> Result<EngineStats, String>
Reload rules without blocking in-flight event processing.
Builds a fresh RuntimeEngine with the same configuration as the
current one, loads rules into it, imports the old engine’s correlation
state, and atomically swaps. In-flight batches that already hold an
Arc to the old engine finish undisturbed.
Sourcepub fn rules_path(&self) -> PathBuf
pub fn rules_path(&self) -> PathBuf
Return the rules path from the current engine.
Sourcepub fn metrics(&self) -> &dyn MetricsHook
pub fn metrics(&self) -> &dyn MetricsHook
Return a reference to the metrics hook.
Sourcepub fn export_state(&self) -> Option<CorrelationSnapshot>
pub fn export_state(&self) -> Option<CorrelationSnapshot>
Export correlation state from the current engine.
Sourcepub fn import_state(&self, snapshot: &CorrelationSnapshot) -> bool
pub fn import_state(&self, snapshot: &CorrelationSnapshot) -> bool
Import correlation state into the current engine.
Sourcepub fn stats(&self) -> EngineStats
pub fn stats(&self) -> EngineStats
Return summary statistics about the current engine.
Auto Trait Implementations§
impl Freeze for LogProcessor
impl !RefUnwindSafe for LogProcessor
impl Send for LogProcessor
impl Sync for LogProcessor
impl Unpin for LogProcessor
impl UnsafeUnpin for LogProcessor
impl !UnwindSafe for LogProcessor
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
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