pub struct MessageReadyEvent {
pub msg_id: i64,
pub queue_name: String,
pub namespace: String,
pub ready_at: DateTime<Utc>,
pub metadata: HashMap<String, String>,
pub visibility_timeout_seconds: Option<i32>,
}Expand description
Event emitted when a message is ready for processing
This event is triggered when a message is enqueued in PGMQ and becomes available for processing by workers. It provides the message ID and queue information needed to claim and process the message.
§Examples
use tasker_pgmq::MessageReadyEvent;
use chrono::Utc;
use std::collections::HashMap;
let event = MessageReadyEvent {
msg_id: 42,
queue_name: "tasks_queue".to_string(),
namespace: "tasks".to_string(),
ready_at: Utc::now(),
metadata: HashMap::new(),
visibility_timeout_seconds: Some(30),
};
assert_eq!(event.msg_id, 42);
assert_eq!(event.queue_name, "tasks_queue");
assert_eq!(event.namespace, "tasks");Fields§
§msg_id: i64ID of the message that’s ready
queue_name: StringQueue where the message is available
namespace: StringExtracted namespace from the queue name
ready_at: DateTime<Utc>When the message became ready
metadata: HashMap<String, String>Optional message metadata (limited by payload size)
visibility_timeout_seconds: Option<i32>Visibility timeout if applicable
Implementations§
Source§impl MessageReadyEvent
impl MessageReadyEvent
Sourcepub fn new<S: Into<String>>(msg_id: i64, queue_name: S, namespace: S) -> Self
pub fn new<S: Into<String>>(msg_id: i64, queue_name: S, namespace: S) -> Self
Create a new message ready event
Sourcepub fn with_timestamp<S: Into<String>>(
msg_id: i64,
queue_name: S,
namespace: S,
ready_at: DateTime<Utc>,
) -> Self
pub fn with_timestamp<S: Into<String>>( msg_id: i64, queue_name: S, namespace: S, ready_at: DateTime<Utc>, ) -> Self
Create with custom timestamp
Sourcepub fn with_metadata(self, metadata: HashMap<String, String>) -> Self
pub fn with_metadata(self, metadata: HashMap<String, String>) -> Self
Add metadata to the event
Sourcepub fn add_metadata<K: Into<String>, V: Into<String>>(
self,
key: K,
value: V,
) -> Self
pub fn add_metadata<K: Into<String>, V: Into<String>>( self, key: K, value: V, ) -> Self
Add a single metadata entry
Sourcepub fn with_visibility_timeout(self, timeout_seconds: i32) -> Self
pub fn with_visibility_timeout(self, timeout_seconds: i32) -> Self
Set visibility timeout
Trait Implementations§
Source§impl Clone for MessageReadyEvent
impl Clone for MessageReadyEvent
Source§fn clone(&self) -> MessageReadyEvent
fn clone(&self) -> MessageReadyEvent
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 MessageReadyEvent
impl Debug for MessageReadyEvent
Source§impl<'de> Deserialize<'de> for MessageReadyEvent
impl<'de> Deserialize<'de> for MessageReadyEvent
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 MessageReadyEvent
impl PartialEq for MessageReadyEvent
Source§impl Serialize for MessageReadyEvent
impl Serialize for MessageReadyEvent
impl StructuralPartialEq for MessageReadyEvent
Auto Trait Implementations§
impl Freeze for MessageReadyEvent
impl RefUnwindSafe for MessageReadyEvent
impl Send for MessageReadyEvent
impl Sync for MessageReadyEvent
impl Unpin for MessageReadyEvent
impl UnwindSafe for MessageReadyEvent
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