MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / enforcement_loop

Function enforcement_loop

nodedb/src/engine/bitemporal/enforcement.rs:58–85  ·  view source on GitHub ↗
(
    state: Arc<SharedState>,
    registry: Arc<BitemporalRetentionRegistry>,
    mut shutdown: watch::Receiver<bool>,
    tick: Duration,
)

Source from the content-addressed store, hash-verified

56}
57
58async 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
87async fn run_one(state: &Arc<SharedState>, entry: &Entry) {
88 let audit_ms = entry.retention.audit_retain_ms;

Callers 1

Calls 3

run_oneFunction · 0.70
snapshotMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected