Struct PriorityQueue

Source
pub struct PriorityQueue<T> { /* private fields */ }
Expand description

A priority queue implemented on a redis sorted set

Implementations§

Source§

impl<T: Serialize + DeserializeOwned> PriorityQueue<T>

Source

pub fn name(&self) -> &str

get key name used for this queue

Source

pub async fn count(&self, lowest: f64, highest: f64) -> Result<u64, ErrorTypes>

Return the number of items within the two priority values (inclusive on both ends)

Source

pub async fn delete(&self) -> Result<(), ErrorTypes>

Remove all the data from this queue

Source

pub async fn length(&self) -> Result<u64, ErrorTypes>

Get the number of items in the queue

Source

pub async fn pop(&self, num: isize) -> Result<Vec<T>, ErrorTypes>

Remove items from the front of the queue

Source

pub async fn blocking_pop( &self, timeout: Duration, low_priority: bool, ) -> Result<Option<T>, ErrorTypes>

When only one item is requested, blocking is is possible.

Source

pub async fn dequeue_range( &self, lower_limit: Option<i64>, upper_limit: Option<i64>, skip: Option<u32>, num: Option<u32>, ) -> Result<Vec<T>, ErrorTypes>

Dequeue a number of elements, within a specified range of scores. Limits given are inclusive, can be made exclusive, see redis docs on how to format limits for that. NOTE: lower/upper limit is negated+swapped in the lua script, no need to do it here :param lower_limit: The score of all dequeued elements must be higher or equal to this. :param upper_limit: The score of all dequeued elements must be lower or equal to this. :param skip: In the range of available items to dequeue skip over this many. :param num: Maximum number of elements to dequeue.

Source

pub async fn push(&self, priority: f64, data: &T) -> Result<Vec<u8>, ErrorTypes>

Place an item into the queue

Source

pub async fn rank(&self, raw_value: &[u8]) -> Result<Option<u64>, ErrorTypes>

Given the raw encoding of an item in queue get its position

Source

pub async fn remove(&self, raw_value: &[u8]) -> Result<bool, ErrorTypes>

Remove a specific item from the queue based on its raw value

Source

pub async fn unpush(&self, num: isize) -> Result<Vec<T>, ErrorTypes>

Pop items from the low priority end of the queue

Source

pub async fn select( queues: &[&PriorityQueue<T>], timeout: Option<Duration>, ) -> Result<Option<(String, T)>, ErrorTypes>

Pop the first item from any of the given queues within the given timeout

Source

pub async fn all_length( queues: &[&PriorityQueue<T>], ) -> Result<Vec<u64>, ErrorTypes>

Utility function for batch reading queue lengths.

Auto Trait Implementations§

§

impl<T> Freeze for PriorityQueue<T>

§

impl<T> !RefUnwindSafe for PriorityQueue<T>

§

impl<T> Send for PriorityQueue<T>
where T: Send,

§

impl<T> Sync for PriorityQueue<T>
where T: Sync,

§

impl<T> Unpin for PriorityQueue<T>
where T: Unpin,

§

impl<T> !UnwindSafe for PriorityQueue<T>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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> ErasedDestructor for T
where T: 'static,