refactor: SearchService uses SearchIndex + StatsStore instead of SearchEngine

This commit is contained in:
hsiegeln
2026-03-16 18:18:52 +01:00
parent a55fc3c10d
commit 84b93d74c7

View File

@@ -1,63 +1,43 @@
package com.cameleer3.server.core.search;
import com.cameleer3.server.core.storage.SearchIndex;
import com.cameleer3.server.core.storage.StatsStore;
import java.time.Instant;
import java.util.List;
/**
* Orchestrates search operations, delegating to a {@link SearchEngine} backend.
* <p>
* This is a plain class (no Spring annotations) -- it lives in the core module
* and is wired as a bean by the app module configuration. The thin orchestration
* layer allows adding cross-cutting concerns (logging, caching, metrics) later.
*/
public class SearchService {
private final SearchEngine engine;
private final SearchIndex searchIndex;
private final StatsStore statsStore;
public SearchService(SearchEngine engine) {
this.engine = engine;
public SearchService(SearchIndex searchIndex, StatsStore statsStore) {
this.searchIndex = searchIndex;
this.statsStore = statsStore;
}
/**
* Search for route executions matching the given criteria.
*/
public SearchResult<ExecutionSummary> search(SearchRequest request) {
return engine.search(request);
return searchIndex.search(request);
}
/**
* Count route executions matching the given criteria.
*/
public long count(SearchRequest request) {
return engine.count(request);
return searchIndex.count(request);
}
/**
* Compute aggregate execution stats (P99 latency, active count).
*/
public ExecutionStats stats(java.time.Instant from, java.time.Instant to) {
return engine.stats(from, to);
public ExecutionStats stats(Instant from, Instant to) {
return statsStore.stats(from, to);
}
/**
* Compute aggregate execution stats scoped to specific routes and agents.
*/
public ExecutionStats stats(java.time.Instant from, java.time.Instant to,
String routeId, List<String> agentIds) {
return engine.stats(from, to, routeId, agentIds);
public ExecutionStats stats(Instant from, Instant to, String routeId, List<String> agentIds) {
return statsStore.statsForRoute(from, to, routeId, agentIds);
}
/**
* Compute bucketed time-series stats over a time window.
*/
public StatsTimeseries timeseries(java.time.Instant from, java.time.Instant to, int bucketCount) {
return engine.timeseries(from, to, bucketCount);
public StatsTimeseries timeseries(Instant from, Instant to, int bucketCount) {
return statsStore.timeseries(from, to, bucketCount);
}
/**
* Compute bucketed time-series stats scoped to specific routes and agents.
*/
public StatsTimeseries timeseries(java.time.Instant from, java.time.Instant to, int bucketCount,
public StatsTimeseries timeseries(Instant from, Instant to, int bucketCount,
String routeId, List<String> agentIds) {
return engine.timeseries(from, to, bucketCount, routeId, agentIds);
return statsStore.timeseriesForRoute(from, to, bucketCount, routeId, agentIds);
}
}