engine: persist the incident ring (LOGSEARCH) across restarts via a periodic + on-shutdown snapshot event, mirroring stat-counter persistence
All checks were successful
CI / check (push) Successful in 3m44s

This commit is contained in:
Jean Chevronnet 2026-07-19 00:46:14 +00:00
parent 754c5d9e95
commit a10662bbc6
No known key found for this signature in database
9 changed files with 102 additions and 6 deletions

View file

@ -456,6 +456,20 @@ impl Network {
self.stats = stats;
}
// Restore the recent-incident ring (and its id counter) from a persisted
// snapshot at startup, so OperServ LOGSEARCH survives a restart.
pub fn seed_incidents(&mut self, data: (u64, Vec<(String, u64, String)>)) {
let (seq, incidents) = data;
self.incident_seq = seq;
self.incidents = incidents.into_iter().map(|(id, ts, summary)| Incident { id, ts, summary }).collect();
}
// Snapshot the live incident ring (id counter, incidents oldest-first) for
// persistence.
pub fn incidents_snapshot(&self) -> (u64, Vec<(String, u64, String)>) {
(self.incident_seq, self.incidents.iter().map(|i| (i.id.clone(), i.ts, i.summary.clone())).collect())
}
// BOTSTATS view: (total lines, top talkers by count, descending).
pub fn channel_activity(&self, channel: &str) -> Option<(u64, Vec<(String, u64)>)> {
let a = self.chan_activity.get(&lc(channel))?;