Skip to content

Commit

Permalink
Quick dependency unification
Browse files Browse the repository at this point in the history
Only remaining task is to upgrade from clap 2 to 3.
  • Loading branch information
onalante-msft committed Apr 15, 2022
1 parent e2f22e4 commit fb8e43d
Show file tree
Hide file tree
Showing 32 changed files with 201 additions and 2,430 deletions.
355 changes: 105 additions & 250 deletions edgelet/Cargo.lock

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions edgelet/docker-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ version = "0.1.0"

[dependencies]
async-trait = "0.1"
base64 = "0.9"
futures = "0.1"
base64 = "0.13"
futures = "0.3"
hyper = "0.14"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
typed-headers = "0.1"
url = "1.5"
url = "2"

http-common = {git = "https://github.com/Azure/iot-identity-service", branch = "main"}
http-common = { git = "https://github.com/Azure/iot-identity-service", branch = "main" }

1 change: 0 additions & 1 deletion edgelet/docker-rs/src/apis/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::sync::Arc;

use futures::{Future, Stream};
use serde_json;
use typed_headers::{self, mime, HeaderMapExt};

use http_common::{Connector, ErrorBody, HttpRequest};
use hyper::{Body, Client, Uri};
Expand Down
1 change: 0 additions & 1 deletion edgelet/docker-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@
#![cfg(not(tarpaulin_include))]
pub mod apis;
pub mod models;
pub mod utils;

pub use apis::{DockerApi, DockerApiClient};
50 changes: 0 additions & 50 deletions edgelet/docker-rs/src/utils.rs

This file was deleted.

12 changes: 3 additions & 9 deletions edgelet/edgelet-docker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ version = "0.1.0"
[dependencies]
anyhow = "1"
async-trait = "0.1"
base64 = "0.9"
base64 = "0.13"
bytes = "1"
chrono = { version = "0.4", features = ["serde"] }
futures = "0.3"
hex="0.3"
hex = "0.4"
hyper = "0.14"
log = "0.4"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
sysinfo = "0.14.10"
sysinfo = "0.23"
thiserror = "1"
tokio = { version = "1", features = ["macros", "process"] }
url = { version = "2", features = ["serde"] }
Expand All @@ -32,9 +32,3 @@ edgelet-settings = { path = "../edgelet-settings", features = ["settings-docker"
edgelet-utils = { path = "../edgelet-utils" }
http-common = { git = "https://github.com/Azure/iot-identity-service", branch = "main" }
libc = "0.2.66"

[dev_dependencies]
maplit = "1.0"
tempfile = "3"
time = "0.1"
typed-headers = "0.1"
31 changes: 13 additions & 18 deletions edgelet/edgelet-docker/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::{mem, process, str};
use anyhow::Context;
use hyper::Uri;
use log::{debug, error, info, warn, Level};
use sysinfo::{DiskExt, ProcessExt, ProcessorExt, System, SystemExt};
use sysinfo::{DiskExt, PidExt, ProcessExt, ProcessorExt, System, SystemExt};
use tokio::sync::mpsc::UnboundedSender;
use tokio::sync::Mutex;
use url::Url;
Expand Down Expand Up @@ -666,35 +666,30 @@ impl ModuleRuntime for DockerModuleRuntime {
let mut system_resources = self.system_resources.as_ref().lock().await;
system_resources.refresh_all();

let start_time = process::id()
.try_into()
.map(|id| {
system_resources
.get_process(id)
.map(ProcessExt::start_time)
.unwrap_or_default()
})
let start_time = system_resources
.process(sysinfo::Pid::from_u32(process::id()))
.map(ProcessExt::start_time)
.unwrap_or_default();

let current_time = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap_or_default()
.as_secs();

let used_cpu = system_resources.get_global_processor_info().get_cpu_usage();
let total_memory = system_resources.get_total_memory() * 1000;
let used_memory = system_resources.get_used_memory() * 1000;
let used_cpu = system_resources.global_processor_info().cpu_usage();
let total_memory = system_resources.total_memory() * 1000;
let used_memory = system_resources.used_memory() * 1000;

let disks = system_resources
.get_disks()
.disks()
.iter()
.map(|disk| {
DiskInfo::new(
disk.get_name().to_string_lossy().into_owned(),
disk.get_available_space(),
disk.get_total_space(),
String::from_utf8_lossy(disk.get_file_system()).into_owned(),
format!("{:?}", disk.get_type()),
disk.name().to_string_lossy().into_owned(),
disk.available_space(),
disk.total_space(),
String::from_utf8_lossy(disk.file_system()).into_owned(),
format!("{:?}", disk.type_()),
)
})
.collect();
Expand Down
Loading

0 comments on commit fb8e43d

Please sign in to comment.