pub struct Job {
pub id: Uuid,
pub fingerprint: Option<String>,
pub unique_key: Option<String>,
pub queue: String,
pub job_data: Value,
pub status: String,
pub created_at: DateTime<Utc>,
pub run_at: Option<DateTime<Utc>>,
pub updated_at: Option<DateTime<Utc>>,
pub attempt: i32,
pub max_attempts: i32,
/* private fields */
}Expand description
Represents a job processed/processing by the queue.
Fields§
§id: UuidJob ID
fingerprint: Option<String>Fingerprint, made as a soft key for deduplication purposes or cancelling. Does not violate any database constraints.
unique_key: Option<String>Unique key - database constraint on unique_key jobs in pending and running states.
Repeated inserts with the same unique_key will be rejected by the database.
queue: StringName of the queue job belongs to.
job_data: ValuePayload - serde_json::Value,
status: StringCurrent status of the job in string form
created_at: DateTime<Utc>Timestamp when the job was created.
run_at: Option<DateTime<Utc>>Timestamp when the job is scheduled to run.
updated_at: Option<DateTime<Utc>>Timestamp when the job was last updated (for use by heartbeat)
attempt: i32Attempt count of the job
max_attempts: i32Maximum number of attempts for the job
Implementations§
Source§impl Job
impl Job
Sourcepub fn new<T: Serialize + DeserializeOwned>(
queue: &'static str,
job_data: T,
) -> Self
pub fn new<T: Serialize + DeserializeOwned>( queue: &'static str, job_data: T, ) -> Self
Create a new Job instance with the given queue name and job payload.
Sourcepub fn with_unique_key(self, unique_key: impl Into<String>) -> Self
pub fn with_unique_key(self, unique_key: impl Into<String>) -> Self
Builder method: sets Job::unique_key
Sourcepub fn with_run_at(self, run_at: DateTime<Utc>) -> Self
pub fn with_run_at(self, run_at: DateTime<Utc>) -> Self
Builder method: sets Job::run_at
Sourcepub fn with_max_attempts(self, max_attempts: i32) -> Self
pub fn with_max_attempts(self, max_attempts: i32) -> Self
Builder method: sets Job::max_attempts
Sourcepub fn with_fingerprint(self, fingerprint: impl Into<String>) -> Self
pub fn with_fingerprint(self, fingerprint: impl Into<String>) -> Self
Builder method: sets Job::fingerprint
Trait Implementations§
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> 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> 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 more