pub struct DistributedTask {
pub id: Uuid,
pub name: String,
pub priority: TaskPriority,
pub status: TaskStatus,
pub payload: String,
pub enqueued_at: i64,
pub max_retries: u32,
pub retry_count: u32,
pub deadline: Option<i64>,
/* private fields */
}Expand description
A distributed task that can be queued and assigned to workers.
Fields§
§id: UuidUnique task identifier
name: StringTask name/description
priority: TaskPriorityTask priority
status: TaskStatusCurrent status
payload: StringPayload data (serialized task parameters)
enqueued_at: i64Unix timestamp when the task was enqueued
max_retries: u32Maximum number of retry attempts
retry_count: u32Current retry count
deadline: Option<i64>Optional deadline (unix timestamp)
Implementations§
Source§impl DistributedTask
impl DistributedTask
Sourcepub fn new(name: &str, priority: TaskPriority, payload: &str) -> Self
pub fn new(name: &str, priority: TaskPriority, payload: &str) -> Self
Creates a new distributed task.
Sourcepub fn with_max_retries(self, retries: u32) -> Self
pub fn with_max_retries(self, retries: u32) -> Self
Sets the maximum retry count.
Sourcepub fn with_deadline(self, deadline: i64) -> Self
pub fn with_deadline(self, deadline: i64) -> Self
Sets a deadline for the task.
Sourcepub fn is_past_deadline(&self, now: i64) -> bool
pub fn is_past_deadline(&self, now: i64) -> bool
Returns true if the task has passed its deadline.
Sourcepub fn mark_running(&mut self)
pub fn mark_running(&mut self)
Marks the task as running.
Sourcepub fn mark_completed(&mut self)
pub fn mark_completed(&mut self)
Marks the task as completed.
Sourcepub fn mark_failed(&mut self)
pub fn mark_failed(&mut self)
Marks the task as failed.
Trait Implementations§
Source§impl Clone for DistributedTask
impl Clone for DistributedTask
Source§fn clone(&self) -> DistributedTask
fn clone(&self) -> DistributedTask
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DistributedTask
impl Debug for DistributedTask
Source§impl<'de> Deserialize<'de> for DistributedTask
impl<'de> Deserialize<'de> for DistributedTask
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for DistributedTask
Source§impl Ord for DistributedTask
impl Ord for DistributedTask
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for DistributedTask
impl PartialEq for DistributedTask
Source§impl PartialOrd for DistributedTask
impl PartialOrd for DistributedTask
Auto Trait Implementations§
impl Freeze for DistributedTask
impl RefUnwindSafe for DistributedTask
impl Send for DistributedTask
impl Sync for DistributedTask
impl Unpin for DistributedTask
impl UnsafeUnpin for DistributedTask
impl UnwindSafe for DistributedTask
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request