feat(fxt): add PodData/PodGroupData structs and StateUpdate::Pods

Add K8s pod data structures to TUI state layer for the upcoming pods
cockpit view. PodData represents individual pods, PodGroupData groups
them by service with ready/total counts. The StateUpdate::Pods variant
and apply_update handler wire the data path from gRPC streams to state.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jgrusewski
2026-03-04 12:56:40 +01:00
parent c49608815a
commit 4951daea36
3 changed files with 36 additions and 2 deletions

View File

@@ -25,8 +25,8 @@ use crate::proto::{broker_gateway, data_acquisition, ml, monitoring, risk, tradi
use super::state::{
AccountData, AlertData, CircuitBreakerData, ConnectionStatus, DataCacheData, DataFeedData,
ExecutionData, GpuData, ModelStatusData, OrderEventData, PositionData, RiskAlertData, RiskData,
ServiceData, SystemResources, TrainingSessionData,
ExecutionData, GpuData, ModelStatusData, OrderEventData, PodGroupData, PositionData,
RiskAlertData, RiskData, ServiceData, SystemResources, TrainingSessionData,
};
// ---------------------------------------------------------------------------
@@ -73,6 +73,8 @@ pub enum StateUpdate {
daily_pnl: f64,
total_pnl: f64,
},
/// Cluster pod statuses (from SubscribeClusterPods).
Pods(Vec<PodGroupData>),
/// gRPC connection status change.
Connection(ConnectionStatus),
}

View File

@@ -320,6 +320,9 @@ fn apply_update(state: &mut AppState, update: StateUpdate) {
state.account.daily_pnl = daily_pnl;
state.account.total_pnl = total_pnl;
}
StateUpdate::Pods(pods) => {
state.pods = pods;
}
StateUpdate::Connection(status) => {
state.connection_status = status;
}

View File

@@ -63,6 +63,12 @@ pub struct AppState {
pub data_cache: DataCacheData,
/// System alerts from monitoring (ring buffer).
pub alerts: VecDeque<AlertData>,
/// K8s pod groups (from SubscribeClusterPods).
pub pods: Vec<PodGroupData>,
/// Currently selected pod group index.
pub selected_pod_group: Option<usize>,
/// Whether the selected pod group is expanded.
pub pod_group_expanded: bool,
/// Timestamp of the last data refresh.
pub last_update: Instant,
/// gRPC connection status.
@@ -88,6 +94,9 @@ impl Default for AppState {
data_feeds: Vec::new(),
data_cache: DataCacheData::default(),
alerts: VecDeque::new(),
pods: Vec::new(),
selected_pod_group: None,
pod_group_expanded: false,
last_update: Instant::now(),
connection_status: ConnectionStatus::default(),
}
@@ -314,3 +323,23 @@ pub struct AlertData {
pub service: String,
pub title: String,
}
/// A single K8s pod.
pub struct PodData {
pub name: String,
pub service: String,
pub status: String,
pub restarts: i32,
pub age: String,
pub node: String,
pub ready: bool,
pub version: String,
}
/// Pods grouped by service.
pub struct PodGroupData {
pub service: String,
pub pods: Vec<PodData>,
pub ready_count: usize,
pub total_count: usize,
}