pub struct QueueFanout { /* 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 fan one logical workload out over several queues without hand-rolling naming and routing in every process.
Implementations§
Source§impl QueueFanout
impl QueueFanout
Sourcepub fn new(
logical_queue: impl Into<String>,
width: usize,
) -> Result<Self, QueueFanoutError>
pub fn new( logical_queue: impl Into<String>, width: usize, ) -> Result<Self, QueueFanoutError>
Build a fanout using Awa’s default physical queue naming.
Width 1 maps to the logical queue name itself. Widths above 1
produce {logical_queue}__p0, {logical_queue}__p1, and so on.
Sourcepub fn from_physical_queues<I, S>(
logical_queue: impl Into<String>,
physical_queues: I,
) -> Result<Self, QueueFanoutError>
pub fn from_physical_queues<I, S>( logical_queue: impl Into<String>, physical_queues: I, ) -> Result<Self, QueueFanoutError>
Build a fanout 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 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, using the same portable hash Awa uses for queue-storage enqueue shards.
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 fanout 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 QueueFanout
impl AsRef<[String]> for QueueFanout
Source§impl Clone for QueueFanout
impl Clone for QueueFanout
Source§fn clone(&self) -> QueueFanout
fn clone(&self) -> QueueFanout
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 QueueFanout
impl Debug for QueueFanout
impl Eq for QueueFanout
Source§impl<'a> IntoIterator for &'a QueueFanout
impl<'a> IntoIterator for &'a QueueFanout
Source§impl PartialEq for QueueFanout
impl PartialEq for QueueFanout
Source§fn eq(&self, other: &QueueFanout) -> bool
fn eq(&self, other: &QueueFanout) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for QueueFanout
Auto Trait Implementations§
impl Freeze for QueueFanout
impl RefUnwindSafe for QueueFanout
impl Send for QueueFanout
impl Sync for QueueFanout
impl Unpin for QueueFanout
impl UnsafeUnpin for QueueFanout
impl UnwindSafe for QueueFanout
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