pub struct QueueEvents { /* private fields */ }Expand description
A cross-process, stream-based queue event listener.
See the module documentation for details.
Implementations§
Source§impl QueueEvents
impl QueueEvents
Sourcepub async fn new(name: &str, opts: QueueEventsOptions) -> Result<Self, Error>
pub async fn new(name: &str, opts: QueueEventsOptions) -> Result<Self, Error>
Create a new QueueEvents listener with its own Redis connection.
Sourcepub async fn with_connection(
name: &str,
conn: RedisConnection,
opts: QueueEventsOptions,
) -> Result<Self, Error>
pub async fn with_connection( name: &str, conn: RedisConnection, opts: QueueEventsOptions, ) -> Result<Self, Error>
Create a QueueEvents listener that reuses an existing connection.
Note: the listener still opens a dedicated connection internally for the
blocking XREAD; conn is only used for its client/configuration.
Sourcepub async fn from_queue_options(
name: &str,
opts: &QueueOptions,
) -> Result<Self, Error>
pub async fn from_queue_options( name: &str, opts: &QueueOptions, ) -> Result<Self, Error>
Convenience constructor that derives options from QueueOptions.
Sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
Whether the consuming loop is currently running.
Sourcepub async fn run(&self) -> Result<(), Error>
pub async fn run(&self) -> Result<(), Error>
Start consuming events.
Called automatically when QueueEventsOptions::autorun is true.
Returns an error if the listener is already running.
Sourcepub async fn next_event(&self) -> Option<QueueEventEntry>
pub async fn next_event(&self) -> Option<QueueEventEntry>
Wait for and return the next event, or None once the listener is closed
and the buffer is drained.
Sourcepub async fn try_next_event(&self) -> Option<QueueEventEntry>
pub async fn try_next_event(&self) -> Option<QueueEventEntry>
Try to receive a buffered event without waiting.
Auto Trait Implementations§
impl !RefUnwindSafe for QueueEvents
impl !UnwindSafe for QueueEvents
impl Freeze for QueueEvents
impl Send for QueueEvents
impl Sync for QueueEvents
impl Unpin for QueueEvents
impl UnsafeUnpin for QueueEvents
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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