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", "dotenv",
"futures-util", "futures-util",
"http-signature-normalization-actix", "http-signature-normalization-actix",
"indexmap",
"lru", "lru",
"metrics", "metrics",
"metrics-util", "metrics-util",

View file

@ -39,7 +39,6 @@ console-subscriber = { version = "0.1", optional = true }
dashmap = "5.1.0" dashmap = "5.1.0"
dotenv = "0.15.0" dotenv = "0.15.0"
futures-util = "0.3.17" futures-util = "0.3.17"
indexmap = "1.9.2"
lru = "0.8.0" lru = "0.8.0"
metrics = "0.20.1" metrics = "0.20.1"
metrics-util = "0.14.0" metrics-util = "0.14.0"

View file

@ -1,4 +1,3 @@
use indexmap::IndexMap;
use metrics::{Key, Recorder, SetRecorderError}; use metrics::{Key, Recorder, SetRecorderError};
use metrics_util::{ use metrics_util::{
registry::{AtomicStorage, GenerationalStorage, Recency, Registry}, registry::{AtomicStorage, GenerationalStorage, Recency, Registry},
@ -16,6 +15,8 @@ const MINUTES: u64 = 60 * SECONDS;
const HOURS: u64 = 60 * MINUTES; const HOURS: u64 = 60 * MINUTES;
const DAYS: u64 = 24 * HOURS; const DAYS: u64 = 24 * HOURS;
type DistributionMap = BTreeMap<Vec<(String, String)>, Summary>;
#[derive(Clone)] #[derive(Clone)]
pub struct MemoryCollector { pub struct MemoryCollector {
inner: Arc<Inner>, inner: Arc<Inner>,
@ -23,7 +24,7 @@ pub struct MemoryCollector {
struct Inner { struct Inner {
descriptions: RwLock<HashMap<String, metrics::SharedString>>, descriptions: RwLock<HashMap<String, metrics::SharedString>>,
distributions: RwLock<HashMap<String, IndexMap<Vec<(String, String)>, Summary>>>, distributions: RwLock<HashMap<String, DistributionMap>>,
recency: Recency<Key>, recency: Recency<Key>,
registry: Registry<Key, GenerationalStorage<AtomicStorage>>, registry: Registry<Key, GenerationalStorage<AtomicStorage>>,
} }
@ -289,7 +290,7 @@ impl Inner {
} }
let mut d = self.distributions.write().unwrap(); 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 let entry = outer_entry
.entry(labels) .entry(labels)
@ -303,8 +304,7 @@ impl Inner {
} }
let d = self.distributions.read().unwrap().clone(); let d = self.distributions.read().unwrap().clone();
let h = d d.into_iter()
.into_iter()
.map(|(key, value)| { .map(|(key, value)| {
( (
key, key,
@ -320,9 +320,7 @@ impl Inner {
.collect(), .collect(),
) )
}) })
.collect(); .collect()
h
} }
fn snapshot(&self) -> Snapshot { fn snapshot(&self) -> Snapshot {