Skip to main content

Drain

Trait Drain 

Source
pub trait Drain {
    // Required methods
    fn process_line(&mut self, line: String) -> Result<bool, Error>;
    fn collect_log_groups(&self) -> Vec<LogGroup>;
}
Expand description

Defines the core interface for log processing drains.

The Drain trait abstracts the mechanism by which log lines are processed, clustered into LogGroups, and subsequently retrieved. Implementations of this trait can offer various strategies for log analysis, such as simple in-memory storage or more complex, multi-stage processing pipelines.

This abstraction allows other parts of the system, like the LogStore, to operate on log data generically, without being coupled to a specific drain implementation.

Required Methods§

Source

fn process_line(&mut self, line: String) -> Result<bool, Error>

Processes a single log line, potentially updating internal log group structures.

§Arguments
  • line - A String representing the log line to be processed.
§Returns
  • Ok(true) if processing the line resulted in the creation of a new LogGroup.
  • Ok(false) if the line was successfully processed and added to an existing LogGroup.
  • Err(anyhow::Error) if an error occurred during processing.
Source

fn collect_log_groups(&self) -> Vec<LogGroup>

Retrieves all unique LogGroups currently managed by the drain.

This method provides a snapshot of the log groups at the time of calling. The order of log groups in the returned vector is not guaranteed.

§Returns

A Vec<LogGroup> containing all log groups. If no log lines have been processed or no groups have been formed, an empty vector is returned.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§