use crate::util; use std::any::type_name_of_val; use std::sync::Arc; use tonic::async_trait; // A side-effect is an action run that doesn't affect the pipeline result from being returned #[derive(Clone)] pub struct SideEffectInput { pub query: Arc, pub selected_candidates: Vec, } #[async_trait] pub trait SideEffect: Send + Sync where Q: Clone + Send + Sync + 'static, C: Clone + Send + Sync + 'static, { /// Decide if this side-effect should be run fn enable(&self, _query: Arc) -> bool { true } async fn run(&self, input: Arc>) -> Result<(), String>; fn name(&self) -> &'static str { util::short_type_name(type_name_of_val(self)) } }