Skip to main content

RequestQueue

Trait RequestQueue 

Source
pub trait RequestQueue: Send + Sync {
    // Required methods
    fn add<'life0, 'async_trait>(
        &'life0 self,
        req: Request,
        opts: AddOptions,
    ) -> Pin<Box<dyn Future<Output = StorageResult<QueueOpInfo>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn add_batch<'life0, 'async_trait>(
        &'life0 self,
        reqs: Vec<RequestSource>,
        opts: AddOptions,
    ) -> Pin<Box<dyn Future<Output = StorageResult<BatchAddHandle>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn fetch_next<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = StorageResult<Option<Lease>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn mark_handled<'life0, 'async_trait>(
        &'life0 self,
        lease: Lease,
    ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn reclaim<'life0, 'async_trait>(
        &'life0 self,
        lease: Lease,
        opts: ReclaimOptions,
    ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn renew<'life0, 'life1, 'async_trait>(
        &'life0 self,
        lease_id: &'life1 LeaseId,
        extend_by: Duration,
    ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn abandon<'life0, 'async_trait>(
        &'life0 self,
        lease: Lease,
    ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn is_empty<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn is_finished<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn handled_count<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = StorageResult<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn pending_count<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = StorageResult<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Object-safe queue with temporary lease ownership.

Single-process backends may document lease expiry as a no-op, but must retain this complete lease API so callers and distributed backends share one contract.

Required Methods§

Source

fn add<'life0, 'async_trait>( &'life0 self, req: Request, opts: AddOptions, ) -> Pin<Box<dyn Future<Output = StorageResult<QueueOpInfo>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Adds a request and returns its deduplication status.

Source

fn add_batch<'life0, 'async_trait>( &'life0 self, reqs: Vec<RequestSource>, opts: AddOptions, ) -> Pin<Box<dyn Future<Output = StorageResult<BatchAddHandle>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Adds multiple request sources and returns a handle for deferred completion.

Source

fn fetch_next<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = StorageResult<Option<Lease>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Hands temporary ownership of the next request to the caller as a lease.

Source

fn mark_handled<'life0, 'async_trait>( &'life0 self, lease: Lease, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Marks a leased request as successful and consumes its lease.

Source

fn reclaim<'life0, 'async_trait>( &'life0 self, lease: Lease, opts: ReclaimOptions, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Re-queues a lease, incrementing retry count unless opts disables it.

Backends must persist the request state carried in the lease (e.g. mutated error_messages or session_rotation_count), not a previously stored copy.

Source

fn renew<'life0, 'life1, 'async_trait>( &'life0 self, lease_id: &'life1 LeaseId, extend_by: Duration, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Extends an active lease deadline, returning LeaseNotFound if it is unknown or completed.

Source

fn abandon<'life0, 'async_trait>( &'life0 self, lease: Lease, ) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Re-queues and consumes a lease without incrementing its request retry count.

Backends must persist the request state carried in the lease (e.g. mutated error_messages or session_rotation_count), not a previously stored copy.

Source

fn is_empty<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns whether no requests are currently pending.

Source

fn is_finished<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = StorageResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns whether no requests are pending or leased.

Source

fn handled_count<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = StorageResult<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the number of successfully handled requests.

Source

fn pending_count<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = StorageResult<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the number of pending requests.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§