Skip to main content

larastvel_core/queue/
sync.rs

1use async_trait::async_trait;
2
3use super::{JobBox, JobError, Queue};
4
5#[derive(Debug, Clone)]
6pub struct SyncQueue {
7    name: String,
8}
9
10impl SyncQueue {
11    pub fn new(name: &str) -> Self {
12        Self {
13            name: name.to_string(),
14        }
15    }
16}
17
18#[async_trait]
19impl Queue for SyncQueue {
20    async fn push(&self, job: JobBox) -> Result<(), JobError> {
21        tracing::debug!("[SyncQueue] Executing job: {}", job.name());
22        job.handle().await
23    }
24
25    async fn pop(&self) -> Option<(JobBox, u64)> {
26        None
27    }
28
29    /// Sync jobs run exactly once per push — a failed attempt is not retried.
30    async fn release(
31        &self,
32        job: JobBox,
33        attempts: u64,
34        delay_seconds: u64,
35    ) -> Result<(), JobError> {
36        let _ = (job, attempts, delay_seconds);
37        Ok(())
38    }
39
40    async fn count(&self) -> usize {
41        0
42    }
43
44    fn name(&self) -> &str {
45        &self.name
46    }
47}