Skip to content

Commit

Permalink
fix: fix compile error on mac and window
Browse files Browse the repository at this point in the history
  • Loading branch information
raindust committed Nov 29, 2023
1 parent a838457 commit f673d5f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 23 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,5 @@ wasmer-types = "3.2.1"
wasmparser = "0.104.0"
zstd = "0.12.3"
sysinfo = "0.29"
procfs = "0.15"
tabled = "0.14.0"
rand = "0.8"
20 changes: 4 additions & 16 deletions actorx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ openssl = { workspace = true, optional = true }
leb128 = { workspace = true, optional = true }
zstd = { workspace = true, optional = true }
sysinfo = { workspace = true, optional = true }
procfs = { workspace = true, optional = true }
tabled = { workspace = true, optional = true }

wasmer = { workspace = true, optional = true }
wasmer-middlewares = { workspace = true, optional = true }

[target.'cfg(target_os = "linux")'.dependencies]
procfs = "0.15"

[features]
default = ["sdk"]
sdk = []
Expand Down Expand Up @@ -84,7 +86,6 @@ host = [
"tokio-util",
"command-fds",
"sysinfo",
"procfs",
"tabled",
]
wasm = ["sdk", "futures"]
Expand All @@ -95,17 +96,4 @@ backtrace = ["tea-codec/backtrace"]
llvm = ["worker", "wasmer/llvm"]
timeout = []
track = ["timeout"]
__test = [
"sdk",
"tokio",
"tokio/io-util",
"tokio/net",
"tokio/parking_lot",
"tokio/process",
"tokio/time",
"tokio/sync",
"tokio-util",
"command-fds",
"sysinfo",
"tabled",
]
__test = []
11 changes: 7 additions & 4 deletions actorx/src/host/sys.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#[cfg(target_os = "linux")]
use procfs::{process::Process, ProcResult};
use sysinfo::SystemExt;
use tabled::{Table, Tabled};
use crate::error::Result;

pub fn dump_sys_usages() -> String {
let mut result = String::new();
Expand All @@ -11,7 +13,7 @@ pub fn dump_sys_usages() -> String {
result
}

pub fn get_memory_usage() -> ProcResult<(u64, u64)> {
pub fn get_memory_usage() -> Result<(u64, u64)> {
let mut sys = sysinfo::System::new_all();
sys.refresh_all();
let total = sys.total_memory();
Expand Down Expand Up @@ -61,6 +63,7 @@ struct ProcessInfo {
}

impl ProcessInfo {
#[cfg(target_os = "linux")]
fn new(pro: &Process, memory_m_bytes: u64, app_pid: i32) -> ProcResult<Self> {
Ok(Self {
pid: pro.pid,
Expand All @@ -71,7 +74,7 @@ impl ProcessInfo {
}
}

#[cfg(not(feature = "__test"))]
#[cfg(target_os = "linux")]
fn process_info() -> ProcResult<String> {
let app = Process::myself()?;

Expand All @@ -90,7 +93,7 @@ fn process_info() -> ProcResult<String> {
Ok(Table::new(processes).to_string())
}

#[cfg(feature = "__test")]
fn process_info() -> ProcResult<String> {
#[cfg(not(target_os = "linux"))]
fn process_info() -> Result<String> {
Ok("".to_string())
}
4 changes: 2 additions & 2 deletions actorx/src/host/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ impl Actor for WasmActor {
Some(self.id.clone())
}

#[cfg(not(feature = "__test"))]
#[cfg(target_os = "linux")]
async fn size(&self) -> Result<u64> {
let worker = self.worker::<false>().await?;
let pid = worker.pid().ok_or_err("worker pid")?;
Expand All @@ -220,7 +220,7 @@ impl Actor for WasmActor {
Ok(total_size)
}

#[cfg(feature = "__test")]
#[cfg(not(target_os = "linux"))]
async fn size(&self) -> Result<u64> {
Ok(0)
}
Expand Down

0 comments on commit f673d5f

Please sign in to comment.