added Option to data structs
This commit is contained in:
@@ -58,10 +58,10 @@ pub async fn get_single_container_memory_stats(
|
||||
};
|
||||
|
||||
return Ok(Some(ContainerMemoryInfo {
|
||||
container_id: container_id.to_string(),
|
||||
memory_usage,
|
||||
memory_limit,
|
||||
memory_usage_percent,
|
||||
container_id: Some(container_id.to_string()),
|
||||
memory_usage: Some(memory_usage),
|
||||
memory_limit: Some(memory_limit),
|
||||
memory_usage_percent: Some(memory_usage_percent),
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,6 @@ pub async fn get_single_container_memory_stats(
|
||||
/// Get total memory usage across all containers
|
||||
pub async fn get_total_memory_usage(docker: &Docker) -> Result<u64, Box<dyn Error + Send + Sync>> {
|
||||
let mem_infos = get_all_containers_memory_stats(docker).await?;
|
||||
let total_memory: u64 = mem_infos.iter().map(|mem| mem.memory_usage).sum();
|
||||
let total_memory: u64 = mem_infos.iter().map(|mem| mem.memory_usage.unwrap()).sum();
|
||||
Ok(total_memory)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user