1use crate::error::Result;
2use crate::webhook_types::{JobData, JobProcessorFnAsync};
3use async_trait::async_trait;
4use serde::Serialize;
5use serde::de::DeserializeOwned;
6use std::future::Future;
7use std::pin::Pin;
8use std::sync::Arc;
9
10impl JobData where JobData: Serialize + DeserializeOwned {}
11
12#[allow(dead_code)]
14type JobProcessorFn = Box<dyn Fn(JobData) -> Result<()> + Send + Sync + 'static>;
15#[allow(dead_code)]
17type ArcJobProcessorFn = Arc<
18 Box<
19 dyn Fn(JobData) -> Pin<Box<dyn Future<Output = Result<()>> + Send>> + Send + Sync + 'static,
20 >,
21>;
22
23#[async_trait]
24pub trait QueueInterface: Send + Sync {
25 async fn add_to_queue(&self, queue_name: &str, data: JobData) -> crate::error::Result<()>;
26 async fn process_queue(
28 &self,
29 queue_name: &str,
30 callback: JobProcessorFnAsync,
31 ) -> crate::error::Result<()>;
32 async fn disconnect(&self) -> crate::error::Result<()>;
33 async fn check_health(&self) -> crate::error::Result<()>;
34}