(now time.Time)
| 224 | } |
| 225 | |
| 226 | func (q *queue) pruneLocked(now time.Time) { |
| 227 | if q.head >= len(q.items) { |
| 228 | q.items = nil |
| 229 | q.head = 0 |
| 230 | return |
| 231 | } |
| 232 | |
| 233 | windowSeconds := retentionSeconds.Load() |
| 234 | if windowSeconds <= 0 { |
| 235 | windowSeconds = defaultRetentionSeconds |
| 236 | } |
| 237 | cutoff := now.Add(-time.Duration(windowSeconds) * time.Second) |
| 238 | for q.head < len(q.items) && q.items[q.head].enqueuedAt.Before(cutoff) { |
| 239 | q.head++ |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | func (q *queue) maybeCompactLocked() { |
| 244 | if q.head == 0 { |