pub enum PgmqNotifyEvent {
QueueCreated(QueueCreatedEvent),
MessageReady(MessageReadyEvent),
MessageWithPayload(MessageWithPayloadEvent),
BatchReady(BatchReadyEvent),
}Expand description
Union of all possible PGMQ notification events
This enum represents all event types that can be emitted by PGMQ operations. Events are tagged for JSON serialization and can be pattern-matched for handling.
§Examples
use tasker_pgmq::{PgmqNotifyEvent, QueueCreatedEvent};
use chrono::Utc;
let event = PgmqNotifyEvent::QueueCreated(QueueCreatedEvent {
queue_name: "new_queue".to_string(),
namespace: "default".to_string(),
created_at: Utc::now(),
metadata: Default::default(),
});
match event {
PgmqNotifyEvent::QueueCreated(e) => {
println!("Queue created: {}", e.queue_name);
}
PgmqNotifyEvent::MessageReady(e) => {
println!("Message ready: {}", e.msg_id);
}
PgmqNotifyEvent::MessageWithPayload(e) => {
println!("Message with payload: {}", e.msg_id);
}
PgmqNotifyEvent::BatchReady(e) => {
println!("Batch ready: {} messages", e.message_count);
}
}Variants§
QueueCreated(QueueCreatedEvent)
Queue was created
MessageReady(MessageReadyEvent)
Message is ready for processing in a queue (signal only, requires fetch) Used for large messages (>= 7KB) that don’t fit in pg_notify payload
MessageWithPayload(MessageWithPayloadEvent)
Message with full payload included (TAS-133) Used for small messages (< 7KB) - enables direct processing without fetch
BatchReady(BatchReadyEvent)
Batch of messages are ready for processing in a queue
Implementations§
Source§impl PgmqNotifyEvent
impl PgmqNotifyEvent
Sourcepub fn queue_name(&self) -> &str
pub fn queue_name(&self) -> &str
Get the queue name for any event type
Sourcepub fn metadata(&self) -> &HashMap<String, String>
pub fn metadata(&self) -> &HashMap<String, String>
Get metadata for any event type
Note: MessageWithPayload events don’t have metadata, returns empty HashMap
Sourcepub fn matches_namespace(&self, namespace: &str) -> bool
pub fn matches_namespace(&self, namespace: &str) -> bool
Check if event matches a specific namespace
Sourcepub fn event_type(&self) -> &'static str
pub fn event_type(&self) -> &'static str
Get the event type as a string
Sourcepub fn msg_id(&self) -> Option<i64>
pub fn msg_id(&self) -> Option<i64>
Get the message ID if this event is message-related
Returns Some(msg_id) for MessageReady and MessageWithPayload events,
None for queue creation and batch events.
Sourcepub fn has_payload(&self) -> bool
pub fn has_payload(&self) -> bool
Check if this event includes the full message payload (TAS-133)
Returns true for MessageWithPayload events where the message
can be processed directly without a separate fetch.
Trait Implementations§
Source§impl Clone for PgmqNotifyEvent
impl Clone for PgmqNotifyEvent
Source§fn clone(&self) -> PgmqNotifyEvent
fn clone(&self) -> PgmqNotifyEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PgmqNotifyEvent
impl Debug for PgmqNotifyEvent
Source§impl<'de> Deserialize<'de> for PgmqNotifyEvent
impl<'de> Deserialize<'de> for PgmqNotifyEvent
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>,
Source§impl PartialEq for PgmqNotifyEvent
impl PartialEq for PgmqNotifyEvent
Source§impl Serialize for PgmqNotifyEvent
impl Serialize for PgmqNotifyEvent
impl StructuralPartialEq for PgmqNotifyEvent
Auto Trait Implementations§
impl Freeze for PgmqNotifyEvent
impl RefUnwindSafe for PgmqNotifyEvent
impl Send for PgmqNotifyEvent
impl Sync for PgmqNotifyEvent
impl Unpin for PgmqNotifyEvent
impl UnwindSafe for PgmqNotifyEvent
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
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>
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>
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