pub struct BatchReadyEvent {
pub msg_ids: Vec<i64>,
pub queue_name: String,
pub namespace: String,
pub message_count: i64,
pub ready_at: DateTime<Utc>,
pub metadata: HashMap<String, String>,
pub delay_seconds: i32,
}Expand description
Event emitted when a batch of messages is ready for processing
This event is triggered when multiple messages are enqueued in PGMQ via batch operations and become available for processing. It provides the message IDs and queue information needed to claim and process the batch.
§Examples
use tasker_pgmq::BatchReadyEvent;
use chrono::Utc;
use std::collections::HashMap;
let event = BatchReadyEvent {
msg_ids: vec![1, 2, 3],
queue_name: "tasks_queue".to_string(),
namespace: "tasks".to_string(),
message_count: 3,
ready_at: Utc::now(),
metadata: HashMap::new(),
delay_seconds: 0,
};
assert_eq!(event.msg_ids, vec![1, 2, 3]);
assert_eq!(event.message_count, 3);Fields§
§msg_ids: Vec<i64>IDs of the messages in the batch
queue_name: StringQueue where the messages are available
namespace: StringExtracted namespace from the queue name
message_count: i64Number of messages in the batch
ready_at: DateTime<Utc>When the batch became ready
metadata: HashMap<String, String>Optional message metadata (limited by payload size)
delay_seconds: i32Delay in seconds before messages become visible
Implementations§
Source§impl BatchReadyEvent
impl BatchReadyEvent
Sourcepub fn new<S: Into<String>>(
msg_ids: Vec<i64>,
queue_name: S,
namespace: S,
) -> Self
pub fn new<S: Into<String>>( msg_ids: Vec<i64>, queue_name: S, namespace: S, ) -> Self
Create a new batch ready event
Sourcepub fn with_timestamp<S: Into<String>>(
msg_ids: Vec<i64>,
queue_name: S,
namespace: S,
ready_at: DateTime<Utc>,
) -> Self
pub fn with_timestamp<S: Into<String>>( msg_ids: Vec<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_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 BatchReadyEvent
impl Clone for BatchReadyEvent
Source§fn clone(&self) -> BatchReadyEvent
fn clone(&self) -> BatchReadyEvent
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 BatchReadyEvent
impl Debug for BatchReadyEvent
Source§impl<'de> Deserialize<'de> for BatchReadyEvent
impl<'de> Deserialize<'de> for BatchReadyEvent
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 BatchReadyEvent
impl PartialEq for BatchReadyEvent
Source§impl Serialize for BatchReadyEvent
impl Serialize for BatchReadyEvent
impl StructuralPartialEq for BatchReadyEvent
Auto Trait Implementations§
impl Freeze for BatchReadyEvent
impl RefUnwindSafe for BatchReadyEvent
impl Send for BatchReadyEvent
impl Sync for BatchReadyEvent
impl Unpin for BatchReadyEvent
impl UnwindSafe for BatchReadyEvent
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