use std::sync::Arc; use crate::worker::Action; #[async_trait::async_trait] pub trait SimpleNotifyWorker { type J; async fn consumer( &self, job: Self::J, notifier: Arc, ); fn msg_to_job( &self, routing_key: &str, content_type: &Option, body: &[u8], ) -> Result; } #[async_trait::async_trait] pub trait NotificationReceiver { async fn tell(&self, action: Action); } #[derive(Default)] pub struct DummyNotificationReceiver { pub actions: parking_lot::Mutex>, } impl DummyNotificationReceiver { pub fn new() -> DummyNotificationReceiver { Default::default() } } #[async_trait::async_trait] impl NotificationReceiver for DummyNotificationReceiver { async fn tell(&self, action: Action) { let mut actions = self.actions.lock(); actions.push(action); } }