diff options
Diffstat (limited to 'src/sync/health.rs')
| -rw-r--r-- | src/sync/health.rs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/sync/health.rs b/src/sync/health.rs index f9a5f3a..0ae7dee 100644 --- a/src/sync/health.rs +++ b/src/sync/health.rs | |||
| @@ -206,11 +206,7 @@ impl RelayHealthTracker { | |||
| 206 | health.next_retry_at = Some(now + backoff); | 206 | health.next_retry_at = Some(now + backoff); |
| 207 | 207 | ||
| 208 | if old_state != HealthState::Degraded { | 208 | if old_state != HealthState::Degraded { |
| 209 | tracing::warn!( | 209 | tracing::warn!("Relay {} degraded, backoff {:?}", relay_url, backoff); |
| 210 | "Relay {} degraded, backoff {:?}", | ||
| 211 | relay_url, | ||
| 212 | backoff | ||
| 213 | ); | ||
| 214 | } else { | 210 | } else { |
| 215 | tracing::debug!( | 211 | tracing::debug!( |
| 216 | "Relay {} failure #{}, backoff {:?}", | 212 | "Relay {} failure #{}, backoff {:?}", |
| @@ -308,12 +304,17 @@ impl RelayHealthTracker { | |||
| 308 | 304 | ||
| 309 | /// Get all tracked relay URLs | 305 | /// Get all tracked relay URLs |
| 310 | pub fn get_tracked_relays(&self) -> Vec<String> { | 306 | pub fn get_tracked_relays(&self) -> Vec<String> { |
| 311 | self.health.iter().map(|entry| entry.key().clone()).collect() | 307 | self.health |
| 308 | .iter() | ||
| 309 | .map(|entry| entry.key().clone()) | ||
| 310 | .collect() | ||
| 312 | } | 311 | } |
| 313 | 312 | ||
| 314 | /// Get a clone of the health info for a relay | 313 | /// Get a clone of the health info for a relay |
| 315 | pub fn get_health(&self, relay_url: &str) -> Option<RelayHealth> { | 314 | pub fn get_health(&self, relay_url: &str) -> Option<RelayHealth> { |
| 316 | self.health.get(relay_url).map(|entry| entry.value().clone()) | 315 | self.health |
| 316 | .get(relay_url) | ||
| 317 | .map(|entry| entry.value().clone()) | ||
| 317 | } | 318 | } |
| 318 | } | 319 | } |
| 319 | 320 | ||
| @@ -369,7 +370,7 @@ mod tests { | |||
| 369 | fn test_backoff_increases_exponentially() { | 370 | fn test_backoff_increases_exponentially() { |
| 370 | let base = DEFAULT_BASE_BACKOFF_SECS; // 5 seconds | 371 | let base = DEFAULT_BASE_BACKOFF_SECS; // 5 seconds |
| 371 | let max = 3600u64; | 372 | let max = 3600u64; |
| 372 | 373 | ||
| 373 | // failure 1: 5s (base * 2^0 = 5) | 374 | // failure 1: 5s (base * 2^0 = 5) |
| 374 | assert_eq!( | 375 | assert_eq!( |
| 375 | RelayHealthTracker::get_backoff_duration(1, base, max), | 376 | RelayHealthTracker::get_backoff_duration(1, base, max), |
| @@ -498,4 +499,4 @@ mod tests { | |||
| 498 | let health = tracker.get_health("wss://nonexistent.example.com"); | 499 | let health = tracker.get_health("wss://nonexistent.example.com"); |
| 499 | assert!(health.is_none()); | 500 | assert!(health.is_none()); |
| 500 | } | 501 | } |
| 501 | } \ No newline at end of file | 502 | } |