use async_trait::async_trait;
use std::time::Duration;
use crate::error::{JobError, QueueError};
use crate::job::Job;
#[async_trait]
pub trait Queue: Send + Sync {
async fn enqueue(&self, topic: &str, payload: Vec<u8>) -> Result<(), QueueError>;
async fn dequeue(&self, topic: &str, timeout: Duration) -> Result<Option<Job>, QueueError>;
async fn ack(&self, job: &Job) -> Result<(), JobError>;
async fn nack(&self, job: &Job, requeue: bool) -> Result<(), JobError>;
async fn dlq_move(&self, topic: &str, job: Job) -> Result<(), QueueError>;
async fn len(&self, topic: &str) -> Result<u64, QueueError>;
async fn is_empty(&self, topic: &str) -> Result<bool, QueueError> {
Ok(self.len(topic).await? == 0)
}
}