feat: merge persistent route catalog into legacy catalog endpoint
Add RouteCatalogStore as a third data source in RouteCatalogController so that /api/v1/routes/catalog surfaces routes with zero executions and routes from previous app versions that fall within the requested time window. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,8 @@ import com.cameleer.server.core.agent.AgentRegistryService;
|
|||||||
import com.cameleer.server.core.agent.AgentState;
|
import com.cameleer.server.core.agent.AgentState;
|
||||||
import com.cameleer.server.core.agent.RouteStateRegistry;
|
import com.cameleer.server.core.agent.RouteStateRegistry;
|
||||||
import com.cameleer.server.core.storage.DiagramStore;
|
import com.cameleer.server.core.storage.DiagramStore;
|
||||||
|
import com.cameleer.server.core.storage.RouteCatalogEntry;
|
||||||
|
import com.cameleer.server.core.storage.RouteCatalogStore;
|
||||||
import com.cameleer.server.core.storage.StatsStore;
|
import com.cameleer.server.core.storage.StatsStore;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
@@ -42,15 +44,18 @@ public class RouteCatalogController {
|
|||||||
private final DiagramStore diagramStore;
|
private final DiagramStore diagramStore;
|
||||||
private final JdbcTemplate jdbc;
|
private final JdbcTemplate jdbc;
|
||||||
private final RouteStateRegistry routeStateRegistry;
|
private final RouteStateRegistry routeStateRegistry;
|
||||||
|
private final RouteCatalogStore routeCatalogStore;
|
||||||
|
|
||||||
public RouteCatalogController(AgentRegistryService registryService,
|
public RouteCatalogController(AgentRegistryService registryService,
|
||||||
DiagramStore diagramStore,
|
DiagramStore diagramStore,
|
||||||
@org.springframework.beans.factory.annotation.Qualifier("clickHouseJdbcTemplate") JdbcTemplate jdbc,
|
@org.springframework.beans.factory.annotation.Qualifier("clickHouseJdbcTemplate") JdbcTemplate jdbc,
|
||||||
RouteStateRegistry routeStateRegistry) {
|
RouteStateRegistry routeStateRegistry,
|
||||||
|
RouteCatalogStore routeCatalogStore) {
|
||||||
this.registryService = registryService;
|
this.registryService = registryService;
|
||||||
this.diagramStore = diagramStore;
|
this.diagramStore = diagramStore;
|
||||||
this.jdbc = jdbc;
|
this.jdbc = jdbc;
|
||||||
this.routeStateRegistry = routeStateRegistry;
|
this.routeStateRegistry = routeStateRegistry;
|
||||||
|
this.routeCatalogStore = routeCatalogStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/catalog")
|
@GetMapping("/catalog")
|
||||||
@@ -122,6 +127,20 @@ public class RouteCatalogController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Merge routes from persistent catalog (covers routes with 0 executions
|
||||||
|
// and routes from previous app versions within the selected time window)
|
||||||
|
try {
|
||||||
|
List<RouteCatalogEntry> catalogEntries = (environment != null && !environment.isBlank())
|
||||||
|
? routeCatalogStore.findByEnvironment(environment, rangeFrom, rangeTo)
|
||||||
|
: routeCatalogStore.findAll(rangeFrom, rangeTo);
|
||||||
|
for (RouteCatalogEntry entry : catalogEntries) {
|
||||||
|
routesByApp.computeIfAbsent(entry.applicationId(), k -> new LinkedHashSet<>())
|
||||||
|
.add(entry.routeId());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("Failed to query route catalog: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
// Build catalog entries — merge apps from agent registry + ClickHouse data
|
// Build catalog entries — merge apps from agent registry + ClickHouse data
|
||||||
Set<String> allAppIds = new LinkedHashSet<>(agentsByApp.keySet());
|
Set<String> allAppIds = new LinkedHashSet<>(agentsByApp.keySet());
|
||||||
allAppIds.addAll(routesByApp.keySet());
|
allAppIds.addAll(routesByApp.keySet());
|
||||||
|
|||||||
Reference in New Issue
Block a user