mirror of
https://github.com/telemt/telemt.git
synced 2026-05-01 17:34:09 +03:00
Hot-path Cleanup and Timeout Invariants
This commit is contained in:
@@ -74,16 +74,24 @@ impl BeobachtenStore {
|
||||
}
|
||||
|
||||
let now = Instant::now();
|
||||
let mut guard = self.inner.lock();
|
||||
Self::cleanup(&mut guard, now, ttl);
|
||||
guard.last_cleanup = Some(now);
|
||||
let entries = {
|
||||
let mut guard = self.inner.lock();
|
||||
Self::cleanup(&mut guard, now, ttl);
|
||||
guard.last_cleanup = Some(now);
|
||||
|
||||
guard
|
||||
.entries
|
||||
.iter()
|
||||
.map(|((class, ip), entry)| (class.clone(), *ip, entry.tries))
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
|
||||
let mut grouped = BTreeMap::<String, Vec<(IpAddr, u64)>>::new();
|
||||
for ((class, ip), entry) in &guard.entries {
|
||||
for (class, ip, tries) in entries {
|
||||
grouped
|
||||
.entry(class.clone())
|
||||
.entry(class)
|
||||
.or_default()
|
||||
.push((*ip, entry.tries));
|
||||
.push((ip, tries));
|
||||
}
|
||||
|
||||
if grouped.is_empty() {
|
||||
|
||||
Reference in New Issue
Block a user