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>>,
handle: Handle,
) -> 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§
Sourcefn 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_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,
Sourcefn 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_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.
Sourcefn 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_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.
Sourcefn 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_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.
Sourcefn 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_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.
Sourcefn 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 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.
Sourcefn initialize_workers<'life0, 'async_trait>(
&'life0 self,
app_state: Arc<ThinData<DefaultAppState>>,
handle: Handle,
) -> Pin<Box<dyn Future<Output = Result<Vec<WorkerHandle>, QueueBackendError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn initialize_workers<'life0, 'async_trait>(
&'life0 self,
app_state: Arc<ThinData<DefaultAppState>>,
handle: Handle,
) -> 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 configurationhandle- Handle to the multi-thread pipeline runtime. Workers MUST be spawned viahandle.spawn(not baretokio::spawn) so background work is distributed across the pipeline runtime’s worker threads instead of landing on the actixSystemarbiter’s single thread.
§Returns
Vector of worker handles that can be used to monitor or stop workers
Sourcefn 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 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.
Sourcefn backend_type(&self) -> QueueBackendType
fn backend_type(&self) -> QueueBackendType
Returns the backend type identifier.
Provided Methods§
Sourcefn shutdown(&self)
fn shutdown(&self)
Signals all workers to shut down gracefully.
The default implementation is a no-op. Redis, SQS, and Pub/Sub backends all
override this to broadcast a shutdown signal (via a watch channel) into
their respective polling loops / cron tasks / Apalis Monitor signal futures,
so a programmatic shutdown (no OS signal) still stops them promptly.