Also replace HashMap with LinkedHashMap to keep service order

This commit is contained in:
Mutzi 2024-01-27 14:42:05 +01:00
parent 94afceb6d0
commit cd391a233d
Signed by: root
GPG Key ID: 2437494E09F13876
3 changed files with 10 additions and 2 deletions

7
Cargo.lock generated
View File

@ -220,6 +220,12 @@ version = "0.2.152"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
[[package]]
name = "linked-hash-map"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
[[package]]
name = "log"
version = "0.4.20"
@ -250,6 +256,7 @@ dependencies = [
"graph-cycles",
"hhmmss",
"libc",
"linked-hash-map",
"nix",
"petgraph",
"serde",

View File

@ -12,6 +12,7 @@ daemonize = "0.5.0"
serde = { version = "1.0", features = ["derive"] }
toml = { version = "0.8.8", features = ["preserve_order"] }
linked-hash-map = "0.5.6"
shlex = "1.3.0"
petgraph = "0.6.4"

View File

@ -19,7 +19,7 @@ struct Data {
pub epoll: nix::sys::epoll::Epoll,
pub sigfd: nix::sys::signalfd::SignalFd,
pub work_queue: Option<std::sync::mpsc::Sender<WorkItem>>,
pub services: std::collections::HashMap<u64, service::Service>
pub services: linked_hash_map::LinkedHashMap<u64, service::Service>
}
impl Data {
fn new() -> Self {
@ -35,7 +35,7 @@ impl Data {
epoll,
sigfd,
work_queue: None,
services: std::collections::HashMap::new()
services: Default::default()
}
}