Skip to main content

soma_gateway/gateway/
view_models.rs

1use serde_json::{json, Value};
2
3use crate::gateway::manager::{GatewayManager, GatewayManagerError};
4use crate::gateway::projection::GatewayProjection;
5
6pub async fn gateway_list_view(manager: &GatewayManager) -> Result<Value, GatewayManagerError> {
7    let projection = GatewayProjection::from_manager(manager).await?;
8    Ok(json!({
9        "upstream_count": projection.upstream_count,
10        "connected_count": projection.connected_count,
11        "discovered_tool_count": projection.discovered_tool_count,
12        "exposed_tool_count": projection.exposed_tool_count,
13        "likely_stale_count": projection.likely_stale_count,
14    }))
15}
16
17pub fn gateway_config_view(manager: &GatewayManager) -> Value {
18    serde_json::to_value(manager.config_view()).expect("gateway config view serializes")
19}
20
21#[cfg(test)]
22#[path = "view_models_tests.rs"]
23mod tests;