pub struct TaskMessage {Show 18 fields
pub id: TaskId,
pub task_name: String,
pub queue: String,
pub payload: Value,
pub state: TaskState,
pub retries: u32,
pub max_retries: u32,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub eta: Option<DateTime<Utc>>,
pub headers: HashMap<String, String>,
pub parent_id: Option<TaskId>,
pub correlation_id: Option<String>,
pub group_id: Option<String>,
pub group_total: Option<u32>,
pub chord_callback: Option<Box<TaskMessage>>,
pub priority: Option<u8>,
pub dedup_key: Option<String>,
}Expand description
A task message that flows through the broker.
Fields§
§id: TaskIdUnique task identifier.
task_name: StringRegistered task name (e.g., “send_email”).
queue: StringTarget queue name.
payload: ValueSerialized task payload.
state: TaskStateCurrent task state.
retries: u32Current retry count.
max_retries: u32Maximum allowed retries.
created_at: DateTime<Utc>When the message was created.
updated_at: DateTime<Utc>When the message was last updated.
eta: Option<DateTime<Utc>>Optional ETA — earliest time the task should execute.
headers: HashMap<String, String>Arbitrary headers for middleware / tracing propagation.
parent_id: Option<TaskId>Parent task ID for workflow tracking.
correlation_id: Option<String>Correlation ID for tracing an entire workflow.
group_id: Option<String>Group ID this task belongs to.
group_total: Option<u32>Total number of tasks in the group.
chord_callback: Option<Box<TaskMessage>>Chord callback to enqueue when all group members complete.
priority: Option<u8>Task priority (0–9, higher = more urgent). Broker-specific support.
dedup_key: Option<String>Deduplication key. If set, brokers may skip enqueue when a duplicate exists.
Implementations§
Source§impl TaskMessage
impl TaskMessage
Sourcepub fn new(
task_name: impl Into<String>,
queue: impl Into<String>,
payload: Value,
) -> Self
pub fn new( task_name: impl Into<String>, queue: impl Into<String>, payload: Value, ) -> Self
Create a new task message with defaults.
Sourcepub fn with_max_retries(self, max_retries: u32) -> Self
pub fn with_max_retries(self, max_retries: u32) -> Self
Set max retries.
Sourcepub fn with_header(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_header( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add a header.
Sourcepub fn with_parent_id(self, parent_id: TaskId) -> Self
pub fn with_parent_id(self, parent_id: TaskId) -> Self
Set parent task ID for workflow tracking.
Sourcepub fn with_correlation_id(self, correlation_id: impl Into<String>) -> Self
pub fn with_correlation_id(self, correlation_id: impl Into<String>) -> Self
Set correlation ID for tracing an entire workflow.
Sourcepub fn with_group(self, group_id: impl Into<String>, group_total: u32) -> Self
pub fn with_group(self, group_id: impl Into<String>, group_total: u32) -> Self
Set group metadata.
Sourcepub fn with_chord_callback(self, callback: TaskMessage) -> Self
pub fn with_chord_callback(self, callback: TaskMessage) -> Self
Set chord callback.
Sourcepub fn with_priority(self, priority: u8) -> Self
pub fn with_priority(self, priority: u8) -> Self
Set task priority (clamped to 0–9, higher = more urgent).
Sourcepub fn with_dedup_key(self, key: impl Into<String>) -> Self
pub fn with_dedup_key(self, key: impl Into<String>) -> Self
Set an explicit deduplication key.
Sourcepub fn with_content_dedup(self) -> Self
pub fn with_content_dedup(self) -> Self
Auto-generate a dedup key by hashing task_name + payload.
Uses FNV-1a (64-bit) which is deterministic across Rust versions and platforms,
unlike DefaultHasher which may change between releases.
Trait Implementations§
Source§impl Clone for TaskMessage
impl Clone for TaskMessage
Source§fn clone(&self) -> TaskMessage
fn clone(&self) -> TaskMessage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more