pub struct MockJobDispatch { /* private fields */ }Expand description
Records dispatched jobs for later verification.
Implementations§
Source§impl MockJobDispatch
impl MockJobDispatch
pub fn new() -> Self
pub async fn dispatch<T: Serialize>( &self, job_type: &str, args: T, ) -> Result<Uuid>
pub async fn dispatch_at<T: Serialize>( &self, job_type: &str, args: T, scheduled_at: DateTime<Utc>, ) -> Result<Uuid>
pub fn dispatched_jobs(&self) -> Vec<DispatchedJob>
pub fn jobs_of_type(&self, job_type: &str) -> Vec<DispatchedJob>
pub fn assert_dispatched(&self, job_type: &str)
pub fn assert_dispatched_with<F>(&self, job_type: &str, predicate: F)
pub fn assert_not_dispatched(&self, job_type: &str)
pub fn assert_dispatch_count(&self, job_type: &str, expected: usize)
pub fn clear(&self)
pub fn complete_job(&self, job_id: Uuid)
pub fn fail_job(&self, job_id: Uuid)
pub fn cancel_job(&self, job_id: Uuid, reason: Option<String>)
Trait Implementations§
Source§impl Default for MockJobDispatch
impl Default for MockJobDispatch
Source§impl JobDispatch for MockJobDispatch
impl JobDispatch for MockJobDispatch
Source§fn get_info(&self, _job_type: &str) -> Option<JobInfo>
fn get_info(&self, _job_type: &str) -> Option<JobInfo>
Get job info by name for auth checking.
Source§fn dispatch_by_name(
&self,
job_type: &str,
args: Value,
owner_subject: Option<String>,
_tenant_id: Option<Uuid>,
) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + '_>>
fn dispatch_by_name( &self, job_type: &str, args: Value, owner_subject: Option<String>, _tenant_id: Option<Uuid>, ) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + '_>>
Dispatch a job by its registered name.
Source§fn dispatch_by_name_at(
&self,
job_type: &str,
args: Value,
scheduled_at: DateTime<Utc>,
owner_subject: Option<String>,
_tenant_id: Option<Uuid>,
) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + '_>>
fn dispatch_by_name_at( &self, job_type: &str, args: Value, scheduled_at: DateTime<Utc>, owner_subject: Option<String>, _tenant_id: Option<Uuid>, ) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + '_>>
Dispatch a job at a specific time by its registered name. Read more
Source§fn dispatch_in_conn<'a>(
&'a self,
_conn: &'a mut PgConnection,
job_type: &'a str,
args: Value,
owner_subject: Option<String>,
_tenant_id: Option<Uuid>,
) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + 'a>>
fn dispatch_in_conn<'a>( &'a self, _conn: &'a mut PgConnection, job_type: &'a str, args: Value, owner_subject: Option<String>, _tenant_id: Option<Uuid>, ) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + 'a>>
Dispatch a job on an existing connection — typically the live
transaction inside a
MutationContext. The insert participates in
the surrounding transaction, so the job only becomes visible to
workers after commit and is rolled back on failure.Source§fn dispatch_in_conn_at<'a>(
&'a self,
_conn: &'a mut PgConnection,
job_type: &'a str,
args: Value,
scheduled_at: DateTime<Utc>,
owner_subject: Option<String>,
_tenant_id: Option<Uuid>,
) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + 'a>>
fn dispatch_in_conn_at<'a>( &'a self, _conn: &'a mut PgConnection, job_type: &'a str, args: Value, scheduled_at: DateTime<Utc>, owner_subject: Option<String>, _tenant_id: Option<Uuid>, ) -> Pin<Box<dyn Future<Output = Result<Uuid>> + Send + 'a>>
Dispatch a job at a specific time on an existing connection. Read more
Auto Trait Implementations§
impl !Freeze for MockJobDispatch
impl RefUnwindSafe for MockJobDispatch
impl Send for MockJobDispatch
impl Sync for MockJobDispatch
impl Unpin for MockJobDispatch
impl UnsafeUnpin for MockJobDispatch
impl UnwindSafe for MockJobDispatch
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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