Skip to main content

Job

Struct Job 

Source
pub struct Job {
Show 30 fields pub job_id: String, pub job_name: String, pub script_name: String, pub script_sig_hash: String, pub enabled: bool, pub schedule_kind: ScheduleKind, pub cron_expr: Option<String>, pub timezone: Option<String>, pub run_once_at: Option<DateTime<Utc>>, pub run_once_claimed_at: Option<DateTime<Utc>>, pub run_once_claimed_by: Option<String>, pub run_once_completed_at: Option<DateTime<Utc>>, pub run_once_claim_expires_at: Option<DateTime<Utc>>, pub partition_hash: Option<i64>, pub claim_lease_id: Option<String>, pub claim_lease_until: Option<DateTime<Utc>>, pub pool: Option<String>, pub region: Option<String>, pub placement_json: Option<Value>, pub actor_json: Value, pub params_json: Value, pub concurrency: i32, pub timeout_ms: Option<i64>, pub retry_policy_json: Value, pub misfire_policy_json: Value, pub parent_limits_json: Option<Value>, pub next_run_at: Option<DateTime<Utc>>, pub current_revision: i32, pub updated_at: DateTime<Utc>, pub created_at: DateTime<Utc>,
}
Expand description

Scheduled work unit: binds a script name to a ScheduleKind and params.

Create with Job::new, set schedule fields, then persist with CoordinatorService::upsert_job (or HTTP upsert / RemoteCoordinatorClient). Typed defaults: crate::ScriptHandle.

Field groupPurpose
script_name / params_jsonWhat to run and with which args
schedule_kind + cron / run-once fieldsWhen it becomes due
actor_jsonIdentity restored by crate::ContextFactory at dispatch
pool / placementWorker pool targeting in split deployments

§Examples

use chronon_core::{Job, ScheduleKind};

let mut job = Job::new("nightly-cleanup", "nightly_cleanup");
job.schedule_kind = ScheduleKind::Cron;
job.cron_expr = Some("0 2 * * *".into());
job.timezone = Some("UTC".into());
job.params_json = serde_json::json!({ "retention_days": 7 });
assert!(job.enabled);
assert_eq!(job.script_name, "nightly_cleanup");

Runnable: cargo run -p uf-chronon --example script_macro --features mem.

Fields§

§job_id: String

Unique identifier (UUID).

§job_name: String

Human-readable name, unique in the deployment.

§script_name: String

Name of the script to execute.

§script_sig_hash: String

Signature hash at job creation (for validation).

§enabled: bool

Whether the job is enabled.

§schedule_kind: ScheduleKind

How the job is scheduled.

§cron_expr: Option<String>

Cron expression (when schedule_kind is Cron).

§timezone: Option<String>

Timezone for cron evaluation (e.g., “America/New_York”).

§run_once_at: Option<DateTime<Utc>>

One-time execution timestamp (when schedule_kind is RunOnce).

§run_once_claimed_at: Option<DateTime<Utc>>

When a coordinator claimed this run-once job for enqueue (distributed safety).

§run_once_claimed_by: Option<String>

Coordinator instance id that holds the claim (coordinator_instance_id).

§run_once_completed_at: Option<DateTime<Utc>>

Set after a scheduled run-once execution is successfully enqueued (persisted run row).

§run_once_claim_expires_at: Option<DateTime<Utc>>

Claim lease expiry; after this, another coordinator may reclaim if not completed.

§partition_hash: Option<i64>

Partition hash for coordinator sharding (distributed mode).

§claim_lease_id: Option<String>

Coordinator tick-claim holder id.

§claim_lease_until: Option<DateTime<Utc>>

Coordinator tick-claim lease expiry.

§pool: Option<String>

Execution pool (e.g., “global”, “region/us-west”).

§region: Option<String>

Target region for execution.

§placement_json: Option<Value>

Additional placement constraints as JSON.

§actor_json: Value

Serialized Actor for identity reconstruction.

§params_json: Value

Parameters to pass to the script.

§concurrency: i32

Maximum concurrent runs allowed.

§timeout_ms: Option<i64>

Execution timeout in milliseconds.

§retry_policy_json: Value

Retry policy JSON (RetryPolicy).

§misfire_policy_json: Value

Misfire policy JSON (MisfirePolicy).

§parent_limits_json: Option<Value>

Limits for parent/child runs.

§next_run_at: Option<DateTime<Utc>>

When the job should next run.

§current_revision: i32

Current revision number.

§updated_at: DateTime<Utc>

Last modification timestamp.

§created_at: DateTime<Utc>

Creation timestamp.

Implementations§

Source§

impl Job

Source

pub fn new(job_name: impl Into<String>, script_name: impl Into<String>) -> Self

Baseline job with generated job_id, enabled = true, and ScheduleKind::Cron (no expression yet).

Populate schedule_kind, cron / run-once fields, params_json, and actor_json before upsert. Prefer crate::ScriptHandle::job / crate::ScriptHandle::job_with_params when the script macro is in use.

§Examples
use chronon_core::Job;

let job = Job::new("demo", "noop");
assert!(!job.job_id.is_empty());
assert_eq!(job.job_name, "demo");
assert_eq!(job.script_name, "noop");
Source

pub fn retry_policy(&self) -> RetryPolicy

Decode RetryPolicy from Self::retry_policy_json, or default on null/invalid.

Source

pub fn misfire_policy(&self) -> MisfirePolicy

Decode MisfirePolicy from Self::misfire_policy_json, or default on null/invalid.

Source

pub fn set_retry_policy(&mut self, policy: &RetryPolicy)

Persist a typed retry policy into Self::retry_policy_json.

Source

pub fn set_misfire_policy(&mut self, policy: &MisfirePolicy)

Persist a typed misfire policy into Self::misfire_policy_json.

Trait Implementations§

Source§

impl Clone for Job

Source§

fn clone(&self) -> Job

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Job

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Job

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Job

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Job

§

impl RefUnwindSafe for Job

§

impl Send for Job

§

impl Sync for Job

§

impl Unpin for Job

§

impl UnsafeUnpin for Job

§

impl UnwindSafe for Job

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.