pub struct JobDefinition {
pub job_type_id: Cow<'static, str>,
pub target_execution_time: SystemTime,
pub input_payload_json: String,
pub labels: IndexMap<String, String>,
pub timeout_policy: TimeoutPolicy,
pub retry_policy: RetryPolicy,
pub metadata_json: Option<String>,
}Expand description
The definition of a job that can be executed in the future.
Fields§
§job_type_id: Cow<'static, str>The ID of the job type.
target_execution_time: SystemTimeThe target execution time of the job.
If not provided, it should be set to the current time.
input_payload_json: StringThe job input payload JSON that is passed to the worker.
labels: IndexMap<String, String>The labels of the job.
timeout_policy: TimeoutPolicyThe timeout policy of the job.
retry_policy: RetryPolicyRetry policy for the job.
metadata_json: Option<String>Additional metadata for the job.
Implementations§
Source§impl JobDefinition
impl JobDefinition
Sourcepub fn at(self, target_execution_time: impl Into<SystemTime>) -> Self
pub fn at(self, target_execution_time: impl Into<SystemTime>) -> Self
Set the target execution time of the job.
Sourcepub fn with_label(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_label( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add a label to the job.
Sourcepub fn with_label_json(
self,
key: impl Into<String>,
value: impl Serialize,
) -> Self
pub fn with_label_json( self, key: impl Into<String>, value: impl Serialize, ) -> Self
Sourcepub fn with_timeout(self, timeout: impl Into<Duration>) -> Self
pub fn with_timeout(self, timeout: impl Into<Duration>) -> Self
Set the timeout for the job.
The timeout is calculated from the start time of the job by default.
Sourcepub fn with_retries(self, retries: u64) -> Self
pub fn with_retries(self, retries: u64) -> Self
Set the number of retries for the job.
Sourcepub fn replace_metadata(self, metadata: impl Serialize) -> Self
pub fn replace_metadata(self, metadata: impl Serialize) -> Self
Set additional metadata for the job.
Note that this will replace any existing metadata.
§Panics
If the metadata cannot be serialized to JSON.
Source§impl JobDefinition
impl JobDefinition
Sourcepub fn repeat_every(self, interval: Duration) -> ScheduleDefinition
pub fn repeat_every(self, interval: Duration) -> ScheduleDefinition
Create a schedule from the job definition that repeats at a fixed interval.
Sourcepub fn repeat_cron(
self,
cron_expression: impl Into<String>,
) -> Result<ScheduleDefinition>
pub fn repeat_cron( self, cron_expression: impl Into<String>, ) -> Result<ScheduleDefinition>
Create a schedule from the job definition that repeats according to a cron expression.
§Errors
If the cron expression is invalid.
Source§impl JobDefinition
impl JobDefinition
Sourcepub fn into_typed_unknown(self) -> TypedJobDefinition
pub fn into_typed_unknown(self) -> TypedJobDefinition
Cast the job definition to a typed job definition with an unknown job type.
Sourcepub fn into_typed<J>(self) -> TypedJobDefinition<J>
pub fn into_typed<J>(self) -> TypedJobDefinition<J>
Cast the job definition to a typed job definition with a known job type.
Trait Implementations§
Source§impl Clone for JobDefinition
impl Clone for JobDefinition
Source§fn clone(&self) -> JobDefinition
fn clone(&self) -> JobDefinition
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for JobDefinition
impl Debug for JobDefinition
Source§impl From<JobDefinition> for JobDefinition
impl From<JobDefinition> for JobDefinition
Source§fn from(definition: JobDefinition) -> Self
fn from(definition: JobDefinition) -> Self
Source§impl From<JobDefinition> for JobDefinition
impl From<JobDefinition> for JobDefinition
Source§fn from(definition: JobDefinition) -> Self
fn from(definition: JobDefinition) -> Self
Source§impl<J> From<JobDefinition> for TypedJobDefinition<J>
impl<J> From<JobDefinition> for TypedJobDefinition<J>
Source§fn from(job_definition: JobDefinition) -> Self
fn from(job_definition: JobDefinition) -> Self
Source§impl<J> From<TypedJobDefinition<J>> for JobDefinition
impl<J> From<TypedJobDefinition<J>> for JobDefinition
Source§fn from(typed: TypedJobDefinition<J>) -> Self
fn from(typed: TypedJobDefinition<J>) -> Self
Auto Trait Implementations§
impl Freeze for JobDefinition
impl RefUnwindSafe for JobDefinition
impl Send for JobDefinition
impl Sync for JobDefinition
impl Unpin for JobDefinition
impl UnwindSafe for JobDefinition
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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<W> IntoExecutionHandler for W
impl<W> IntoExecutionHandler for W
Source§fn handler<J>(self) -> Arc<dyn ExecutionHandlerRaw + Send + Sync>where
Self: ExecutionHandler<J>,
J: JobType,
fn handler<J>(self) -> Arc<dyn ExecutionHandlerRaw + Send + Sync>where
Self: ExecutionHandler<J>,
J: JobType,
self into a [RawHandler] that can be registered
in workers.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>
T in a tonic::Request