feat(events): add AgentEventPage + queryPage interface
Introduces cursor-paginated query on AgentEventRepository. The cursor format is owned by the implementation. The existing non-paginated query(...) is kept for internal consumers.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package com.cameleer.server.core.agent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Cursor-paginated result page for agent event queries.
|
||||
*
|
||||
* @param data events on this page, ordered newest-first
|
||||
* @param nextCursor opaque cursor to pass back for the next page (null when no more)
|
||||
* @param hasMore whether more results exist beyond this page
|
||||
*/
|
||||
public record AgentEventPage(
|
||||
List<AgentEventRecord> data,
|
||||
String nextCursor,
|
||||
boolean hasMore
|
||||
) {}
|
||||
@@ -8,4 +8,12 @@ public interface AgentEventRepository {
|
||||
void insert(String instanceId, String applicationId, String environment, String eventType, String detail);
|
||||
|
||||
List<AgentEventRecord> query(String applicationId, String instanceId, String environment, Instant from, Instant to, int limit);
|
||||
|
||||
/**
|
||||
* Cursor-paginated query ordered by (timestamp DESC, instance_id ASC). The cursor
|
||||
* is an opaque base64 string produced by the implementation; pass {@code null} for
|
||||
* the first page.
|
||||
*/
|
||||
AgentEventPage queryPage(String applicationId, String instanceId, String environment,
|
||||
Instant from, Instant to, String cursor, int limit);
|
||||
}
|
||||
|
||||
@@ -24,4 +24,9 @@ public class AgentEventService {
|
||||
public List<AgentEventRecord> queryEvents(String applicationId, String instanceId, String environment, Instant from, Instant to, int limit) {
|
||||
return repository.query(applicationId, instanceId, environment, from, to, limit);
|
||||
}
|
||||
|
||||
public AgentEventPage queryEventPage(String applicationId, String instanceId, String environment,
|
||||
Instant from, Instant to, String cursor, int limit) {
|
||||
return repository.queryPage(applicationId, instanceId, environment, from, to, cursor, limit);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user