pub struct Queue;Expand description
Global handle to the queue’s database connection.
Initialise once at application start with Queue::init; worker loops
and dispatcher call Queue::connection to get the static reference.
Implementations§
Source§impl Queue
impl Queue
Sourcepub fn connection() -> &'static DatabaseConnection
pub fn connection() -> &'static DatabaseConnection
Return a reference to the global DatabaseConnection.
§Panics
Panics if Queue::init has not been called yet.
Sourcepub async fn init(conn: DatabaseConnection) -> Result<(), Error>
pub async fn init(conn: DatabaseConnection) -> Result<(), Error>
Store conn as the global connection.
Returns Err if called more than once.
Sourcepub fn is_initialized() -> bool
pub fn is_initialized() -> bool
Returns true if Queue::init has been called.
Sourcepub fn register<J>()where
J: Job + DeserializeOwned + 'static,
pub fn register<J>()where
J: Job + DeserializeOwned + 'static,
Register a job type for auto-start by the framework’s WorkerLoop.
Call this in your application bootstrap before the server starts.
The framework’s server boot path inspects Queue::has_registered_jobs
and spawns a WorkerLoop automatically when at least one type is registered.
Sourcepub fn has_registered_jobs() -> bool
pub fn has_registered_jobs() -> bool
Returns true if at least one job type has been registered via Queue::register.
Auto Trait Implementations§
impl Freeze for Queue
impl RefUnwindSafe for Queue
impl Send for Queue
impl Sync for Queue
impl Unpin for Queue
impl UnsafeUnpin for Queue
impl UnwindSafe for Queue
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