pub struct ScheduledTask<'a> { /* private fields */ }Expand description
A task just added to the Schedule, to narrow when it runs or add
hooks. It derefs to the schedule, so adding tasks can go on in a chain.
Implementations§
Source§impl ScheduledTask<'_>
impl ScheduledTask<'_>
Sourcepub fn between(self, from: &str, to: &str) -> Self
pub fn between(self, from: &str, to: &str) -> Self
Only between two times of day (HH:MM, both included); "22:00" to
"06:00" spans midnight.
Sourcepub fn timezone(self, zone: &str) -> Self
pub fn timezone(self, zone: &str) -> Self
Runs in this time zone instead of APP_TIMEZONE (Asia/Jakarta,
+07:00, UTC).
Sourcepub fn on_failure<F, Fut>(self, hook: F) -> Self
pub fn on_failure<F, Fut>(self, hook: F) -> Self
Runs after a run fails or panics, with the error (e.g. to alert someone). The failure is logged either way.
Sourcepub fn ping_before(self, url: impl Into<String>) -> Self
pub fn ping_before(self, url: impl Into<String>) -> Self
GETs url before each run, e.g. a health check’s “start” URL
(Healthchecks.io, Cronitor, Better Stack). A failing ping is logged,
never stops the task.
Sourcepub fn then_ping(self, url: impl Into<String>) -> Self
pub fn then_ping(self, url: impl Into<String>) -> Self
GETs url after each run, however it went.
Sourcepub fn ping_on_success(self, url: impl Into<String>) -> Self
pub fn ping_on_success(self, url: impl Into<String>) -> Self
GETs url after a successful run.
Sourcepub fn ping_on_failure(self, url: impl Into<String>) -> Self
pub fn ping_on_failure(self, url: impl Into<String>) -> Self
GETs url after a failed run.
Methods from Deref<Target = Schedule>§
Sourcepub fn every<F, Fut>(
&mut self,
interval: Duration,
name: &str,
task: F,
) -> ScheduledTask<'_>
pub fn every<F, Fut>( &mut self, interval: Duration, name: &str, task: F, ) -> ScheduledTask<'_>
Every interval, aligned to the clock (every 5 minutes runs at :00, :05, …).
Sourcepub fn every_minute<F, Fut>(&mut self, name: &str, task: F) -> ScheduledTask<'_>
pub fn every_minute<F, Fut>(&mut self, name: &str, task: F) -> ScheduledTask<'_>
Every minute, on the minute.
Sourcepub fn every_minutes<F, Fut>(
&mut self,
minutes: u64,
name: &str,
task: F,
) -> ScheduledTask<'_>
pub fn every_minutes<F, Fut>( &mut self, minutes: u64, name: &str, task: F, ) -> ScheduledTask<'_>
Every minutes minutes, aligned to the clock (every 15 runs at :00, :15, …).
Sourcepub fn hourly<F, Fut>(&mut self, name: &str, task: F) -> ScheduledTask<'_>
pub fn hourly<F, Fut>(&mut self, name: &str, task: F) -> ScheduledTask<'_>
Every hour, on the hour.
Sourcepub fn cron<F, Fut>(
&mut self,
expression: &str,
name: &str,
task: F,
) -> ScheduledTask<'_>
pub fn cron<F, Fut>( &mut self, expression: &str, name: &str, task: F, ) -> ScheduledTask<'_>
When the wall clock matches a cron expression: minute, hour, day of
month, month, day of week (0/7 or SUN), with *, a-b, lists
and /step; also @hourly, @daily, @weekly, @monthly,
@yearly. "30 9 * * 1-5" is 09:30 on weekdays.
Sourcepub fn daily_at<F, Fut>(
&mut self,
time: &str,
name: &str,
task: F,
) -> ScheduledTask<'_>
pub fn daily_at<F, Fut>( &mut self, time: &str, name: &str, task: F, ) -> ScheduledTask<'_>
Every day at HH:MM.
Sourcepub fn weekly_on<F, Fut>(
&mut self,
day: Weekday,
time: &str,
name: &str,
task: F,
) -> ScheduledTask<'_>
pub fn weekly_on<F, Fut>( &mut self, day: Weekday, time: &str, name: &str, task: F, ) -> ScheduledTask<'_>
Every week on day at HH:MM.
Sourcepub fn monthly_on<F, Fut>(
&mut self,
day: u32,
time: &str,
name: &str,
task: F,
) -> ScheduledTask<'_>
pub fn monthly_on<F, Fut>( &mut self, day: u32, time: &str, name: &str, task: F, ) -> ScheduledTask<'_>
Every month on day (1–31; months without that day are skipped, so
use 28 or lower for every month) at HH:MM.
Sourcepub fn upcoming(&self, zone: Zone) -> Vec<UpcomingRun>
pub fn upcoming(&self, zone: Zone) -> Vec<UpcomingRun>
Each task with its next run (in zone unless the task has its own),
as schedule:list shows them.
Trait Implementations§
Source§impl Deref for ScheduledTask<'_>
impl Deref for ScheduledTask<'_>
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for ScheduledTask<'a>
impl<'a> !UnwindSafe for ScheduledTask<'a>
impl<'a> Freeze for ScheduledTask<'a>
impl<'a> Send for ScheduledTask<'a>
impl<'a> Sync for ScheduledTask<'a>
impl<'a> Unpin for ScheduledTask<'a>
impl<'a> UnsafeUnpin for ScheduledTask<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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