Skip to content

Commit 007ef2b

Browse files
author
eastgate
committed
fix: sysinfo 0.30 API compatibility and clippy errors
- Fixed sysinfo API: refresh_cpu_all() -> refresh_cpu() - Fixed sysinfo API: global_cpu_usage() -> global_cpu_info().cpu_usage() - Added proper documentation backticks for code terms - Added #[must_use] attributes to getter methods - Added # Errors section to bind_endpoint() - Fixed duplicate match arms in init_logging() - Suppressed clippy::too_many_lines for display function Resolves integration team build issues with sysinfo 0.30.13
1 parent 42e6869 commit 007ef2b

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

code/crates/nestgate-api/src/bin/nestgate-api-server.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ use tracing::{debug, info};
4747

4848
/// Server configuration with RPC capabilities
4949
///
50-
/// ✅ MODERNIZED (Week 2): Now uses EnvironmentConfig for all settings
51-
/// Eliminates hardcoded defaults and manual env::var parsing
50+
/// ✅ MODERNIZED (Week 2): Now uses `EnvironmentConfig` for all settings
51+
/// Eliminates hardcoded defaults and manual `env::var` parsing
5252
#[derive(Debug, Clone)]
5353
/// Configuration for Server
5454
pub struct ServerConfig {
@@ -67,29 +67,35 @@ pub struct ServerConfig {
6767
}
6868

6969
impl ServerConfig {
70-
/// Get bind endpoint as SocketAddr
70+
/// Get bind endpoint as `SocketAddr`
71+
///
72+
/// # Errors
73+
/// Returns an error if the bind address cannot be parsed
7174
pub fn bind_endpoint(&self) -> Result<SocketAddr, std::net::AddrParseError> {
7275
self.env_config.bind_address()
7376
}
7477

7578
/// Get API port
79+
#[must_use]
7680
pub fn api_port(&self) -> u16 {
7781
self.env_config.network.port.get()
7882
}
7983

8084
/// Get bind address string
85+
#[must_use]
8186
pub fn bind_address(&self) -> &str {
8287
&self.env_config.network.host
8388
}
8489

8590
/// Get log level
91+
#[must_use]
8692
pub fn log_level(&self) -> &str {
8793
&self.env_config.monitoring.log_level
8894
}
8995
}
9096

9197
impl Default for ServerConfig {
92-
/// Returns the default instance using EnvironmentConfig
98+
/// Returns the default instance using `EnvironmentConfig`
9399
fn default() -> Self {
94100
Self {
95101
env_config: EnvironmentConfig::default(),
@@ -170,8 +176,8 @@ async fn main() -> Result<()> {
170176

171177
/// Load server configuration with RPC settings
172178
///
173-
/// ✅ MODERNIZED (Week 2): Uses EnvironmentConfig for all settings
174-
/// Eliminates manual env::var parsing and unwrap() calls
179+
/// ✅ MODERNIZED (Week 2): Uses `EnvironmentConfig` for all settings
180+
/// Eliminates manual `env::var` parsing and `unwrap()` calls
175181
fn load_config() -> Result<ServerConfig> {
176182
// Load base configuration from environment
177183
let env_config =
@@ -222,10 +228,9 @@ fn init_logging(log_level: &str) {
222228
let level = match log_level.to_lowercase().as_str() {
223229
"trace" => tracing::Level::TRACE,
224230
"debug" => tracing::Level::DEBUG,
225-
"info" => tracing::Level::INFO,
226231
"warn" => tracing::Level::WARN,
227232
"error" => tracing::Level::ERROR,
228-
_ => tracing::Level::INFO,
233+
_ => tracing::Level::INFO, // "info" or unknown defaults to INFO
229234
};
230235
// Initialize basic tracing (tracing_subscriber not available)
231236
println!("Initializing tracing with level: {level:?}");
@@ -259,6 +264,7 @@ fn print_enhanced_banner() {
259264
);
260265
}
261266
/// Print enhanced API endpoints with RPC capabilities
267+
#[allow(clippy::too_many_lines)]
262268
fn print_enhanced_api_endpoints(config: &ServerConfig) {
263269
println!("\n📋 Complete API Endpoints with Real-time Bidirectional RPC:");
264270
println!("┌─────────────────────────────────────────────────────────────────────┐");

code/crates/nestgate-api/src/handlers/storage_error_path_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,3 +384,4 @@ fn test_storage_structs_are_debug() {
384384

385385

386386

387+

code/crates/nestgate-api/src/rest/handlers/monitoring.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,8 @@ pub async fn get_alerts(
279279
// Simulate system resource alerts
280280
// ✅ REAL METRICS: Get actual current CPU usage
281281
let mut sys = sysinfo::System::new();
282-
sys.refresh_cpu_all();
283-
let current_cpu = f64::from(sys.global_cpu_usage());
282+
sys.refresh_cpu();
283+
let current_cpu = f64::from(sys.global_cpu_info().cpu_usage());
284284
if current_cpu > 80.0 {
285285
alerts.push(Alert {
286286
id: "alert_002".to_string(),

scripts/clippy_pedantic_analysis.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ echo "🎯 Estimated time: 1-2 hours for all fixes"
4242

4343

4444

45+

0 commit comments

Comments
 (0)