Record record2 = HttpEndpoint.createRecord("some-rest-api", "localhost", 8080, "/api");
/** * Same as {@link io.vertx.rxjava.servicediscovery.types.HttpEndpoint#createRecord} but without metadata. * @param name the service name * @param host the host, must be public * @param port the port * @param root the root, if not set "/" is used * @return the created record */ public static Record createRecord(String name, String host, int port, String root) { Record ret = io.vertx.servicediscovery.types.HttpEndpoint.createRecord(name, host, port, root); return ret; }
/** * Same as {@link io.vertx.rxjava.servicediscovery.types.HttpEndpoint#createRecord} but without metadata, using the port 80 * and using "/" as root. * @param name the name * @param host the host * @return the created record */ public static Record createRecord(String name, String host) { Record ret = io.vertx.servicediscovery.types.HttpEndpoint.createRecord(name, host); return ret; }
/** * Same as {@link #createRecord(String, String, int, String, JsonObject)} but without metadata. * * @param name the service name * @param host the host, must be public * @param port the port * @param root the root, if not set "/" is used * @return the created record */ static Record createRecord(String name, String host, int port, String root) { return createRecord(name, host, port, root, null); }
/** * Same as {@link io.vertx.rxjava.servicediscovery.types.HttpEndpoint#createRecord} but without metadata. * @param name the service name * @param host the host, must be public * @param port the port * @param root the root, if not set "/" is used * @return the created record */ public static Record createRecord(String name, String host, int port, String root) { Record ret = io.vertx.servicediscovery.types.HttpEndpoint.createRecord(name, host, port, root); return ret; }
public void publishHttpEndpoint(String name, String host, int port, Handler<AsyncResult<Void>> completionHandler) { Record record = HttpEndpoint.createRecord(name, host, port, "/"); publish(record, completionHandler); }
protected Future<Void> publishHttpEndpoint(String name, String host, int port) { Record record = HttpEndpoint.createRecord(name, host, port, "/", new JsonObject().put("api.name", config().getString("api.name", "")) ); return publish(record); }
protected Single<Void> publishHttpEndpoint(String name, String host, int port) { Record record = HttpEndpoint.createRecord(name, host, port, "/", new JsonObject().put("api.name", config().getString("api.name", "")) ); return publish(record); }
private Record createRecord(final JsonObject item) { final String name = item.getString(NAME); final String host = item.getString(HOST); final Integer port = item.getInteger(PORT); final JsonObject meta = item.getJsonObject(META); return HttpEndpoint.createRecord( name, host, port, "/*", meta ); }
protected Future<Void> publishApiGateway(String host, int port) { Record record = HttpEndpoint.createRecord("api-gateway", true, host, port, "/", null) .setType("api-gateway"); return publish(record); }
public static java.util.Map<String, Object> createRecord(io.vertx.servicediscovery.types.HttpEndpoint j_receiver, java.lang.String name, java.lang.String host, int port, java.lang.String root, java.util.Map<String, Object> metadata) { return io.vertx.servicediscovery.types.HttpEndpoint.createRecord(name, host, port, root, metadata != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(metadata) : null) != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(io.vertx.servicediscovery.types.HttpEndpoint.createRecord(name, host, port, root, metadata != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(metadata) : null).toJson()) : null; } public static java.util.Map<String, Object> createRecord(io.vertx.servicediscovery.types.HttpEndpoint j_receiver, java.lang.String name, boolean ssl, java.lang.String host, int port, java.lang.String root, java.util.Map<String, Object> metadata) {
@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(); })); }
@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 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 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 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 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); }