Skip to main content

DistributedQueue

Trait DistributedQueue 

Source
pub trait DistributedQueue: Send + Sync {
    // Required methods
    fn enqueue<'life0, 'async_trait>(
        &'life0 self,
        envelope: CommandEnvelope,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn dequeue<'life0, 'async_trait>(
        &'life0 self,
        partition_id: PartitionId,
    ) -> Pin<Box<dyn Future<Output = Result<Option<CommandEnvelope>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn complete<'life0, 'async_trait>(
        &'life0 self,
        result: CommandResult,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn num_partitions(&self) -> usize;
    fn worker_id(&self) -> &WorkerId;
    fn is_coordinator(&self) -> bool;
    fn is_worker(&self) -> bool;
}
Expand description

Distributed queue trait for multi-machine parallel processing

Implement this trait to enable distributed queue processing across multiple machines. The default implementation (LocalDistributedQueue) uses local multi-core parallelism.

Required Methods§

Source

fn enqueue<'life0, 'async_trait>( &'life0 self, envelope: CommandEnvelope, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Enqueue a command to be processed by a worker

Source

fn dequeue<'life0, 'async_trait>( &'life0 self, partition_id: PartitionId, ) -> Pin<Box<dyn Future<Output = Result<Option<CommandEnvelope>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Dequeue a command for processing (called by workers)

Source

fn complete<'life0, 'async_trait>( &'life0 self, result: CommandResult, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Report command completion

Source

fn num_partitions(&self) -> usize

Get the number of partitions

Source

fn worker_id(&self) -> &WorkerId

Get the worker ID for this instance

Source

fn is_coordinator(&self) -> bool

Check if this instance is a coordinator (can enqueue commands)

Source

fn is_worker(&self) -> bool

Check if this instance is a worker (can dequeue and execute commands)

Implementors§