Testing
This commit is contained in:
@@ -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>> {
|
||||
|
||||
Reference in New Issue
Block a user