pub struct MailQueue { /* private fields */ }Expand description
Mail queue with retry logic and priority support
Implementations§
Source§impl MailQueue
impl MailQueue
Sourcepub fn new_with_store(store: Arc<dyn QueueStore>) -> Self
pub fn new_with_store(store: Arc<dyn QueueStore>) -> Self
Create a new mail queue with persistent storage
Sourcepub fn new_with_priority_config(priority_config: PriorityConfig) -> Self
pub fn new_with_priority_config(priority_config: PriorityConfig) -> Self
Create a new mail queue with priority configuration
Sourcepub fn new_with_store_and_priority(
store: Arc<dyn QueueStore>,
priority_config: PriorityConfig,
) -> Self
pub fn new_with_store_and_priority( store: Arc<dyn QueueStore>, priority_config: PriorityConfig, ) -> Self
Create a new mail queue with storage and priority configuration
Sourcepub fn update_priority_config(&self, config: PriorityConfig)
pub fn update_priority_config(&self, config: PriorityConfig)
Update priority configuration
Sourcepub fn get_priority_config(&self) -> PriorityConfig
pub fn get_priority_config(&self) -> PriorityConfig
Get current priority configuration
Sourcepub async fn load_from_storage(&self) -> Result<()>
pub async fn load_from_storage(&self) -> Result<()>
Load all pending entries from storage on startup
Sourcepub async fn enqueue(&self, mail: Mail) -> Result<()>
pub async fn enqueue(&self, mail: Mail) -> Result<()>
Enqueue a mail for delivery (atomic operation with persistence)
Sourcepub async fn enqueue_with_priority(
&self,
mail: Mail,
priority: Priority,
) -> Result<()>
pub async fn enqueue_with_priority( &self, mail: Mail, priority: Priority, ) -> Result<()>
Enqueue a mail with explicit priority
Sourcepub fn get_ready_for_retry(&self, limit: usize) -> Vec<QueueEntry>
pub fn get_ready_for_retry(&self, limit: usize) -> Vec<QueueEntry>
Get next batch of mails ready for retry, ordered by priority
Sourcepub fn get_ready_for_retry_by_priority(
&self,
priority: Priority,
limit: usize,
) -> Vec<QueueEntry>
pub fn get_ready_for_retry_by_priority( &self, priority: Priority, limit: usize, ) -> Vec<QueueEntry>
Get mails ready for retry for a specific priority
Sourcepub async fn mark_failed(&self, mail_id: &MailId, error: String) -> Result<()>
pub async fn mark_failed(&self, mail_id: &MailId, error: String) -> Result<()>
Mark delivery attempt as failed (atomic operation with persistence)
Sourcepub async fn mark_delivered(&self, mail_id: &MailId) -> Result<()>
pub async fn mark_delivered(&self, mail_id: &MailId) -> Result<()>
Mark delivery as successful and remove from queue (atomic operation)
Sourcepub fn get_bounced(&self) -> Vec<QueueEntry>
pub fn get_bounced(&self) -> Vec<QueueEntry>
Get all bounced messages (exceeded retry limit) - legacy in-memory only
Sourcepub async fn list_dlq(&self) -> Result<Vec<QueueEntry>>
pub async fn list_dlq(&self) -> Result<Vec<QueueEntry>>
List all entries in dead letter queue
Sourcepub async fn remove_from_dlq(&self, mail_id: &MailId) -> Result<()>
pub async fn remove_from_dlq(&self, mail_id: &MailId) -> Result<()>
Remove a mail from dead letter queue
Sourcepub async fn retry_from_dlq(&self, mail_id: &MailId) -> Result<()>
pub async fn retry_from_dlq(&self, mail_id: &MailId) -> Result<()>
Retry a message from dead letter queue
Sourcepub async fn remove(&self, mail_id: &MailId) -> Result<Option<QueueEntry>>
pub async fn remove(&self, mail_id: &MailId) -> Result<Option<QueueEntry>>
Remove a mail from queue (atomic operation)
Sourcepub fn stats(&self) -> QueueStats
pub fn stats(&self) -> QueueStats
Get queue statistics
Sourcepub fn stats_for_priority(&self, priority: Priority) -> QueueStats
pub fn stats_for_priority(&self, priority: Priority) -> QueueStats
Get statistics for a specific priority level
Sourcepub fn stats_by_priority(&self) -> HashMap<Priority, QueueStats>
pub fn stats_by_priority(&self) -> HashMap<Priority, QueueStats>
Get statistics grouped by priority
Sourcepub fn list_all(&self) -> Vec<QueueEntry>
pub fn list_all(&self) -> Vec<QueueEntry>
Get all queue entries (for inspection)
Sourcepub fn list_by_priority(&self, priority: Priority) -> Vec<QueueEntry>
pub fn list_by_priority(&self, priority: Priority) -> Vec<QueueEntry>
Get queue entries for a specific priority
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MailQueue
impl !RefUnwindSafe for MailQueue
impl Send for MailQueue
impl Sync for MailQueue
impl Unpin for MailQueue
impl UnsafeUnpin for MailQueue
impl !UnwindSafe for MailQueue
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request