Skip to main content

FakeQueue

Struct FakeQueue 

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

A queue that records dispatches and runs nothing.

Implementations§

Source§

impl FakeQueue

Source

pub fn new() -> Self

Source

pub fn all(&self) -> Vec<QueuedJob>

Every job pushed, in order.

Source

pub fn pushed(&self, name: &str) -> Vec<QueuedJob>

The jobs pushed under one name — for asserting on a payload.

Source

pub fn count(&self) -> usize

How many jobs were pushed in total.

Source

pub fn reset(&self)

Forget everything, so one test can reuse a fake across phases.

Source

pub fn assert_pushed(&self, name: &str) -> &Self

Assert a job with this name was dispatched at least once.

Source

pub fn assert_pushed_times(&self, name: &str, times: usize) -> &Self

Assert a job with this name was dispatched exactly times times.

Source

pub fn assert_not_pushed(&self, name: &str) -> &Self

Assert a job with this name was never dispatched.

Source

pub fn assert_nothing_pushed(&self) -> &Self

Assert nothing at all was dispatched.

Source

pub fn assert_pushed_on(&self, queue: &str, name: &str) -> &Self

Assert a job was dispatched onto a particular queue.

Source

pub fn assert_pushed_later(&self, name: &str, delay: Duration) -> &Self

Assert a job was dispatched with a delay of at least delay.

Trait Implementations§

Source§

impl Default for FakeQueue

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Queue for FakeQueue

Source§

fn pop<'a>( &'a self, _queue: &'a str, ) -> BoxFuture<'a, Result<Option<ReservedJob>>>

Always empty. A fake that handed jobs back would run them, which is the one thing it exists not to do.

Source§

fn driver(&self) -> &'static str

The driver’s name. It appears in queue.* events and error messages, which is how Telescope shows which backend handled a job.
Source§

fn push(&self, job: QueuedJob) -> BoxFuture<'_, Result<String>>

Store a job. Returns the driver’s identifier for it. Read more
Source§

fn size<'a>(&'a self, queue: &'a str) -> BoxFuture<'a, Result<u64>>

How many jobs are waiting on a queue, including delayed ones.
Source§

fn delete<'a>(&'a self, _job: &'a ReservedJob) -> BoxFuture<'a, Result<()>>

Finish with a reserved job: it succeeded and is gone.
Source§

fn release<'a>( &'a self, _job: &'a ReservedJob, _delay: Duration, ) -> BoxFuture<'a, Result<()>>

Put a reserved job back, available again after delay. Read more
Source§

fn fail<'a>( &'a self, _job: &'a ReservedJob, _error: &'a str, ) -> BoxFuture<'a, Result<()>>

Move a reserved job to the dead-letter store with the error that killed it. It must no longer be on the queue afterwards.
Source§

fn failed_jobs(&self) -> BoxFuture<'_, Result<Vec<FailedJob>>>

Everything in the dead-letter store, oldest first.
Source§

fn clear<'a>(&'a self, queue: &'a str) -> BoxFuture<'a, Result<u64>>

Throw away every job waiting on a queue. Returns how many went.
Source§

fn push_on<'a>( &'a self, queue: &'a str, job: QueuedJob, ) -> BoxFuture<'a, Result<String>>

Store a job on a named queue, whatever the job itself asked for.
Source§

fn later<'a>( &'a self, delay: Duration, job: QueuedJob, ) -> BoxFuture<'a, Result<String>>

Store a job that only becomes visible to a worker after delay.

Auto Trait Implementations§

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> QueueExt for T
where T: Queue + ?Sized,

Source§

fn dispatch_chain<'a>(&'a self, chain: Chain) -> BoxFuture<'a, Result<String>>

dispatch(SendWelcomeEmail { user_id }) — the everyday call. Push the first step of a chain; the worker pushes each next step as the one before it succeeds. Returns the first step’s id.
Source§

fn dispatch<'a, J: Job>(&'a self, job: &'a J) -> BoxFuture<'a, Result<String>>

Source§

fn dispatch_on<'a, J: Job>( &'a self, queue: &'a str, job: &'a J, ) -> BoxFuture<'a, Result<String>>

Dispatch onto a named queue instead of the job’s own.
Source§

fn dispatch_later<'a, J: Job>( &'a self, delay: Duration, job: &'a J, ) -> BoxFuture<'a, Result<String>>

Dispatch, but not before delay has passed.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.