pub struct PartitionedQueue { /* private fields */ }Expand description
A deterministic set of physical queues for one hot logical queue.
Awa still stores and executes jobs from ordinary queue names. This helper gives producers and workers the same stable list of physical queues, so an application can partition one logical workload over several queues without hand-rolling naming and routing in every process.
Implementations§
Source§impl PartitionedQueue
impl PartitionedQueue
Sourcepub fn new(
logical_queue: impl Into<String>,
partitions: usize,
) -> Result<Self, PartitionedQueueError>
pub fn new( logical_queue: impl Into<String>, partitions: usize, ) -> Result<Self, PartitionedQueueError>
Build a partitioned queue using Awa’s default physical queue naming.
One partition maps to the logical queue name itself. With more than one
partition, partition 0 is still the logical queue name and later
partitions are {logical_queue}__p1, {logical_queue}__p2, and so on.
That keeps direct enqueues to the logical name consumable during a
1 -> N rollout.
Sourcepub fn from_physical_queues<I, S>(
logical_queue: impl Into<String>,
physical_queues: I,
) -> Result<Self, PartitionedQueueError>
pub fn from_physical_queues<I, S>( logical_queue: impl Into<String>, physical_queues: I, ) -> Result<Self, PartitionedQueueError>
Build a partitioned queue from explicit physical queue names.
Use this when an application already has queue names it wants to keep, or when migrating an existing manually-fanned-out deployment to the shared helper.
Sourcepub fn logical_queue(&self) -> &str
pub fn logical_queue(&self) -> &str
Logical queue name used by the application.
Sourcepub fn physical_queues(&self) -> &[String]
pub fn physical_queues(&self) -> &[String]
Physical queues that must be declared on worker runtimes.
Sourcepub fn partitions(&self) -> usize
pub fn partitions(&self) -> usize
Number of physical queues in the partitioned queue.
Sourcepub fn queue_for_key(&self, key: impl AsRef<[u8]>) -> &str
pub fn queue_for_key(&self, key: impl AsRef<[u8]>) -> &str
Select a physical queue by stable routing key.
The same key always maps to the same physical queue. Partition routing
domain-separates the hash used for queue-storage enqueue shards so
partitions == enqueue_shards does not collapse keyed traffic onto one
shard inside each partition.
Sourcepub fn queue_for_index(&self, index: usize) -> &str
pub fn queue_for_index(&self, index: usize) -> &str
Select a physical queue by caller-supplied sequence number.
This is useful for bulk producers that want round-robin partitioning and do not need per-key ordering.
Sourcepub fn route_opts_by_key(
&self,
opts: InsertOpts,
key: impl AsRef<[u8]>,
) -> InsertOpts
pub fn route_opts_by_key( &self, opts: InsertOpts, key: impl AsRef<[u8]>, ) -> InsertOpts
Return insert options routed by key.
This sets both the physical queue and ordering_key, so per-key FIFO is
preserved even if the selected physical queue later uses multiple
queue-storage enqueue shards.
Sourcepub fn route_opts_by_index(&self, opts: InsertOpts, index: usize) -> InsertOpts
pub fn route_opts_by_index(&self, opts: InsertOpts, index: usize) -> InsertOpts
Return insert options routed by round-robin index.
Trait Implementations§
Source§impl AsRef<[String]> for PartitionedQueue
impl AsRef<[String]> for PartitionedQueue
Source§impl Clone for PartitionedQueue
impl Clone for PartitionedQueue
Source§fn clone(&self) -> PartitionedQueue
fn clone(&self) -> PartitionedQueue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PartitionedQueue
impl Debug for PartitionedQueue
impl Eq for PartitionedQueue
Source§impl<'a> IntoIterator for &'a PartitionedQueue
impl<'a> IntoIterator for &'a PartitionedQueue
Source§impl PartialEq for PartitionedQueue
impl PartialEq for PartitionedQueue
Source§fn eq(&self, other: &PartitionedQueue) -> bool
fn eq(&self, other: &PartitionedQueue) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for PartitionedQueue
Auto Trait Implementations§
impl Freeze for PartitionedQueue
impl RefUnwindSafe for PartitionedQueue
impl Send for PartitionedQueue
impl Sync for PartitionedQueue
impl Unpin for PartitionedQueue
impl UnsafeUnpin for PartitionedQueue
impl UnwindSafe for PartitionedQueue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more