List of usage examples for io.vertx.core CompositeFuture list
@GenIgnore
default <T> List<T> list()
From source file:io.engagingspaces.graphql.servicediscovery.publisher.SchemaPublisher.java
License:Open Source License
/** * Publishes the provided schema definitions to the specified service discovery. * <p>/* w w w. j a v a 2 s .c o m*/ * Upon success a list of {@link SchemaRegistration}s is returned in the result handler. * * @param options the service discovery options * @param resultHandler the result handler * @param schemas the GraphQL schema's to publish */ default void publishAll(ServiceDiscoveryOptions options, Handler<AsyncResult<List<SchemaRegistration>>> resultHandler, GraphQLSchema... schemas) { Objects.requireNonNull(resultHandler, "Publication result handler cannot be null"); if (schemas == null || schemas.length == 0) { resultHandler.handle(Future.failedFuture("Nothing to publish. No schema definitions provided")); return; } List<Future> futures = new ArrayList<>(); Arrays.asList(schemas).forEach(schema -> publish(options, schema, rh -> futures .add(rh.succeeded() ? Future.succeededFuture(rh.result()) : Future.failedFuture(rh.cause())))); CompositeFuture.all(futures).setHandler(rh -> { if (rh.failed()) { resultHandler.handle(Future.failedFuture(rh.cause())); return; } CompositeFuture composite = rh.result(); List<SchemaRegistration> published = composite.list(); if (published.size() != schemas.length) { List<Throwable> errors = rh.result().<Future<Void>>list().stream().filter(Future::failed) .map(Future::cause).collect(Collectors.toList()); resultHandler.handle(Future.failedFuture(new PartialPublishException(errors))); } else { resultHandler.handle(Future.succeededFuture(published)); } }); }