This commit is contained in:
2025-10-12 18:55:15 +02:00
parent 75910610e4
commit c312916687
2 changed files with 71 additions and 29 deletions

View File

@@ -538,26 +538,10 @@ impl ServiceCollector {
cache.get(service).cloned()
}
async fn should_update_description(&self, service: &str) -> bool {
// Simple time-based throttling - only run expensive descriptions every ~30 seconds
// Use a hash of the current time to spread out when different services get described
let now = std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap()
.as_secs();
let service_hash = service.as_bytes().iter().fold(0u64, |acc, &b| {
acc.wrapping_mul(31).wrapping_add(b as u64)
});
// Each service gets its description updated every 30 seconds, but staggered
let update_interval = 30; // seconds
let service_offset = service_hash % update_interval;
let should_update = (now + service_offset) % update_interval == 0;
should_update
async fn should_update_description(&self, _service: &str) -> bool {
// For now, always update descriptions since we have caching
// The cache will prevent redundant work
true
}
async fn get_service_description(&self, service: &str) -> Option<Vec<String>> {