pub struct Job { /* private fields */ }Expand description
A declared cron job. See the module documentation.
Declare as a module-level static with an app-wide unique name using
lowercase letters, digits, and dashes.
Implementations§
Source§impl Job
impl Job
Sourcepub const fn new(
name: &'static str,
path: &'static str,
schedule: Schedule,
) -> Self
pub const fn new( name: &'static str, path: &'static str, schedule: Schedule, ) -> Self
Declares a cron job named name that sends a POST request to path on
the declaring service according to schedule.
path must start with /. Both name and path must be string
literals, and schedule must be written inline so Encore can parse them
statically.
Sourcepub const fn title(self, title: &'static str) -> Self
pub const fn title(self, title: &'static str) -> Self
Sets a human-readable display title shown in the dashboard instead of the job’s identifier.
Sourcepub const fn run_in_local(self, local: bool) -> Self
pub const fn run_in_local(self, local: bool) -> Self
Controls whether the job runs on schedule during local development while
an encore run session is active.
Defaults to false. Developers can still override this setting per
checkout. Deployed environments always schedule the job regardless of
this setting.
use encore::cron::{Job, Schedule};
static REFRESH: Job = Job::new("refresh-rates", "/internal/rates", Schedule::Every("30m"))
.run_in_local(true);Sourcepub const fn tag(self, _key: &'static str, _value: &'static str) -> Self
pub const fn tag(self, _key: &'static str, _value: &'static str) -> Self
Attaches a key/value tag to the job (for example, .tag("data", "pci"))
for policy and governance tooling.
Call once per tag with unique keys. Both key and value must be string
literals so Encore can parse them statically. Keys must start with a
letter, contain only lowercase letters, digits, _, and -, and must
not start with encore (reserved for Encore’s own tags). Values use the
same character set or may be empty. Each key and value is at most 63
characters, and a job may have at most 32 tags.
use encore::cron::{Job, Schedule};
static CLEANUP: Job =
Job::new("cleanup", "/internal/cleanup", Schedule::Cron("0 4 * * *")).tag("team", "ops");Sourcepub const fn path(&self) -> &'static str
pub const fn path(&self) -> &'static str
Returns the HTTP path that Encore invokes when the job runs.
Sourcepub const fn runs_in_local(&self) -> bool
pub const fn runs_in_local(&self) -> bool
Returns whether the job is configured to run on schedule locally (see
run_in_local).
Trait Implementations§
Auto Trait Implementations§
impl Forget for Job
impl Freeze for Job
impl Move for Job
impl RefUnwindSafe for Job
impl Send for Job
impl Sync for Job
impl Unpin for Job
impl UnsafeUnpin for Jobwhere
&'static str: UnsafeUnpin,
impl UnwindSafe for Jobwhere
&'static str: 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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 moreSource§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>
T in a tonic::Request