pub struct Job {Show 21 fields
pub dataset_id: String,
pub replay_of_job_id: Option<Uuid>,
pub idempotency_key: Option<String>,
pub id: Uuid,
pub queue: String,
pub job_type: String,
pub payload: Value,
pub run_at: DateTime<Utc>,
pub deadline_at: Option<DateTime<Utc>>,
pub timeout_seconds: Option<i64>,
pub recurring_interval_seconds: Option<i64>,
pub status: String,
pub priority: i32,
pub max_attempts: i32,
pub locked_at: Option<DateTime<Utc>>,
pub locked_by: Option<String>,
pub lock_expires_at: Option<DateTime<Utc>>,
pub dlq_reason_code: Option<String>,
pub dlq_at: Option<DateTime<Utc>>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}Expand description
Primary job entity representing a unit of work stored in a storage backend.
§Examples
use azums_core::Job;
let job = Job::new("email_send", serde_json::json!({"to": "user@example.com"}))
.queue("emails")
.priority(10)
.max_attempts(5);
assert_eq!(job.queue, "emails");
assert_eq!(job.priority, 10);
assert_eq!(job.max_attempts, 5);
assert_eq!(job.payload["to"], "user@example.com");Fields§
§dataset_id: String§replay_of_job_id: Option<Uuid>§idempotency_key: Option<String>§id: Uuid§queue: String§job_type: String§payload: Value§run_at: DateTime<Utc>§deadline_at: Option<DateTime<Utc>>§timeout_seconds: Option<i64>§recurring_interval_seconds: Option<i64>§status: String§priority: i32§max_attempts: i32§locked_at: Option<DateTime<Utc>>§locked_by: Option<String>§lock_expires_at: Option<DateTime<Utc>>§dlq_reason_code: Option<String>§dlq_at: Option<DateTime<Utc>>§created_at: DateTime<Utc>§updated_at: DateTime<Utc>Implementations§
Source§impl Job
impl Job
Sourcepub fn new(job_type: impl Into<String>, payload: Value) -> Self
pub fn new(job_type: impl Into<String>, payload: Value) -> Self
Creates a new Job with default queue "default", priority 0, and max attempts 25.
§Examples
use azums_core::Job;
let job = Job::new("greet", serde_json::json!({"name": "World"}));
assert_eq!(job.job_type, "greet");
assert_eq!(job.payload["name"], "World");Sourcepub fn priority(self, priority: i32) -> Self
pub fn priority(self, priority: i32) -> Self
Sets job execution priority (higher numbers are leased first).
Sourcepub fn max_attempts(self, max_attempts: i32) -> Self
pub fn max_attempts(self, max_attempts: i32) -> Self
Sets maximum retry attempts before moving job to Dead-Letter Queue (DLQ).
Sourcepub fn idempotency_key(self, idempotency_key: impl Into<String>) -> Self
pub fn idempotency_key(self, idempotency_key: impl Into<String>) -> Self
Sets an application-provided enqueue idempotency key.
Backends that support idempotent enqueue return the existing logical job ID when another enqueue uses the same key.
Sourcepub fn run_at(self, run_at: DateTime<Utc>) -> Self
pub fn run_at(self, run_at: DateTime<Utc>) -> Self
Sets scheduled execution timestamp (run_at).
Sourcepub fn deadline_at(self, deadline_at: DateTime<Utc>) -> Self
pub fn deadline_at(self, deadline_at: DateTime<Utc>) -> Self
Sets the latest timestamp at which this job may start execution.
If the backend clock is already past this value when workers try to lease the job, Azums
moves the job to DLQ with DEADLINE_EXCEEDED instead of executing it late.
Sourcepub fn timeout_seconds(self, timeout_seconds: i64) -> Self
pub fn timeout_seconds(self, timeout_seconds: i64) -> Self
Sets a per-attempt handler timeout in seconds.
Worker runtimes that execute handlers enforce this as a handler execution timeout and route timeout failures through normal retry/DLQ classification.
Sourcepub fn recurring_interval_seconds(self, interval_seconds: i64) -> Self
pub fn recurring_interval_seconds(self, interval_seconds: i64) -> Self
Sets fixed-interval recurring execution in seconds.
After a successful occurrence, Azums enqueues the next occurrence as a new logical job with
run_at = previous_run_at + recurring_interval_seconds.
Sourcepub fn payload_json(&self) -> &Value
pub fn payload_json(&self) -> &Value
Returns reference to job JSON payload.
Sourcepub fn lifecycle_state_at(
&self,
now: DateTime<Utc>,
failed_attempts: usize,
) -> Result<JobLifecycleState, Error>
pub fn lifecycle_state_at( &self, now: DateTime<Utc>, failed_attempts: usize, ) -> Result<JobLifecycleState, Error>
Derives the canonical lifecycle state from this persisted job and attempt history.
failed_attempts is the number of durable failed JobAttempt rows for this job.
Sourcepub fn payload_typed<T: DeserializeOwned>(&self) -> Result<T, Error>
pub fn payload_typed<T: DeserializeOwned>(&self) -> Result<T, Error>
Deserializes the JSON payload into a concrete type T.
§Examples
use azums_core::{Job, Error};
use serde::Deserialize;
#[derive(Deserialize, Debug, PartialEq)]
struct EmailPayload {
to: String,
}
let job = Job::new("email", serde_json::json!({"to": "a@b.com"}));
let payload: EmailPayload = job.payload_typed().unwrap();
assert_eq!(payload.to, "a@b.com");