pub fn spawn_drain(
pool: Pool,
key: String,
mailer: Option<Arc<dyn Mailer>>,
mailer_from: String,
)Expand description
Drain in the background, off the request path.
Called right after enqueue so a notification normally goes out in the
same second it was queued, without the visitor waiting on Slack. It
drains everything due, not just what this request added, so a retry
queued earlier rides along.
The task stays up while retries are pending, sleeping until the next
one is due, so a backed-off delivery goes out without new traffic. It
ends once the queue has nothing pending: a retry never waits longer than
the last backoff step, and a delivery gives up after MAX_ATTEMPTS.