pub struct Scheduler { /* private fields */ }Expand description
Async job scheduler with interval, one-shot, and cron-style scheduling.
Create a Scheduler, register jobs with Scheduler::schedule, then
call Scheduler::start to launch the background run loop.
Implementations§
Source§impl Scheduler
impl Scheduler
Sourcepub async fn schedule<F>(
&self,
name: &str,
schedule: Schedule,
handler: F,
) -> JobId
pub async fn schedule<F>( &self, name: &str, schedule: Schedule, handler: F, ) -> JobId
Register a new job and return its JobId.
handler is called every time the schedule fires. It must return a
BoxFuture<'static, ()>.
Sourcepub async fn cancel(&self, id: JobId) -> bool
pub async fn cancel(&self, id: JobId) -> bool
Cancel a job by ID. Returns true if the job existed.
Sourcepub async fn enable(&self, id: JobId, enabled: bool)
pub async fn enable(&self, id: JobId, enabled: bool)
Enable or disable a job. Disabled jobs are skipped by the run loop.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Scheduler
impl !UnwindSafe for Scheduler
impl Freeze for Scheduler
impl Send for Scheduler
impl Sync for Scheduler
impl Unpin for Scheduler
impl UnsafeUnpin for Scheduler
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
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> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request