Struct Queue

Source
pub struct Queue { /* private fields */ }
Expand description

Queue

Implementations§

Source§

impl Queue

Source

pub fn new(config: QueueConfig, conn: ConnectionManager) -> Self

Creates new instance from existing connection

Source

pub fn connection(&self) -> ConnectionManager

Gets underlying connection

Source

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

Source

pub fn time(&self) -> impl Future<Output = Result<Duration, RedisError>> + Send

Returns redis’s current time

Source

pub async fn len(&self) -> Result<usize, RedisError>

Returns number of elements within queue

Source

pub async fn consume( &self, group: &str, ids: &[StreamId], ) -> Result<usize, RedisError>

Marks specified StreamId as successfully consumed, resulting in corresponding messages’ deletion.

Source

pub async fn delete(&self, ids: &[StreamId]) -> Result<usize, RedisError>

Requests to delete message from the stream.

Source

pub async fn trim(&self, method: TrimMethod) -> Result<u64, RedisError>

Trims elements according to specified method

Source

pub async fn purge(&self) -> Result<(), RedisError>

Purges whole message stream

Source

pub async fn groups_info(&self) -> Result<Vec<GroupInfo>, RedisError>

Retrieves summary of every group existing within stream

Source

pub async fn pending_stats( &self, group: &str, ) -> Result<PendingStats, RedisError>

Retrieves pending messages statistics for group

Source

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

Source

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

Source

pub async fn pending( &self, params: &PendingParams<'_>, ) -> Result<Vec<PendingEntry>, RedisError>

Retrieves pending messages within stream.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Queue

Source§

fn clone(&self) -> Queue

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Queue

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Queue

§

impl !RefUnwindSafe for Queue

§

impl Send for Queue

§

impl Sync for Queue

§

impl Unpin for Queue

§

impl !UnwindSafe for Queue

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

impl<T> ErasedDestructor for T
where T: 'static,