use super::{formats::Format, aggregators::Aggregator}; use super::super::LogResult; use std::{io::Write, sync::Mutex}; pub struct Pipeline { format: Box, aggregator: Box, writer: Mutex>, } impl Pipeline { pub fn new(writer: W, format: F, aggregator: A) -> Pipeline { Pipeline { format: Box::new(format), aggregator: Box::new(aggregator), writer: Mutex::new(Box::new(writer)), } } pub fn push_item(&self, item: &LogResult) { let mut writer = self.writer.lock().unwrap(); self.aggregator.push_item(item, &self.format, &mut *writer); } }