pub enum QueueDriver {
Sync,
Memory,
Database,
Redis,
Sqs,
}Expand description
Which Queue to build.
use rainier_queue::QueueDriver;
use rainier_support::Setting;
assert!(!QueueDriver::Sync.is_deferred(), "sync runs the job inline");
assert!(QueueDriver::parse("database").unwrap().survives_a_restart());Variants§
Sync
Run the job inline, on the thread that dispatched it.
The default because it needs no worker: a fresh clone dispatches a job and the job happens. Also the reason a slow job makes a slow request — which is the thing a queue exists to avoid, so this is a development setting.
Memory
A queue in this process’s memory.
For tests that want a job to be queued rather than run, so they can assert on it. Lost on restart, invisible to other processes.
Database
Two tables in the application’s own database.
Durable, shared, and needs no new infrastructure — the reason it is
the usual production answer. Needs the migrations
(DatabaseQueue::migrations()) and a queue:work process.
Redis
Redis streams.
Durable-ish, and the qualifier is the point: Redis acknowledges a
write before it is on disk and before a replica has it, so a job
can be lost to a crash or a failover. Right for work you can afford
to lose, wrong for work you cannot — see the
driver’s docs. Needs the redis feature.
Sqs
Amazon SQS.
Durable and managed, with the visibility timeout doing the
reservation. Needs the sqs feature.
Implementations§
Source§impl QueueDriver
impl QueueDriver
Source§impl QueueDriver
impl QueueDriver
Sourcepub fn is_deferred(&self) -> bool
pub fn is_deferred(&self) -> bool
Whether dispatching returns before the job has run.
false for Sync, which is the whole difference between
it and the others — and the reason a test that asserts on a side effect
passes under sync and hangs under everything else.
Sourcepub fn survives_a_restart(&self) -> bool
pub fn survives_a_restart(&self) -> bool
Whether a job dispatched now survives this process exiting.
True for anything that stores the job somewhere else. It is not the
same question as whether the job is safe — see
may_lose_an_accepted_job, which is
the one that catches Redis.
Sourcepub fn may_lose_an_accepted_job(&self) -> bool
pub fn may_lose_an_accepted_job(&self) -> bool
Whether a dispatch this driver accepted can still be lost.
True only for Redis, and it is the distinction the
obvious question misses: a Redis job survives your process restarting,
because it lives in another one — and can still vanish, because Redis
acknowledges a write before it is on disk (appendfsync everysec
leaves a window of about a second) and before any replica has it (
replication is asynchronous, so a failover can drop confirmed writes).
A database queue’s insert is committed before it returns; SQS is replicated across availability zones before it acknowledges. Neither can tell you a job is queued and then lose it.
So this is the predicate a deploy check should look at when the work is a payment rather than a cache warm.
Sourcepub fn needs_a_worker(&self) -> bool
pub fn needs_a_worker(&self) -> bool
Whether this driver needs a queue:work process to make progress.
Trait Implementations§
Source§impl AsRef<str> for QueueDriver
impl AsRef<str> for QueueDriver
Source§impl Clone for QueueDriver
impl Clone for QueueDriver
Source§fn clone(&self) -> QueueDriver
fn clone(&self) -> QueueDriver
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for QueueDriver
Source§impl Debug for QueueDriver
impl Debug for QueueDriver
Source§impl Default for QueueDriver
impl Default for QueueDriver
Source§fn default() -> QueueDriver
fn default() -> QueueDriver
Source§impl<'de> Deserialize<'de> for QueueDriver
impl<'de> Deserialize<'de> for QueueDriver
Source§fn deserialize<D>(
deserializer: D,
) -> Result<QueueDriver, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<QueueDriver, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Display for QueueDriver
impl Display for QueueDriver
impl Eq for QueueDriver
Source§impl FromStr for QueueDriver
impl FromStr for QueueDriver
Source§impl Hash for QueueDriver
impl Hash for QueueDriver
Source§impl PartialEq for QueueDriver
impl PartialEq for QueueDriver
Source§impl Serialize for QueueDriver
impl Serialize for QueueDriver
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Source§impl Setting for QueueDriver
impl Setting for QueueDriver
Source§const SETTING: &'static str = "queue driver"
const SETTING: &'static str = "queue driver"
"cache driver". Read moreSource§const ALL: &'static [QueueDriver]
const ALL: &'static [QueueDriver]
impl StructuralPartialEq for QueueDriver
Auto Trait Implementations§
impl Freeze for QueueDriver
impl RefUnwindSafe for QueueDriver
impl Send for QueueDriver
impl Sync for QueueDriver
impl Unpin for QueueDriver
impl UnsafeUnpin for QueueDriver
impl UnwindSafe for QueueDriver
Blanket Implementations§
impl<T> Actor for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Event for T
impl<T> Event for T
Source§fn event_name() -> &'static strwhere
Self: Sized,
fn event_name() -> &'static strwhere
Self: Sized,
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