(
state: Arc<SharedState>,
registry: Arc<BitemporalRetentionRegistry>,
mut shutdown: watch::Receiver<bool>,
tick: Duration,
)
| 56 | } |
| 57 | |
| 58 | async fn enforcement_loop( |
| 59 | state: Arc<SharedState>, |
| 60 | registry: Arc<BitemporalRetentionRegistry>, |
| 61 | mut shutdown: watch::Receiver<bool>, |
| 62 | tick: Duration, |
| 63 | ) { |
| 64 | tokio::time::sleep(Duration::from_secs(STARTUP_DELAY_SECS)).await; |
| 65 | |
| 66 | loop { |
| 67 | tokio::select! { |
| 68 | _ = tokio::time::sleep(tick) => {} |
| 69 | _ = shutdown.changed() => { |
| 70 | if *shutdown.borrow() { |
| 71 | info!("bitemporal retention loop shutting down"); |
| 72 | return; |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | let entries = registry.snapshot(); |
| 78 | if entries.is_empty() { |
| 79 | continue; |
| 80 | } |
| 81 | for entry in entries { |
| 82 | run_one(&state, &entry).await; |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | async fn run_one(state: &Arc<SharedState>, entry: &Entry) { |
| 88 | let audit_ms = entry.retention.audit_retain_ms; |
no test coverage detected