Unverified Commit 3acdc0f8 authored by Biswa Panda's avatar Biswa Panda Committed by GitHub
Browse files

feat(runtime): add DYN_TCP_RESPONSE_STREAM_PORT/HOST env vars for configurable...

feat(runtime): add DYN_TCP_RESPONSE_STREAM_PORT/HOST env vars for configurable response stream server port
parent f7fe8005
......@@ -14,6 +14,7 @@
//! - **Runtime**: Tokio runtime configuration and system server settings
//! - **NATS**: NATS client connection and authentication
//! - **ETCD**: ETCD client connection and authentication
//! - **TCP Response Stream**: TCP response stream server (CallHome) port and host
//! - **Event Plane**: Event transport selection (NATS)
//! - **KVBM**: Key-Value Block Manager configuration
//! - **LLM**: Language model inference configuration
......@@ -351,6 +352,17 @@ pub mod router {
pub const DYN_ROUTER_QUEUE_POLICY: &str = "DYN_ROUTER_QUEUE_POLICY";
}
/// TCP response stream server (CallHome listener) environment variables
pub mod tcp_response_stream {
/// Port for the TCP response stream server.
/// If unset or 0, the OS assigns a free ephemeral port.
pub const DYN_TCP_RESPONSE_STREAM_PORT: &str = "DYN_TCP_RESPONSE_STREAM_PORT";
/// Host/interface for the TCP response stream server.
/// If unset, the server auto-detects a routable local IP.
pub const DYN_TCP_RESPONSE_STREAM_HOST: &str = "DYN_TCP_RESPONSE_STREAM_HOST";
}
/// Event Plane transport environment variables
pub mod event_plane {
/// Event transport selection: "zmq" or "nats". Default: "nats"
......@@ -505,6 +517,9 @@ mod tests {
// Router
router::DYN_ROUTER_QUEUE_THRESHOLD,
router::DYN_ROUTER_QUEUE_POLICY,
// TCP Response Stream
tcp_response_stream::DYN_TCP_RESPONSE_STREAM_PORT,
tcp_response_stream::DYN_TCP_RESPONSE_STREAM_HOST,
// Event Plane
event_plane::DYN_EVENT_PLANE,
event_plane::DYN_EVENT_PLANE_CODEC,
......
......@@ -4,6 +4,7 @@
use crate::component::{
self, Component, ComponentBuilder, Endpoint, Instance, Namespace, RoutingOccupancyState,
};
use crate::config::environment_names::tcp_response_stream;
use crate::pipeline::PipelineError;
use crate::pipeline::network::manager::NetworkManager;
use crate::service::{ServiceClient, ServiceSet};
......@@ -344,7 +345,34 @@ impl DistributedRuntime {
Ok(self
.tcp_server
.get_or_try_init(async move {
let options = tcp::server::ServerOptions::default();
let port = match std::env::var(tcp_response_stream::DYN_TCP_RESPONSE_STREAM_PORT) {
Ok(p) => p.parse::<u16>().map_err(|_| {
PipelineError::Generic(format!(
"invalid {}: '{}' is not a valid port number",
tcp_response_stream::DYN_TCP_RESPONSE_STREAM_PORT,
p
))
})?,
Err(_) => 0,
};
let interface = std::env::var(tcp_response_stream::DYN_TCP_RESPONSE_STREAM_HOST)
.ok()
.filter(|h| !h.is_empty());
let host_suffix = interface
.as_ref()
.map_or(String::new(), |h| format!(" on host {h}"));
if port == 0 {
tracing::info!(
"TCP response stream server using OS-assigned port{host_suffix}"
);
} else {
tracing::info!(
"TCP response stream server using fixed port {port}{host_suffix}"
);
}
let options = tcp::server::ServerOptions { port, interface };
let server = tcp::server::TcpStreamServer::new(options).await?;
Ok::<_, PipelineError>(server)
})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment