1use async_trait::async_trait;
7use coreon_core::{Exchange, Processor, Result};
8use std::sync::Arc;
9use tracing::warn;
10
11pub struct WireTap {
12 branch: Arc<dyn Processor>,
13}
14
15impl WireTap {
16 pub fn new(branch: Arc<dyn Processor>) -> Arc<Self> {
17 Arc::new(Self { branch })
18 }
19}
20
21#[async_trait]
22impl Processor for WireTap {
23 async fn process(&self, exchange: &mut Exchange) -> Result<()> {
24 let mut copy = exchange.clone();
25 let branch = self.branch.clone();
26 tokio::spawn(async move {
27 if let Err(e) = branch.process(&mut copy).await {
28 warn!(error = %e, "wire-tap branch failed");
29 }
30 });
31 Ok(())
32 }
33}