class AggregatingJobServiceGateway implements JobServiceGateway {

    private Observable<JobQueryResult> findJobsWithCursorPagination(JobQuery request, Set<String> fields, CallMetadata callMetadata) {
        return aggregatingClient.call(JobManagementServiceGrpc::newStub, findJobsInCell(request, callMetadata))
                .map(CellResponse::getResult)
                .map(this::addStackName)
                .reduce(this::combineJobResults)
                .map(combinedResults -> {
                    Pair<List<Job>, Pagination> combinedPage = takeCombinedPage(
                            request.getPage(),
                            combinedResults.getItemsList(),
                            combinedResults.getPagination(),
                            JobManagerCursors.jobCursorOrderComparator(),
                            JobManagerCursors::newCursorFrom
                    );

                    if (!CollectionsExt.isNullOrEmpty(fields)) {
                        combinedPage = combinedPage.mapLeft(jobs -> jobs.stream()
                                .map(job -> ProtobufExt.copy(job, fields))
                                .collect(Collectors.toList())
                        );
                    }

                    return JobQueryResult.newBuilder()
                            .addAllItems(combinedPage.getLeft())
                            .setPagination(combinedPage.getRight())
                            .build();
                });
    }

    @Inject public  AggregatingJobServiceGateway(GrpcConfiguration grpcConfiguration,
                                        TitusFederationConfiguration federationConfiguration,
                                        CellConnector connector,
                                        CellRouter router,
                                        AggregatingCellClient aggregatingClient,
                                        AggregatingJobManagementServiceHelper jobManagementServiceHelper);

}