pub struct Job<M>where
M: Executable + Clone,{
pub context: JobContext,
pub data: M,
}Fields§
§context: JobContext§data: MImplementations§
Source§impl<M> Job<M>where
M: Executable + Clone,
impl<M> Job<M>where
M: Executable + Clone,
Sourcepub fn new(job: M) -> Job<M>
pub fn new(job: M) -> Job<M>
Create a new job.
ⓘ
#[derive(BackgroundJob, Serialize, Deserialize, Debug, Clone)]
pub struct Print {
pub number: i32,
}
#[aj::async_trait]
impl Execute for Print {
type Output = ();
async fn execute(&mut self, _: &JobContext) -> Self::Output {
println!("Hello, {}", self.number);
}
}
let job = Job::new(Print {
number: 1,
})pub fn set_context(self, context: JobContext) -> Job<M>
pub fn context(self, context: JobContext) -> Job<M>
Sourcepub fn set_job_type(self, job_type: JobType) -> Job<M>
pub fn set_job_type(self, job_type: JobType) -> Job<M>
Set Job Type
pub fn job_type(self, job_type: JobType) -> Job<M>
Sourcepub fn schedule_at(self, schedule_at: DateTime<Utc>) -> Job<M>
pub fn schedule_at(self, schedule_at: DateTime<Utc>) -> Job<M>
Schedule job to run at specific time
ⓘ
job.schedule_at(get_now() + Duration::seconds(2));Sourcepub fn delay(self, after: TimeDelta) -> Job<M>
pub fn delay(self, after: TimeDelta) -> Job<M>
Schedule job to run after specific time
ⓘ
job.delay(Duration::seconds(2));Sourcepub fn cron(self, cron_expression: &str) -> Job<M>
pub fn cron(self, cron_expression: &str) -> Job<M>
Schedule job run by Cron Pattern
ⓘ
job.cron("* * * * * * *");Sourcepub fn set_retry(self, retry: Retry) -> Job<M>
pub fn set_retry(self, retry: Retry) -> Job<M>
Set Retry logic for job
job.set_retry(aj::Retry::default())
pub fn retry(self, retry: Retry) -> Job<M>
Source§impl<M> Job<M>where
M: BackgroundJob + Executable + Unpin + Send + Sync + Clone + Serialize + DeserializeOwned + 'static,
impl<M> Job<M>where
M: BackgroundJob + Executable + Unpin + Send + Sync + Clone + Serialize + DeserializeOwned + 'static,
Trait Implementations§
Source§impl<'de, M> Deserialize<'de> for Job<M>
impl<'de, M> Deserialize<'de> for Job<M>
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Job<M>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Job<M>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<M> Serialize for Job<M>
impl<M> Serialize for Job<M>
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,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl<M> Freeze for Job<M>where
M: Freeze,
impl<M> RefUnwindSafe for Job<M>where
M: RefUnwindSafe,
impl<M> Send for Job<M>where
M: Send,
impl<M> Sync for Job<M>where
M: Sync,
impl<M> Unpin for Job<M>where
M: Unpin,
impl<M> UnwindSafe for Job<M>where
M: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<A, T> DynMessage<A> for T
impl<A, T> DynMessage<A> for T
Source§fn handle_dyn(
self: Box<T>,
state: &mut A,
actor_ref: ActorRef<A>,
tx: Option<Sender<Result<Box<dyn Any + Send>, SendError<Box<dyn Any + Send>, Box<dyn Any + Send>>>>>,
) -> Pin<Box<dyn Future<Output = Option<Box<dyn Debug + Send>>> + Send + '_>>
fn handle_dyn( self: Box<T>, state: &mut A, actor_ref: ActorRef<A>, tx: Option<Sender<Result<Box<dyn Any + Send>, SendError<Box<dyn Any + Send>, Box<dyn Any + Send>>>>>, ) -> Pin<Box<dyn Future<Output = Option<Box<dyn Debug + Send>>> + Send + '_>>
Handles the dyn message with the provided actor state, ref, and reply sender.
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