Trait QueueBackend

Source
pub trait QueueBackend: Send + Sync {
    // Required methods
    fn produce_transaction_request<'life0, 'async_trait>(
        &'life0 self,
        job: Job<TransactionRequest>,
        scheduled_on: Option<i64>,
    ) -> Pin<Box<dyn Future<Output = Result<String, QueueBackendError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn produce_transaction_submission<'life0, 'async_trait>(
        &'life0 self,
        job: Job<TransactionSend>,
        scheduled_on: Option<i64>,
    ) -> Pin<Box<dyn Future<Output = Result<String, QueueBackendError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn produce_transaction_status_check<'life0, 'async_trait>(
        &'life0 self,
        job: Job<TransactionStatusCheck>,
        scheduled_on: Option<i64>,
    ) -> Pin<Box<dyn Future<Output = Result<String, QueueBackendError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn produce_notification<'life0, 'async_trait>(
        &'life0 self,
        job: Job<NotificationSend>,
        scheduled_on: Option<i64>,
    ) -> Pin<Box<dyn Future<Output = Result<String, QueueBackendError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn produce_token_swap_request<'life0, 'async_trait>(
        &'life0 self,
        job: Job<TokenSwapRequest>,
        scheduled_on: Option<i64>,
    ) -> Pin<Box<dyn Future<Output = Result<String, QueueBackendError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn produce_relayer_health_check<'life0, 'async_trait>(
        &'life0 self,
        job: Job<RelayerHealthCheck>,
        scheduled_on: Option<i64>,
    ) -> Pin<Box<dyn Future<Output = Result<String, QueueBackendError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn initialize_workers<'life0, 'async_trait>(
        &'life0 self,
        app_state: Arc<ThinData<DefaultAppState>>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<WorkerHandle>, QueueBackendError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<QueueHealth>, QueueBackendError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn backend_type(&self) -> QueueBackendType;

    // Provided method
    fn shutdown(&self) { ... }
}
Expand description

Queue backend abstraction trait.

This trait defines the interface for job queue operations that can be implemented by different backends (Redis/Apalis, AWS SQS, etc.).

The trait is designed to be backend-agnostic, with no Redis or SQS-specific types in the interface.

Required Methods§

Source

fn produce_transaction_request<'life0, 'async_trait>( &'life0 self, job: Job<TransactionRequest>, scheduled_on: Option<i64>, ) -> Pin<Box<dyn Future<Output = Result<String, QueueBackendError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Produces a transaction request job to the queue.

§Arguments
  • job - The job to enqueue
  • scheduled_on - Optional Unix timestamp for delayed execution
§Returns

Result with job ID on success, or QueueBackendError on failure

Source

fn produce_transaction_submission<'life0, 'async_trait>( &'life0 self, job: Job<TransactionSend>, scheduled_on: Option<i64>, ) -> Pin<Box<dyn Future<Output = Result<String, QueueBackendError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Produces a transaction submission job to the queue.

Source

fn produce_transaction_status_check<'life0, 'async_trait>( &'life0 self, job: Job<TransactionStatusCheck>, scheduled_on: Option<i64>, ) -> Pin<Box<dyn Future<Output = Result<String, QueueBackendError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Produces a transaction status check job to the queue.

Source

fn produce_notification<'life0, 'async_trait>( &'life0 self, job: Job<NotificationSend>, scheduled_on: Option<i64>, ) -> Pin<Box<dyn Future<Output = Result<String, QueueBackendError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Produces a notification send job to the queue.

Source

fn produce_token_swap_request<'life0, 'async_trait>( &'life0 self, job: Job<TokenSwapRequest>, scheduled_on: Option<i64>, ) -> Pin<Box<dyn Future<Output = Result<String, QueueBackendError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Produces a token swap request job to the queue.

Source

fn produce_relayer_health_check<'life0, 'async_trait>( &'life0 self, job: Job<RelayerHealthCheck>, scheduled_on: Option<i64>, ) -> Pin<Box<dyn Future<Output = Result<String, QueueBackendError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Produces a relayer health check job to the queue.

Source

fn initialize_workers<'life0, 'async_trait>( &'life0 self, app_state: Arc<ThinData<DefaultAppState>>, ) -> Pin<Box<dyn Future<Output = Result<Vec<WorkerHandle>, QueueBackendError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Initializes and starts all worker tasks for this backend.

Workers will poll their respective queues and process jobs using the provided application state.

§Arguments
  • app_state - Application state containing handlers and configuration
§Returns

Vector of worker handles that can be used to monitor or stop workers

Source

fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<QueueHealth>, QueueBackendError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Performs a health check on all queues.

Returns health status for each queue, including message counts and backend-specific health indicators.

Source

fn backend_type(&self) -> QueueBackendType

Returns the backend type identifier.

Provided Methods§

Source

fn shutdown(&self)

Signals all workers to shut down gracefully.

The default implementation is a no-op (e.g. Redis/Apalis workers handle shutdown via Monitor’s signal handling). SQS backend overrides this to broadcast a shutdown signal to all polling loops and cron tasks.

Implementors§