larastvel-core 0.2.0

Larastvel framework core - inspired by Laravel
Documentation
use async_trait::async_trait;

use super::{JobBox, JobError, Queue};

#[derive(Debug, Clone)]
pub struct SyncQueue {
    name: String,
}

impl SyncQueue {
    pub fn new(name: &str) -> Self {
        Self {
            name: name.to_string(),
        }
    }
}

#[async_trait]
impl Queue for SyncQueue {
    async fn push(&self, job: JobBox) -> Result<(), JobError> {
        tracing::debug!("[SyncQueue] Executing job: {}", job.name());
        job.handle().await
    }

    async fn pop(&self) -> Option<JobBox> {
        None
    }

    async fn count(&self) -> usize {
        0
    }

    fn name(&self) -> &str {
        &self.name
    }
}