cliquenet/metrics.rs
1use crate::x25519::PublicKey;
2
3/// Type that records metrics.
4pub trait Metrics: Send + Sync {
5 /// Set a peer gauge to the given value.
6 fn set(&self, key: &PublicKey, label: &str, val: usize);
7
8 /// Add to a peer counter the given value.
9 fn add(&self, key: &PublicKey, label: &str, val: usize);
10
11 /// Remove all peer metrics.
12 fn del(&self, key: &PublicKey);
13}
14
15/// A no-op [`Metrics`] implementation.
16pub(crate) struct NoMetrics;
17
18impl Metrics for NoMetrics {
19 fn set(&self, _: &PublicKey, _: &str, _: usize) {}
20 fn add(&self, _: &PublicKey, _: &str, _: usize) {}
21 fn del(&self, _: &PublicKey) {}
22}