pub struct Task<D: Clone> {
pub task_id: TaskId,
pub payload: D,
pub status: TaskStatus,
pub queued_at: SystemTime,
pub started_at: Option<SystemTime>,
pub finished_at: Option<SystemTime>,
pub retries: u32,
pub error_msg: Option<String>,
}Expand description
A Task struct represents a single unit of work that will be processed
by a worker. It contains payload of type D, which is used by the worker
during processing. The Task struct also includes fields for managing
the task’s lifecycle, including the task’s UUID, the start and
finish times, the number of retries, and any error messages.
Fields§
§task_id: TaskId§payload: D§status: TaskStatus§queued_at: SystemTime§started_at: Option<SystemTime>§finished_at: Option<SystemTime>§retries: u32§error_msg: Option<String>Implementations§
Source§impl<D: Clone> Task<D>
impl<D: Clone> Task<D>
pub fn new(payload: D) -> Self
pub fn set_in_progress(&mut self)
pub fn set_succeed(&mut self)
pub fn set_retry(&mut self, err_msg: &str)
pub fn set_dlq(&mut self, err_msg: &str)
pub fn set_status(&mut self, new_status: TaskStatus)
pub fn get_payload(&self) -> &D
Trait Implementations§
Source§impl<'de, D> Deserialize<'de> for Task<D>where
D: Deserialize<'de> + Clone,
impl<'de, D> Deserialize<'de> for Task<D>where
D: Deserialize<'de> + Clone,
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
Auto Trait Implementations§
impl<D> Freeze for Task<D>where
D: Freeze,
impl<D> RefUnwindSafe for Task<D>where
D: RefUnwindSafe,
impl<D> Send for Task<D>where
D: Send,
impl<D> Sync for Task<D>where
D: Sync,
impl<D> Unpin for Task<D>where
D: Unpin,
impl<D> UnsafeUnpin for Task<D>where
D: UnsafeUnpin,
impl<D> UnwindSafe for Task<D>where
D: UnwindSafe,
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