upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/metrics/bandwidth.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2025-12-11 16:53:03 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2025-12-11 16:53:03 +0000
commit2a9160836bb87fdea3ae891563b0169c68d1c2ab (patch)
tree583c890687beaf7f380fc0be131bdf17485f06fa /src/metrics/bandwidth.rs
parent52489d3b1a7d79e164b4cc901b53fd06c05ce1b1 (diff)
fix: resolve all fmt and clippy warnings
Main lib (src/): - Add #[allow(dead_code)] for build_info field (stored to prevent Prometheus unregistration) - Add #[allow(dead_code)] for first_seen field (reserved for future rate limiting) - Replace .or_insert_with(RelaySyncNeeds::default) with .or_default() - Replace manual div_ceil implementations with .div_ceil(100) Test code (tests/): - Replace .expect(&format!(...)) with .unwrap_or_else(|_| panic!(...)) - Remove needless borrows in fetch_metrics() calls - Add #[allow(dead_code)] and #[allow(unused_imports)] to test helpers module grasp-audit: - Apply cargo fmt to fix formatting
Diffstat (limited to 'src/metrics/bandwidth.rs')
-rw-r--r--src/metrics/bandwidth.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/metrics/bandwidth.rs b/src/metrics/bandwidth.rs
index d2c53e8..d51af12 100644
--- a/src/metrics/bandwidth.rs
+++ b/src/metrics/bandwidth.rs
@@ -80,7 +80,9 @@ impl BandwidthTracker {
80 &["repo"], 80 &["repo"],
81 ) 81 )
82 .unwrap(); 82 .unwrap();
83 registry.register(Box::new(top_repos_gauge.clone())).unwrap(); 83 registry
84 .register(Box::new(top_repos_gauge.clone()))
85 .unwrap();
84 86
85 Self { 87 Self {
86 all_repos: DashMap::new(), 88 all_repos: DashMap::new(),
@@ -120,7 +122,12 @@ impl BandwidthTracker {
120 // Try to update the timestamp atomically to prevent concurrent refreshes 122 // Try to update the timestamp atomically to prevent concurrent refreshes
121 if self 123 if self
122 .last_refresh_nanos 124 .last_refresh_nanos
123 .compare_exchange(last_refresh, elapsed_nanos, Ordering::SeqCst, Ordering::Relaxed) 125 .compare_exchange(
126 last_refresh,
127 elapsed_nanos,
128 Ordering::SeqCst,
129 Ordering::Relaxed,
130 )
124 .is_ok() 131 .is_ok()
125 { 132 {
126 self.refresh_top_n(); 133 self.refresh_top_n();
@@ -298,4 +305,4 @@ mod tests {
298 // Refresh should not panic on empty data 305 // Refresh should not panic on empty data
299 tracker.refresh_top_n(); 306 tracker.refresh_top_n();
300 } 307 }
301} \ No newline at end of file 308}