pub struct CronScheduler { /* private fields */ }Expand description
SurrealDB-backed cron scheduler.
Implementations§
Source§impl CronScheduler
impl CronScheduler
Sourcepub fn new(memory: Arc<SurrealMemory>) -> Self
pub fn new(memory: Arc<SurrealMemory>) -> Self
Create with a SurrealDB memory backend.
Sourcepub async fn add(
&self,
name: &str,
schedule: &str,
task: &str,
channel: &str,
chat_id: &str,
model: &str,
) -> Result<String>
pub async fn add( &self, name: &str, schedule: &str, task: &str, channel: &str, chat_id: &str, model: &str, ) -> Result<String>
Add a new cron job. Returns the job ID.
pub async fn add_once( &self, name: &str, run_at: DateTime<Utc>, task: &str, channel: &str, chat_id: &str, model: &str, ) -> Result<String>
Sourcepub async fn enable(&self, id_or_name: &str) -> Result<bool>
pub async fn enable(&self, id_or_name: &str) -> Result<bool>
Enable a cron job.
Enabling is the documented recovery from a dead status, so it also
recomputes next_run and clears the status. Setting enabled = true
alone leaves a job matching no branch of the due query while list
reports it as enabled.
pub async fn claim_due_jobs(&self, channel: &str) -> Result<Vec<CronJob>>
Sourcepub async fn mark_run(
&self,
job_id: &str,
run_token: &str,
schedule: &str,
) -> Result<()>
pub async fn mark_run( &self, job_id: &str, run_token: &str, schedule: &str, ) -> Result<()>
Mark a job as just run and compute next_run.
pub async fn release_run(&self, job_id: &str, run_token: &str) -> Result<()>
pub async fn fail_run( &self, job_id: &str, run_token: &str, error: &str, ) -> Result<()>
Auto Trait Implementations§
impl !Freeze for CronScheduler
impl !RefUnwindSafe for CronScheduler
impl !UnwindSafe for CronScheduler
impl Send for CronScheduler
impl Sync for CronScheduler
impl Unpin for CronScheduler
impl UnsafeUnpin for CronScheduler
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
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>
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