clippy, replace indexmap with btreemap

This commit is contained in:
asonix 2022-11-23 11:25:13 -06:00
parent e2f3727d07
commit d7a720b6c4
3 changed files with 6 additions and 10 deletions

1
Cargo.lock generated
View file

@ -301,7 +301,6 @@ dependencies = [
"dotenv",
"futures-util",
"http-signature-normalization-actix",
"indexmap",
"lru",
"metrics",
"metrics-util",

View file

@ -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"

View file

@ -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 {