pub struct MessageWithPayloadEvent {
pub msg_id: i64,
pub queue_name: String,
pub namespace: String,
pub message: Value,
pub ready_at: DateTime<Utc>,
pub delay_seconds: i32,
}Expand description
Event emitted when a message is ready with full payload included (TAS-133)
This event is triggered for messages smaller than 7KB, where the full payload can fit within pg_notify’s ~8KB limit. This enables RabbitMQ-style direct processing without a separate database fetch operation.
For larger messages, MessageReadyEvent is used instead (signal-only).
§Benefits
- Reduced latency: No separate fetch required
- Unified consumer code: Same processing pattern as RabbitMQ
- Direct ack: Can delete message by msg_id after processing
§Examples
use tasker_pgmq::MessageWithPayloadEvent;
use chrono::Utc;
let event = MessageWithPayloadEvent {
msg_id: 42,
queue_name: "tasks_queue".to_string(),
namespace: "tasks".to_string(),
message: serde_json::json!({"task": "process", "data": [1, 2, 3]}),
ready_at: Utc::now(),
delay_seconds: 0,
};
// Process message directly without fetching
let task_data = &event.message["task"];
assert_eq!(task_data, "process");Fields§
§msg_id: i64ID of the message (for ack/delete after processing)
queue_name: StringQueue where the message is stored
namespace: StringExtracted namespace from the queue name
message: ValueThe full message payload (included because size < 7KB)
ready_at: DateTime<Utc>When the message became ready
delay_seconds: i32Delay in seconds before message became visible (if any)
Implementations§
Source§impl MessageWithPayloadEvent
impl MessageWithPayloadEvent
Sourcepub fn new<S: Into<String>>(
msg_id: i64,
queue_name: S,
namespace: S,
message: Value,
) -> Self
pub fn new<S: Into<String>>( msg_id: i64, queue_name: S, namespace: S, message: Value, ) -> Self
Create a new message with payload event
Sourcepub fn with_timestamp<S: Into<String>>(
msg_id: i64,
queue_name: S,
namespace: S,
message: Value,
ready_at: DateTime<Utc>,
) -> Self
pub fn with_timestamp<S: Into<String>>( msg_id: i64, queue_name: S, namespace: S, message: Value, ready_at: DateTime<Utc>, ) -> Self
Create with custom timestamp
Sourcepub fn with_delay_seconds(self, delay_seconds: i32) -> Self
pub fn with_delay_seconds(self, delay_seconds: i32) -> Self
Set delay seconds
Trait Implementations§
Source§impl Clone for MessageWithPayloadEvent
impl Clone for MessageWithPayloadEvent
Source§fn clone(&self) -> MessageWithPayloadEvent
fn clone(&self) -> MessageWithPayloadEvent
Returns a duplicate of the value. Read more
1.0.0 · 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 MessageWithPayloadEvent
impl Debug for MessageWithPayloadEvent
Source§impl<'de> Deserialize<'de> for MessageWithPayloadEvent
impl<'de> Deserialize<'de> for MessageWithPayloadEvent
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 PartialEq for MessageWithPayloadEvent
impl PartialEq for MessageWithPayloadEvent
Source§impl Serialize for MessageWithPayloadEvent
impl Serialize for MessageWithPayloadEvent
impl StructuralPartialEq for MessageWithPayloadEvent
Auto Trait Implementations§
impl Freeze for MessageWithPayloadEvent
impl RefUnwindSafe for MessageWithPayloadEvent
impl Send for MessageWithPayloadEvent
impl Sync for MessageWithPayloadEvent
impl Unpin for MessageWithPayloadEvent
impl UnwindSafe for MessageWithPayloadEvent
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> 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