/** * 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); }
/** * 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); }
/** * {@inheritDoc} */ @Override public void publish(Record record, Handler<AsyncResult<Record>> resultHandler) { unmanagedDiscoveryInstance.publish(record, resultHandler); }
public void publish(EventBusServiceConfiguration configuration, Handler<AsyncResult<Record>> handler) { serviceDiscovery.publish(createEventBusRecord(configuration), handler); }
public void publish(DataSourceServiceConfiguration configuration, Handler<AsyncResult<Record>> handler) { serviceDiscovery.publish(createJDBCRecord(configuration), handler); }
public static void publish(io.vertx.servicediscovery.ServiceDiscovery 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 getRecord(io.vertx.servicediscovery.ServiceDiscovery j_receiver, java.util.Map<String, Object> filter, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) {
private void publish(RoutingContext routingContext) { JsonObject json = routingContext.getBodyAsJson(); Record record = new Record(json); discovery.publish(record, ar -> { if (ar.failed()) { routingContext.fail(ar.cause()); } else { routingContext.response().setStatusCode(201) .putHeader("Content-Type", "application/json") .end(ar.result().toJson().toString()); } }); }
private void publish(RoutingContext routingContext) { JsonObject json = routingContext.getBodyAsJson(); Record record = new Record(json); discovery.publish(record, ar -> { if (ar.failed()) { routingContext.fail(ar.cause()); } else { routingContext.response().setStatusCode(201) .putHeader("Content-Type", "application/json") .end(ar.result().toJson().toString()); } }); }
@Test public void testPublicationWithoutStatus() { AtomicReference<Record> ref = new AtomicReference<>(); Record record = HttpEndpoint.createRecord("some-service", "localhost"); discovery.publish(record, ar -> { ref.set(ar.result()); }); await().untilAtomic(ref, is(notNullValue())); assertThat(ref.get().getRegistration()).isNotNull(); assertThat(ref.get().getStatus()).isEqualTo(Status.UP); }
@Test public void testPublicationWithoutStatus() { AtomicReference<Record> ref = new AtomicReference<>(); Record record = HttpEndpoint.createRecord("some-service", "localhost"); discovery.publish(record, ar -> { ref.set(ar.result()); }); await().untilAtomic(ref, is(notNullValue())); assertThat(ref.get().getRegistration()).isNotNull(); assertThat(ref.get().getStatus()).isEqualTo(Status.UP); }
@Test public void testPublicationWithStatusOutOfService() { AtomicReference<Record> ref = new AtomicReference<>(); Record record = HttpEndpoint.createRecord("some-service", "localhost").setStatus(Status.OUT_OF_SERVICE); discovery.publish(record, ar -> { ref.set(ar.result()); }); await().untilAtomic(ref, is(notNullValue())); assertThat(ref.get().getRegistration()).isNotNull(); assertThat(ref.get().getStatus()).isEqualTo(Status.OUT_OF_SERVICE); }
@Test public void testPublicationWithStatusUp() { AtomicReference<Record> ref = new AtomicReference<>(); Record record = HttpEndpoint.createRecord("some-service", "localhost").setStatus(Status.UP); discovery.publish(record, ar -> { ref.set(ar.result()); }); await().untilAtomic(ref, is(notNullValue())); assertThat(ref.get().getRegistration()).isNotNull(); assertThat(ref.get().getStatus()).isEqualTo(Status.UP); }
@Test public void testPublicationWithStatusUnknown() { AtomicReference<Record> ref = new AtomicReference<>(); Record record = HttpEndpoint.createRecord("some-service", "localhost").setStatus(Status.UNKNOWN); discovery.publish(record, ar -> { ref.set(ar.result()); }); await().untilAtomic(ref, is(notNullValue())); assertThat(ref.get().getRegistration()).isNotNull(); assertThat(ref.get().getStatus()).isEqualTo(Status.UP); }
@Test public void testPublicationWithStatusDown() { AtomicReference<Record> ref = new AtomicReference<>(); Record record = HttpEndpoint.createRecord("some-service", "localhost").setStatus(Status.DOWN); discovery.publish(record, ar -> { ref.set(ar.result()); }); await().untilAtomic(ref, is(notNullValue())); assertThat(ref.get().getRegistration()).isNotNull(); assertThat(ref.get().getStatus()).isEqualTo(Status.DOWN); }
@Test public void testPublicationWithStatusUp() { AtomicReference<Record> ref = new AtomicReference<>(); Record record = HttpEndpoint.createRecord("some-service", "localhost").setStatus(Status.UP); discovery.publish(record, ar -> { ref.set(ar.result()); }); await().untilAtomic(ref, is(notNullValue())); assertThat(ref.get().getRegistration()).isNotNull(); assertThat(ref.get().getStatus()).isEqualTo(Status.UP); }
@Test public void testPublicationWithStatusDown() { AtomicReference<Record> ref = new AtomicReference<>(); Record record = HttpEndpoint.createRecord("some-service", "localhost").setStatus(Status.DOWN); discovery.publish(record, ar -> { ref.set(ar.result()); }); await().untilAtomic(ref, is(notNullValue())); assertThat(ref.get().getRegistration()).isNotNull(); assertThat(ref.get().getStatus()).isEqualTo(Status.DOWN); }
@Test public void testPublicationWithStatusUnknown() { AtomicReference<Record> ref = new AtomicReference<>(); Record record = HttpEndpoint.createRecord("some-service", "localhost").setStatus(Status.UNKNOWN); discovery.publish(record, ar -> { ref.set(ar.result()); }); await().untilAtomic(ref, is(notNullValue())); assertThat(ref.get().getRegistration()).isNotNull(); assertThat(ref.get().getStatus()).isEqualTo(Status.UP); }
@Test public void testPublicationWithStatusOutOfService() { AtomicReference<Record> ref = new AtomicReference<>(); Record record = HttpEndpoint.createRecord("some-service", "localhost").setStatus(Status.OUT_OF_SERVICE); discovery.publish(record, ar -> { ref.set(ar.result()); }); await().untilAtomic(ref, is(notNullValue())); assertThat(ref.get().getRegistration()).isNotNull(); assertThat(ref.get().getStatus()).isEqualTo(Status.OUT_OF_SERVICE); }
@Test public void testServiceAvailability_OK() { ServiceDiscovery discovery = ServiceDiscovery.create(vertx); AtomicBoolean done = new AtomicBoolean(); discovery.publish(HttpEndpoint.createRecord("my-service", "localhost"), ar -> { done.set(ar.succeeded()); }); await().untilAtomic(done, is(true)); registerServiceProcedure(discovery); get(200); }