Drain all entries whose retry time has arrived. Returns `(ready_for_retry, exceeded_max_retries)`.
(&mut self)
| 88 | /// Drain all entries whose retry time has arrived. |
| 89 | /// Returns `(ready_for_retry, exceeded_max_retries)`. |
| 90 | pub fn drain_due(&mut self) -> (Vec<RetryEntry>, Vec<RetryEntry>) { |
| 91 | let now = Instant::now(); |
| 92 | let mut ready = Vec::new(); |
| 93 | let mut exhausted = Vec::new(); |
| 94 | |
| 95 | // Drain from front (oldest first). |
| 96 | while self.queue.front().is_some_and(|e| e.next_retry_at <= now) { |
| 97 | let Some(entry) = self.queue.pop_front() else { |
| 98 | break; |
| 99 | }; |
| 100 | if entry.attempts >= self.max_retries { |
| 101 | warn!( |
| 102 | trigger = %entry.trigger_name, |
| 103 | collection = %entry.collection, |
| 104 | attempts = entry.attempts, |
| 105 | "trigger exhausted max retries → DLQ" |
| 106 | ); |
| 107 | exhausted.push(entry); |
| 108 | } else { |
| 109 | ready.push(entry); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | (ready, exhausted) |
| 114 | } |
| 115 | |
| 116 | /// Number of entries pending retry. |
| 117 | pub fn len(&self) -> usize { |