pub struct Task {
pub id: String,
pub task_type: String,
pub queue: String,
pub payload: Vec<u8>,
pub options: TaskOptions,
pub status: TaskStatus,
pub created_at: i64,
pub enqueued_at: Option<i64>,
pub processed_at: Option<i64>,
pub retry_cnt: u32,
pub last_error: Option<String>,
}Expand description
Task struct
Fields§
§id: StringTask ID (UUID)
task_type: StringTask type (for routing to different handlers)
queue: StringQueue name
payload: Vec<u8>Task payload (serialized data)
options: TaskOptionsTask options
status: TaskStatusTask status
created_at: i64Creation time (Unix timestamp, seconds)
enqueued_at: Option<i64>Enqueue time (Unix timestamp, seconds)
processed_at: Option<i64>Processing start time (Unix timestamp, seconds)
retry_cnt: u32Current retry count
last_error: Option<String>Last error message
Implementations§
Source§impl Task
impl Task
Sourcepub fn builder(task_type: impl Into<String>) -> TaskBuilder
pub fn builder(task_type: impl Into<String>) -> TaskBuilder
Create a new task builder
Sourcepub fn description(&self) -> String
pub fn description(&self) -> String
Get task description
Sourcepub fn retry_delay(&self) -> Option<Duration>
pub fn retry_delay(&self) -> Option<Duration>
Calculate the next retry delay (exponential backoff)
Sourcepub fn payload_json<'a, T>(&'a self) -> Result<T>where
T: Deserialize<'a>,
pub fn payload_json<'a, T>(&'a self) -> Result<T>where
T: Deserialize<'a>,
Deserialize payload as JSON
§Example
use rediq::Task;
use serde::Deserialize;
#[derive(Deserialize)]
struct EmailData {
to: String,
subject: String,
}
let data: EmailData = task.payload_json()?;Sourcepub fn payload_msgpack<'a, T>(&'a self) -> Result<T>where
T: Deserialize<'a>,
pub fn payload_msgpack<'a, T>(&'a self) -> Result<T>where
T: Deserialize<'a>,
Deserialize payload as MessagePack
§Example
use rediq::Task;
use serde::Deserialize;
#[derive(Deserialize)]
struct EmailData {
to: String,
subject: String,
}
let data: EmailData = task.payload_msgpack()?;Trait Implementations§
Source§impl<'de> Deserialize<'de> for Task
impl<'de> Deserialize<'de> for Task
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
Source§impl TaskProgressExt for Task
impl TaskProgressExt for Task
Source§fn progress(&self) -> Option<ProgressContext>
fn progress(&self) -> Option<ProgressContext>
Get the progress reporter for this task Read more
Source§fn progress_guard(&self) -> Option<ProgressGuard>
fn progress_guard(&self) -> Option<ProgressGuard>
Create a progress guard for automatic cleanup Read more
Source§fn has_progress(&self) -> bool
fn has_progress(&self) -> bool
Check if progress reporting is available
Auto Trait Implementations§
impl Freeze for Task
impl RefUnwindSafe for Task
impl Send for Task
impl Sync for Task
impl Unpin for Task
impl UnsafeUnpin for Task
impl UnwindSafe for Task
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<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> 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>
Converts
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>
Converts
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