Skip to main content

QueueFanout

Struct QueueFanout 

Source
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

Source

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.

Source

pub fn from_physical_queues<I, S>( logical_queue: impl Into<String>, physical_queues: I, ) -> Result<Self, QueueFanoutError>
where I: IntoIterator<Item = S>, S: Into<String>,

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.

Source

pub fn logical_queue(&self) -> &str

Logical queue name used by the application.

Source

pub fn physical_queues(&self) -> &[String]

Physical queues that must be declared on worker runtimes.

Source

pub fn width(&self) -> usize

Number of physical queues in the fanout.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn as_ref(&self) -> &[String]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for QueueFanout

Source§

fn clone(&self) -> QueueFanout

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for QueueFanout

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for QueueFanout

Source§

impl<'a> IntoIterator for &'a QueueFanout

Source§

type Item = &'a String

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, String>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for QueueFanout

Source§

fn eq(&self, other: &QueueFanout) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for QueueFanout

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more