/** * Publishes a record. * @param record the record * @param resultHandler handler called when the operation has completed (successfully or not). In case of success, the passed record has a registration id required to modify and un-register the service. */ public void publish(Record record, Handler<AsyncResult<Record>> resultHandler) { delegate.publish(record, resultHandler); }
/** * Un-publishes a record. * @param id the registration id * @param resultHandler handler called when the operation has completed (successfully or not). */ public void unpublish(String id, Handler<AsyncResult<Void>> resultHandler) { delegate.unpublish(id, resultHandler); }
/** * Updates an existing record. * @param record the record * @param resultHandler handler called when the operation has completed (successfully or not). In case of success, the passed record has a registration id required to modify and un-register the service. */ public void update(Record record, Handler<AsyncResult<Record>> resultHandler) { delegate.update(record, resultHandler); }
.map(reg -> { Future<Void> future = Future.future(); publisher.unpublish(reg.record().getRegistration(), v -> { registrations.remove(reg); if (v.succeeded()) { .map(instance -> { Future<Void> future = Future.future(); publisher.publish(createRecordForInstance(instance), v -> { if (v.succeeded()) { registrations.add(new RegistrationHolder<>(v.result(), instance));
.map(reg -> { Future<Void> future = Future.future(); publisher.unpublish(reg.record().getRegistration(), v -> { registrations.remove(reg); if (v.succeeded()) { .map(instance -> { Future<Void> future = Future.future(); publisher.publish(createRecordForInstance(instance), v -> { if (v.succeeded()) { registrations.add(new RegistrationHolder<>(v.result(), instance));
/** * Publishes a record. * @param record the record * @param resultHandler handler called when the operation has completed (successfully or not). In case of success, the passed record has a registration id required to modify and un-register the service. */ public void publish(Record record, Handler<AsyncResult<Record>> resultHandler) { delegate.publish(record, resultHandler); }
/** * Un-publishes a record. * @param id the registration id * @param resultHandler handler called when the operation has completed (successfully or not). */ public void unpublish(String id, Handler<AsyncResult<Void>> resultHandler) { delegate.unpublish(id, resultHandler); }
/** * Updates an existing record. * @param record the record * @param resultHandler handler called when the operation has completed (successfully or not). In case of success, the passed record has a registration id required to modify and un-register the service. */ public void update(Record record, Handler<AsyncResult<Record>> resultHandler) { delegate.update(record, resultHandler); }
/** * Registers the service and completes the given future when done. * * @param publisher the service publisher instance * @param completion the completion future * @return the current {@link ImportedConsulService} */ public ImportedConsulService register(ServicePublisher publisher, Future<ImportedConsulService> completion) { publisher.publish(record, ar -> { if (ar.succeeded()) { record.setRegistration(ar.result().getRegistration()); completion.complete(this); } else { completion.fail(ar.cause()); } }); return this; }
@Override public void close(Handler<Void> completionHandler) { List<Future> list = new ArrayList<>(); for (Record record : records) { publisher.unpublish(record.getRegistration(), v -> list.add(v.succeeded() ? Future.succeededFuture() : Future.failedFuture(v.cause()))); } CompositeFuture.all(list).setHandler(ar -> { if (ar.succeeded()) { LOGGER.info("Successfully closed the service importer " + this); } else { LOGGER.error("A failure has been caught while stopping " + this, ar.cause()); } if (completionHandler != null) { completionHandler.handle(null); } } ); }
public static void update(io.vertx.servicediscovery.spi.ServicePublisher j_receiver, java.util.Map<String, Object> record, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) { j_receiver.update(record != null ? new io.vertx.servicediscovery.Record(io.vertx.core.impl.ConversionHelper.toJsonObject(record)) : null, resultHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.servicediscovery.Record>>() { public void handle(io.vertx.core.AsyncResult<io.vertx.servicediscovery.Record> ar) { resultHandler.handle(ar.map(event -> event != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(event.toJson()) : null)); } } : null); } }
public static void publish(io.vertx.servicediscovery.spi.ServicePublisher j_receiver, java.util.Map<String, Object> record, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) { j_receiver.publish(record != null ? new io.vertx.servicediscovery.Record(io.vertx.core.impl.ConversionHelper.toJsonObject(record)) : null, resultHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.servicediscovery.Record>>() { public void handle(io.vertx.core.AsyncResult<io.vertx.servicediscovery.Record> ar) { resultHandler.handle(ar.map(event -> event != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(event.toJson()) : null)); } } : null); } public static void update(io.vertx.servicediscovery.spi.ServicePublisher j_receiver, java.util.Map<String, Object> record, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) {
private void unpublishRecord(Record record, Handler<Void> completionHandler) { publisher.unpublish(record.getRegistration(), ar -> { if (ar.failed()) { LOGGER.error("Cannot unregister kubernetes service", ar.cause()); } else { LOGGER.info("Kubernetes service unregistered from the vert.x registry: " + record.toJson()); if (completionHandler != null) { completionHandler.handle(null); } } }); }
/** * Registers the service and completes the given future when done. * * @param publisher the service publisher instance * @param completion the completion future * @return the current {@link ImportedConsulService} */ public ImportedConsulService register(ServicePublisher publisher, Future<ImportedConsulService> completion) { publisher.publish(record, ar -> { if (ar.succeeded()) { record.setRegistration(ar.result().getRegistration()); completion.complete(this); } else { completion.fail(ar.cause()); } }); return this; }
@Override public void close(Handler<Void> completionHandler) { List<Future> list = new ArrayList<>(); for (Record record : records) { publisher.unpublish(record.getRegistration(), v -> list.add(v.succeeded() ? Future.succeededFuture() : Future.failedFuture(v.cause()))); } CompositeFuture.all(list).setHandler(ar -> { if (ar.succeeded()) { LOGGER.info("Successfully closed the service importer " + this); } else { LOGGER.error("A failure has been caught while stopping " + this, ar.cause()); } if (completionHandler != null) { completionHandler.handle(null); } } ); }
private void publishRecord(Record record, Handler<AsyncResult<Record>> completionHandler) { publisher.publish(record, ar -> { if (completionHandler != null) { completionHandler.handle(ar); } if (ar.succeeded()) { LOGGER.info("Kubernetes service published in the vert.x service registry: " + record.toJson()); } else { LOGGER.error("Kubernetes service not published in the vert.x service registry", ar.cause()); } }); }
/** * Unregisters the service and completes the given future when done, if not {@code null} * * @param publiher the service publisher instance * @param completion the completion future */ public void unregister(ServicePublisher publiher, Future<Void> completion) { if (record.getRegistration() != null) { publiher.unpublish(record.getRegistration(), ar -> { if (ar.succeeded()) { record.setRegistration(null); } if (completion != null) { completion.complete(); } }); } else { if (completion != null) { completion.fail("Record not published"); } } }
publisher.publish(record, ar -> { if (ar.succeeded()) { records.add(ar.result());
/** * Unregisters the service and completes the given future when done, if not {@code null} * * @param publiher the service publisher instance * @param completion the completion future */ public void unregister(ServicePublisher publiher, Future<Void> completion) { if (record.getRegistration() != null) { publiher.unpublish(record.getRegistration(), ar -> { if (ar.succeeded()) { record.setRegistration(null); } if (completion != null) { completion.complete(); } }); } else { if (completion != null) { completion.fail("Record not published"); } } }
@Override public void start(Vertx vertx, ServicePublisher publisher, JsonObject configuration, Future<Void> future) { Record rec1 = HttpEndpoint.createRecord("static-record-1", "acme.org"); Record rec2 = HttpEndpoint.createRecord("static-record-2", "example.com"); publisher.publish(rec1, ar -> publisher.publish(rec2, ar2 -> { registered.set(true); future.complete(); })); }