use of com.netflix.titus.api.model.Pagination in project titus-control-plane by Netflix.
the class CellWithFixedTasksService method findTasks.
@Override
public void findTasks(TaskQuery request, StreamObserver<TaskQueryResult> responseObserver) {
Pair<List<Task>, Pagination> page = PaginationUtil.takePageWithCursor(toPage(request.getPage()), getTasksList(), JobManagerCursors.taskCursorOrderComparator(), JobManagerCursors::taskIndexOf, JobManagerCursors::newTaskCursorFrom);
Set<String> fieldsFilter = new HashSet<>(request.getFieldsList());
if (!fieldsFilter.isEmpty()) {
fieldsFilter.add("id");
page = page.mapLeft(tasks -> tasks.stream().map(task -> ProtobufExt.copy(task, fieldsFilter)).collect(Collectors.toList()));
}
TaskQueryResult result = TaskQueryResult.newBuilder().addAllItems(page.getLeft()).setPagination(toGrpcPagination(page.getRight())).build();
responseObserver.onNext(result);
responseObserver.onCompleted();
}
Aggregations