mirror of
https://git.asonix.dog/asonix/relay.git
synced 2024-11-21 17:11:05 +00:00
clippy, replace indexmap with btreemap
This commit is contained in:
parent
e2f3727d07
commit
d7a720b6c4
3 changed files with 6 additions and 10 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -301,7 +301,6 @@ dependencies = [
|
|||
"dotenv",
|
||||
"futures-util",
|
||||
"http-signature-normalization-actix",
|
||||
"indexmap",
|
||||
"lru",
|
||||
"metrics",
|
||||
"metrics-util",
|
||||
|
|
|
@ -39,7 +39,6 @@ console-subscriber = { version = "0.1", optional = true }
|
|||
dashmap = "5.1.0"
|
||||
dotenv = "0.15.0"
|
||||
futures-util = "0.3.17"
|
||||
indexmap = "1.9.2"
|
||||
lru = "0.8.0"
|
||||
metrics = "0.20.1"
|
||||
metrics-util = "0.14.0"
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use indexmap::IndexMap;
|
||||
use metrics::{Key, Recorder, SetRecorderError};
|
||||
use metrics_util::{
|
||||
registry::{AtomicStorage, GenerationalStorage, Recency, Registry},
|
||||
|
@ -16,6 +15,8 @@ const MINUTES: u64 = 60 * SECONDS;
|
|||
const HOURS: u64 = 60 * MINUTES;
|
||||
const DAYS: u64 = 24 * HOURS;
|
||||
|
||||
type DistributionMap = BTreeMap<Vec<(String, String)>, Summary>;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct MemoryCollector {
|
||||
inner: Arc<Inner>,
|
||||
|
@ -23,7 +24,7 @@ pub struct MemoryCollector {
|
|||
|
||||
struct Inner {
|
||||
descriptions: RwLock<HashMap<String, metrics::SharedString>>,
|
||||
distributions: RwLock<HashMap<String, IndexMap<Vec<(String, String)>, Summary>>>,
|
||||
distributions: RwLock<HashMap<String, DistributionMap>>,
|
||||
recency: Recency<Key>,
|
||||
registry: Registry<Key, GenerationalStorage<AtomicStorage>>,
|
||||
}
|
||||
|
@ -289,7 +290,7 @@ impl Inner {
|
|||
}
|
||||
|
||||
let mut d = self.distributions.write().unwrap();
|
||||
let outer_entry = d.entry(name.clone()).or_insert_with(IndexMap::new);
|
||||
let outer_entry = d.entry(name.clone()).or_insert_with(BTreeMap::new);
|
||||
|
||||
let entry = outer_entry
|
||||
.entry(labels)
|
||||
|
@ -303,8 +304,7 @@ impl Inner {
|
|||
}
|
||||
|
||||
let d = self.distributions.read().unwrap().clone();
|
||||
let h = d
|
||||
.into_iter()
|
||||
d.into_iter()
|
||||
.map(|(key, value)| {
|
||||
(
|
||||
key,
|
||||
|
@ -320,9 +320,7 @@ impl Inner {
|
|||
.collect(),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
h
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn snapshot(&self) -> Snapshot {
|
||||
|
|
Loading…
Reference in a new issue