pub struct RecurringJob {
pub id: String,
pub cron: String,
pub method: String,
pub payload: Value,
pub queue: String,
pub next_run_at: DateTime<Utc>,
pub last_run_at: Option<DateTime<Utc>>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub enabled: bool,
}Expand description
A cron-scheduled job template.
Fields§
§id: StringStable recurring-job id (caller-chosen, e.g. "daily-report").
cron: StringCron expression in the cron crate’s 6/7-field format
(sec min hour day month dow [year]).
method: StringMethod name registered with the worker registry.
payload: ValueJSON payload passed to the worker on each firing.
queue: StringQueue the materialized jobs land in.
next_run_at: DateTime<Utc>Next firing time (computed from cron).
last_run_at: Option<DateTime<Utc>>When the template last produced a job, or None if never fired.
created_at: DateTime<Utc>When the template was first created.
updated_at: DateTime<Utc>When the template was last mutated.
enabled: boolDisabled templates are ignored by the poller.
Implementations§
Source§impl RecurringJob
impl RecurringJob
Sourcepub fn new(
id: impl Into<String>,
cron: impl Into<String>,
method: impl Into<String>,
payload: JsonValue,
queue: impl Into<String>,
) -> Result<Self>
pub fn new( id: impl Into<String>, cron: impl Into<String>, method: impl Into<String>, payload: JsonValue, queue: impl Into<String>, ) -> Result<Self>
Creates a new recurring-job template. Parses cron and computes
next_run_at from now. Returns a validation error if the
expression is invalid or has no future occurrences.
Sourcepub fn advance(&mut self, from: DateTime<Utc>) -> Result<()>
pub fn advance(&mut self, from: DateTime<Utc>) -> Result<()>
Recomputes next_run_at to the next occurrence strictly after
from, updating updated_at in the process. Returns an error if
the stored cron expression is no longer parseable or has no future
occurrence (the latter shouldn’t happen for sane expressions).
Trait Implementations§
Source§impl Clone for RecurringJob
impl Clone for RecurringJob
Source§fn clone(&self) -> RecurringJob
fn clone(&self) -> RecurringJob
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more