feat: spawn docker updates into own thread

Collects spawns into a hashmap, then on next update if spawn exists in hash map, don't bother to run another update
This commit is contained in:
Jack Wills
2022-07-23 02:46:38 +00:00
parent f5504c47c5
commit d0f617820c
7 changed files with 128 additions and 83 deletions
+14 -26
View File
@@ -233,24 +233,12 @@ impl AppData {
SortedOrder::Desc => self.containers.items.sort_by(|a, b| b.name.cmp(&a.name)),
},
Header::Rx => match so {
SortedOrder::Asc => self
.containers
.items
.sort_by(|a, b| a.net_rx.cmp(&b.net_rx)),
SortedOrder::Desc => self
.containers
.items
.sort_by(|a, b| b.net_rx.cmp(&a.net_rx)),
SortedOrder::Asc => self.containers.items.sort_by(|a, b| a.rx.cmp(&b.rx)),
SortedOrder::Desc => self.containers.items.sort_by(|a, b| b.rx.cmp(&a.rx)),
},
Header::Tx => match so {
SortedOrder::Asc => self
.containers
.items
.sort_by(|a, b| a.net_tx.cmp(&b.net_tx)),
SortedOrder::Desc => self
.containers
.items
.sort_by(|a, b| b.net_tx.cmp(&a.net_tx)),
SortedOrder::Asc => self.containers.items.sort_by(|a, b| a.tx.cmp(&b.tx)),
SortedOrder::Desc => self.containers.items.sort_by(|a, b| b.tx.cmp(&a.tx)),
},
}
}
@@ -341,8 +329,8 @@ impl AppData {
container.mem_limit
));
let net_rx_count = count(&container.net_rx.to_string());
let net_tx_count = count(&container.net_tx.to_string());
let net_rx_count = count(&container.rx.to_string());
let net_tx_count = count(&container.tx.to_string());
let image_count = count(&container.image);
let name_count = count(&container.name);
let state_count = count(&container.state.to_string());
@@ -415,8 +403,8 @@ impl AppData {
container.mem_stats.push_back(ByteStats::new(mem));
}
container.net_rx.update(rx);
container.net_tx.update(tx);
container.rx.update(rx);
container.tx.update(tx);
container.mem_limit.update(mem_limit);
}
}
@@ -527,10 +515,10 @@ impl AppData {
self.logs_parsed = true;
}
/// Update all containers logs, should only be used on first initialisation
pub fn update_all_logs(&mut self, all_logs: Vec<Vec<String>>) {
for (index, output) in all_logs.into_iter().enumerate() {
self.update_log_by_index(output, index);
}
}
// /// Update all containers logs, should only be used on first initialisation
// pub fn update_all_logs(&mut self, all_logs: Vec<Vec<String>>) {
// for (index, output) in all_logs.into_iter().enumerate() {
// self.update_log_by_index(output, index);
// }
// }
}