refactor: SearchService uses SearchIndex + StatsStore instead of SearchEngine
This commit is contained in:
@@ -1,63 +1,43 @@
|
|||||||
package com.cameleer3.server.core.search;
|
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;
|
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 {
|
public class SearchService {
|
||||||
|
|
||||||
private final SearchEngine engine;
|
private final SearchIndex searchIndex;
|
||||||
|
private final StatsStore statsStore;
|
||||||
|
|
||||||
public SearchService(SearchEngine engine) {
|
public SearchService(SearchIndex searchIndex, StatsStore statsStore) {
|
||||||
this.engine = engine;
|
this.searchIndex = searchIndex;
|
||||||
|
this.statsStore = statsStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Search for route executions matching the given criteria.
|
|
||||||
*/
|
|
||||||
public SearchResult<ExecutionSummary> search(SearchRequest request) {
|
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) {
|
public long count(SearchRequest request) {
|
||||||
return engine.count(request);
|
return searchIndex.count(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public ExecutionStats stats(Instant from, Instant to) {
|
||||||
* Compute aggregate execution stats (P99 latency, active count).
|
return statsStore.stats(from, to);
|
||||||
*/
|
|
||||||
public ExecutionStats stats(java.time.Instant from, java.time.Instant to) {
|
|
||||||
return engine.stats(from, to);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public ExecutionStats stats(Instant from, Instant to, String routeId, List<String> agentIds) {
|
||||||
* Compute aggregate execution stats scoped to specific routes and agents.
|
return statsStore.statsForRoute(from, to, routeId, agentIds);
|
||||||
*/
|
|
||||||
public ExecutionStats stats(java.time.Instant from, java.time.Instant to,
|
|
||||||
String routeId, List<String> agentIds) {
|
|
||||||
return engine.stats(from, to, routeId, agentIds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public StatsTimeseries timeseries(Instant from, Instant to, int bucketCount) {
|
||||||
* Compute bucketed time-series stats over a time window.
|
return statsStore.timeseries(from, to, bucketCount);
|
||||||
*/
|
|
||||||
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,
|
||||||
* Compute bucketed time-series stats scoped to specific routes and agents.
|
|
||||||
*/
|
|
||||||
public StatsTimeseries timeseries(java.time.Instant from, java.time.Instant to, int bucketCount,
|
|
||||||
String routeId, List<String> agentIds) {
|
String routeId, List<String> agentIds) {
|
||||||
return engine.timeseries(from, to, bucketCount, routeId, agentIds);
|
return statsStore.timeseriesForRoute(from, to, bucketCount, routeId, agentIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user