Skip to content

Commit dc6a7bd

Browse files
committed
fix: gate memory imports in ServiceRuntime for feature-minimal builds
1 parent 84b3e00 commit dc6a7bd

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/cli/runtime.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ use std::sync::Arc;
4141
use tokio_util::sync::CancellationToken;
4242

4343
use crate::env::{RuntimeContext, runtime_context};
44+
#[cfg(feature = "memory")]
4445
use crate::memory::{MemoryGuard, MemoryGuardConfig};
4546
use crate::metrics::MetricsManager;
4647

@@ -62,6 +63,7 @@ pub struct ServiceRuntime {
6263

6364
/// Cgroup-aware memory guard. Tracks memory usage for backpressure.
6465
/// Auto-detected from env prefix + cgroup limits.
66+
#[cfg(feature = "memory")]
6567
pub memory_guard: Arc<MemoryGuard>,
6668

6769
/// Shutdown token. Cancelled on SIGTERM/SIGINT (with K8s pre-stop delay).
@@ -112,6 +114,7 @@ impl ServiceRuntime {
112114
}
113115

114116
// --- Memory guard ---
117+
#[cfg(feature = "memory")]
115118
let memory_guard = Arc::new(MemoryGuard::new(MemoryGuardConfig::from_env(env_prefix)));
116119

117120
// --- Scaling pressure ---
@@ -130,6 +133,7 @@ impl ServiceRuntime {
130133
Ok(pool) => {
131134
let pool = Arc::new(pool);
132135
pool.register_metrics(&metrics);
136+
#[cfg(feature = "memory")]
133137
pool.set_memory_guard(Arc::clone(&memory_guard));
134138
#[cfg(feature = "scaling")]
135139
if let Some(ref sp) = scaling {
@@ -181,13 +185,13 @@ impl ServiceRuntime {
181185
environment = %ctx.environment,
182186
pod_name = ?ctx.pod_name,
183187
namespace = ?ctx.namespace,
184-
memory_limit = memory_guard.limit_bytes(),
185188
"Service runtime initialised"
186189
);
187190

188191
Ok(Self {
189192
metrics,
190193
dfe,
194+
#[cfg(feature = "memory")]
191195
memory_guard,
192196
shutdown,
193197
context: ctx,

0 commit comments

Comments
 (0)