Skip to main content

PartitionedQueue

Struct PartitionedQueue 

Source
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

Source

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.

Source

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

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.

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 partitions(&self) -> usize

Number of physical queues in the partitioned queue.

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. 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.

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 partitioning 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 PartitionedQueue

Source§

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

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

impl Clone for PartitionedQueue

Source§

fn clone(&self) -> PartitionedQueue

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 PartitionedQueue

Source§

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

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

impl Eq for PartitionedQueue

Source§

impl<'a> IntoIterator for &'a PartitionedQueue

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 PartitionedQueue

Source§

fn eq(&self, other: &PartitionedQueue) -> 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 PartitionedQueue

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