Message

Struct Message 

Source
pub struct Message {
    pub headers: MessageHeaders,
    pub properties: MessageProperties,
    pub body: Vec<u8>,
    pub content_type: String,
    pub content_encoding: String,
}
Expand description

Complete Celery message

Fields§

§headers: MessageHeaders

Message headers

§properties: MessageProperties

Message properties

§body: Vec<u8>

Serialized body (task arguments)

§content_type: String

Content type

§content_encoding: String

Content encoding

Implementations§

Source§

impl Message

Source

pub fn new(task: String, id: Uuid, body: Vec<u8>) -> Self

Create a new message with JSON body

Source

pub fn with_priority(self, priority: u8) -> Self

Set priority (0-9)

Source

pub fn with_parent(self, parent_id: Uuid) -> Self

Set parent task ID

Source

pub fn with_root(self, root_id: Uuid) -> Self

Set root task ID

Source

pub fn with_group(self, group: Uuid) -> Self

Set group ID

Source

pub fn with_eta(self, eta: DateTime<Utc>) -> Self

Set ETA (delayed execution)

Source

pub fn with_expires(self, expires: DateTime<Utc>) -> Self

Set expiration

Source

pub fn with_retries(self, retries: u32) -> Self

Set retry count

Source

pub fn with_correlation_id(self, correlation_id: String) -> Self

Set correlation ID (for RPC-style calls)

Source

pub fn with_reply_to(self, reply_to: String) -> Self

Set reply-to queue (for results)

Source

pub fn with_delivery_mode(self, mode: u8) -> Self

Set delivery mode (1 = non-persistent, 2 = persistent)

Source

pub fn validate(&self) -> Result<(), ValidationError>

Validate the complete message

Validates:

  • Headers (task name, retries, eta/expires)
  • Properties (delivery mode, priority)
  • Content type format
  • Body size
Source

pub fn validate_with_limit( &self, max_body_bytes: usize, ) -> Result<(), ValidationError>

Validate with custom body size limit

Source

pub fn has_eta(&self) -> bool

Check if the message has an ETA (delayed execution)

Source

pub fn has_expires(&self) -> bool

Check if the message has an expiration time

Source

pub fn has_group(&self) -> bool

Check if the message is part of a group

Source

pub fn has_parent(&self) -> bool

Check if the message has a parent task

Source

pub fn has_root(&self) -> bool

Check if the message has a root task

Source

pub fn is_persistent(&self) -> bool

Check if the message is persistent

Source

pub fn task_id(&self) -> Uuid

Get the task ID

Source

pub fn task_name(&self) -> &str

Get the task name

Source

pub fn content_type_str(&self) -> &str

Get the content type as a string slice

Source

pub fn content_encoding_str(&self) -> &str

Get the content encoding as a string slice

Source

pub fn body_size(&self) -> usize

Get the message body size in bytes

Source

pub fn has_empty_body(&self) -> bool

Check if the message body is empty

Source

pub fn retry_count(&self) -> u32

Get the retry count (0 if not set)

Source

pub fn priority(&self) -> Option<u8>

Get the priority (None if not set)

Source

pub fn has_correlation_id(&self) -> bool

Check if message has a correlation ID

Source

pub fn correlation_id(&self) -> Option<&str>

Get the correlation ID

Source

pub fn reply_to(&self) -> Option<&str>

Get the reply-to queue

Source

pub fn is_workflow_message(&self) -> bool

Check if this is a workflow message (has parent, root, or group)

Source

pub fn with_new_id(&self) -> Self

Clone the message with a new task ID

Source

pub fn to_builder(&self) -> MessageBuilder

Create a builder from this message (for modification)

Note: This creates a new builder with the message’s metadata. The body (args/kwargs) must be set separately on the builder.

Source

pub fn is_ready_for_execution(&self) -> bool

Check if the message is ready for immediate execution (not delayed)

Source

pub fn is_not_expired(&self) -> bool

Check if the message has not expired yet

Source

pub fn should_process(&self) -> bool

Check if the message should be processed (not expired and ready for execution)

Source

pub fn with_eta_delay(self, delay: Duration) -> Self

Set ETA to now + duration (builder pattern)

§Examples
use celers_protocol::Message;
use uuid::Uuid;
use chrono::Duration;

let msg = Message::new("task".to_string(), Uuid::new_v4(), vec![])
    .with_eta_delay(Duration::minutes(5));
assert!(msg.has_eta());
Source

pub fn with_expires_in(self, duration: Duration) -> Self

Set expiration to now + duration (builder pattern)

§Examples
use celers_protocol::Message;
use uuid::Uuid;
use chrono::Duration;

let msg = Message::new("task".to_string(), Uuid::new_v4(), vec![])
    .with_expires_in(Duration::hours(1));
assert!(msg.has_expires());
Source

pub fn time_until_eta(&self) -> Option<Duration>

Get the time remaining until ETA (None if no ETA or already past)

Source

pub fn time_until_expiration(&self) -> Option<Duration>

Get the time remaining until expiration (None if no expiration or already expired)

Source

pub fn increment_retry(&mut self) -> u32

Increment the retry count (returns new count)

Trait Implementations§

Source§

impl Clone for Message

Source§

fn clone(&self) -> Message

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Message

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Message

Source§

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 Extend<Message> for MessageBatch

Source§

fn extend<T: IntoIterator<Item = Message>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl Extend<Message> for MessagePriorityQueue

Source§

fn extend<T: IntoIterator<Item = Message>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl Extend<Message> for MultiLevelQueue

Source§

fn extend<T: IntoIterator<Item = Message>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl FromIterator<Message> for MessageBatch

Source§

fn from_iter<T: IntoIterator<Item = Message>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<Message> for MessagePriorityQueue

Source§

fn from_iter<T: IntoIterator<Item = Message>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl FromIterator<Message> for MultiLevelQueue

Source§

fn from_iter<T: IntoIterator<Item = Message>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl MessageExt for Message

Source§

fn validate_basic(&self) -> Result<(), ExtensionError>

Validate basic message structure
Source§

fn is_expired(&self) -> bool

Check if message is expired
Source§

fn is_scheduled(&self) -> bool

Check if message is scheduled for future execution
Source§

fn get_age_seconds(&self) -> Option<i64>

Get message age in seconds
Source§

impl PartialEq for Message

Source§

fn eq(&self, other: &Message) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Message

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Message

Source§

impl StructuralPartialEq for Message

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,