pub struct Queue { /* private fields */ }
Expand description
Queue
Implementations§
Source§impl Queue
impl Queue
Sourcepub fn new(config: QueueConfig, conn: ConnectionManager) -> Self
pub fn new(config: QueueConfig, conn: ConnectionManager) -> Self
Creates new instance from existing connection
Sourcepub fn connection(&self) -> ConnectionManager
pub fn connection(&self) -> ConnectionManager
Gets underlying connection
Sourcepub async fn create_group(&self, group: &str) -> Result<(), RedisError>
pub async fn create_group(&self, group: &str) -> Result<(), RedisError>
Creates group within queue where pending messages are stored.
User MUST create group before using it.
If config’s stream
doesn’t exist yet, creates it
Sourcepub fn time(&self) -> impl Future<Output = Result<Duration, RedisError>> + Send
pub fn time(&self) -> impl Future<Output = Result<Duration, RedisError>> + Send
Returns redis’s current time
Sourcepub async fn len(&self) -> Result<usize, RedisError>
pub async fn len(&self) -> Result<usize, RedisError>
Returns number of elements within queue
Sourcepub async fn consume(
&self,
group: &str,
ids: &[StreamId],
) -> Result<usize, RedisError>
pub async fn consume( &self, group: &str, ids: &[StreamId], ) -> Result<usize, RedisError>
Marks specified StreamId
as successfully consumed, resulting in corresponding messages’ deletion.
Sourcepub async fn delete(&self, ids: &[StreamId]) -> Result<usize, RedisError>
pub async fn delete(&self, ids: &[StreamId]) -> Result<usize, RedisError>
Requests to delete message from the stream.
Sourcepub async fn trim(&self, method: TrimMethod) -> Result<u64, RedisError>
pub async fn trim(&self, method: TrimMethod) -> Result<u64, RedisError>
Trims elements according to specified method
Sourcepub async fn purge(&self) -> Result<(), RedisError>
pub async fn purge(&self) -> Result<(), RedisError>
Purges whole message stream
Sourcepub async fn groups_info(&self) -> Result<Vec<GroupInfo>, RedisError>
pub async fn groups_info(&self) -> Result<Vec<GroupInfo>, RedisError>
Retrieves summary of every group existing within stream
Sourcepub async fn pending_stats(
&self,
group: &str,
) -> Result<PendingStats, RedisError>
pub async fn pending_stats( &self, group: &str, ) -> Result<PendingStats, RedisError>
Retrieves pending messages statistics for group
Sourcepub async fn append<T: ToRedisArgs>(
&self,
item: &EntryValue<T>,
) -> Result<StreamId, RedisError>
pub async fn append<T: ToRedisArgs>( &self, item: &EntryValue<T>, ) -> Result<StreamId, RedisError>
Adds item to the queue at the end of queue.
Returns StreamId
of newly created item
Sourcepub async fn append_delayed<T: ToRedisArgs>(
&self,
item: &EntryValue<T>,
delay: Duration,
) -> Result<StreamId, RedisError>
pub async fn append_delayed<T: ToRedisArgs>( &self, item: &EntryValue<T>, delay: Duration, ) -> Result<StreamId, RedisError>
Adds item to the queue with ID generated from current time plus provided delay
Returns StreamId
of newly created item
Sourcepub async fn pending(
&self,
params: &PendingParams<'_>,
) -> Result<Vec<PendingEntry>, RedisError>
pub async fn pending( &self, params: &PendingParams<'_>, ) -> Result<Vec<PendingEntry>, RedisError>
Retrieves pending messages within stream.
Sourcepub async fn fetch<T: FromRedisValue>(
&self,
params: &FetchParams<'_>,
) -> Result<FetchResult<T>, RedisError>
pub async fn fetch<T: FromRedisValue>( &self, params: &FetchParams<'_>, ) -> Result<FetchResult<T>, RedisError>
Attempts to fetch message from within queue.
By new it means messages that are not read yet.
Once message is read, it is added as pending to group, according to configuration.
When processing is finished, user must acknowledge ids to remove them from pending group. Until then these messages can be always re-fetched.
Sourcepub async fn fetch_entries<T: FromRedisValue>(
&self,
params: &FetchParams<'_>,
) -> Result<FetchEntries<T>, RedisError>
pub async fn fetch_entries<T: FromRedisValue>( &self, params: &FetchParams<'_>, ) -> Result<FetchEntries<T>, RedisError>
Attempts to fetch message from within queue.
By new it means messages that are not read yet.
Once message is read, it is added as pending to group, according to configuration.
When processing is finished, user must acknowledge ids to remove them from pending group. Until then these messages can be always re-fetched.
Sourcepub fn fetch_iter<'a>(&self, params: FetchParams<'a>) -> FetchIter<'a>
pub fn fetch_iter<'a>(&self, params: FetchParams<'a>) -> FetchIter<'a>
Creates new fetch iterator.
This is just useful utility when there is no need to change params
at runtime.
Sourcepub fn pending_iter<'a>(&self, params: PendingParams<'a>) -> PendingIter<'a>
pub fn pending_iter<'a>(&self, params: PendingParams<'a>) -> PendingIter<'a>
Creates new pending info iterator.
This is just useful utility when there is no need to change params
at runtime.