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:
hsiegeln
2026-04-17 11:52:42 +02:00
parent 769752a327
commit 67a834153e
3 changed files with 29 additions and 0 deletions

View File

@@ -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
) {}

View File

@@ -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);
}

View File

@@ -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);
}
}