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>
impl<T: Serialize + DeserializeOwned> PriorityQueue<T>
Sourcepub async fn count(&self, lowest: f64, highest: f64) -> Result<u64, ErrorTypes>
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)
Sourcepub async fn delete(&self) -> Result<(), ErrorTypes>
pub async fn delete(&self) -> Result<(), ErrorTypes>
Remove all the data from this queue
Sourcepub async fn length(&self) -> Result<u64, ErrorTypes>
pub async fn length(&self) -> Result<u64, ErrorTypes>
Get the number of items in the queue
Sourcepub async fn pop(&self, num: isize) -> Result<Vec<T>, ErrorTypes>
pub async fn pop(&self, num: isize) -> Result<Vec<T>, ErrorTypes>
Remove items from the front of the queue
Sourcepub async fn blocking_pop(
&self,
timeout: Duration,
low_priority: bool,
) -> Result<Option<T>, ErrorTypes>
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.
Sourcepub async fn dequeue_range(
&self,
lower_limit: Option<i64>,
upper_limit: Option<i64>,
skip: Option<u32>,
num: Option<u32>,
) -> Result<Vec<T>, ErrorTypes>
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.
Sourcepub async fn push(&self, priority: f64, data: &T) -> Result<Vec<u8>, ErrorTypes>
pub async fn push(&self, priority: f64, data: &T) -> Result<Vec<u8>, ErrorTypes>
Place an item into the queue
Sourcepub async fn rank(&self, raw_value: &[u8]) -> Result<Option<u64>, ErrorTypes>
pub async fn rank(&self, raw_value: &[u8]) -> Result<Option<u64>, ErrorTypes>
Given the raw encoding of an item in queue get its position
Sourcepub async fn remove(&self, raw_value: &[u8]) -> Result<bool, ErrorTypes>
pub async fn remove(&self, raw_value: &[u8]) -> Result<bool, ErrorTypes>
Remove a specific item from the queue based on its raw value
Sourcepub async fn unpush(&self, num: isize) -> Result<Vec<T>, ErrorTypes>
pub async fn unpush(&self, num: isize) -> Result<Vec<T>, ErrorTypes>
Pop items from the low priority end of the queue
Sourcepub async fn select(
queues: &[&PriorityQueue<T>],
timeout: Option<Duration>,
) -> Result<Option<(String, T)>, ErrorTypes>
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
Sourcepub async fn all_length(
queues: &[&PriorityQueue<T>],
) -> Result<Vec<u64>, ErrorTypes>
pub async fn all_length( queues: &[&PriorityQueue<T>], ) -> Result<Vec<u64>, ErrorTypes>
Utility function for batch reading queue lengths.