Skip to main content

spawn_session_sweeper

Function spawn_session_sweeper 

Source
pub fn spawn_session_sweeper(db: Db)
Expand description

Periodic maintenance loop — every 10 minutes, sweep:

  1. Expired sessions (auth::purge_expired_sessions) — removes rows from rustio_sessions where expires_at < NOW().
  2. Reset-token rows past their forensic-retention window (auth::recovery::purge_expired_reset_tokens — R1 commit #12) — removes rows from rustio_password_reset_tokens where expires_at < NOW() - INTERVAL '7 days'.

Failure isolation: the two sweeps run sequentially within each tick but each handles its own Result — a failure in one does NOT prevent the other from running, and neither prevents the next tick. The next tick happens unconditionally on the timer.

The 10-minute interval is kept from R0; reset-token sweeping piggy-backs on the existing tick rather than spawning a second timer loop.

(The function name is preserved for backwards compatibility — downstream projects already call spawn_session_sweeper directly. The expanded scope is documented above.)