/** * @return the service record. */ public Record record() { if (cached_0 != null) { return cached_0; } Record ret = delegate.record(); cached_0 = ret; return ret; }
/** * @return the service record. */ public Record record() { if (cached_0 != null) { return cached_0; } Record ret = delegate.record(); cached_0 = ret; return ret; }
public static java.util.Map<String, Object> record(io.vertx.servicediscovery.ServiceReference j_receiver) { return j_receiver.record() != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(j_receiver.record().toJson()) : null; } public static <T>java.lang.Object get(io.vertx.servicediscovery.ServiceReference j_receiver) {
private void sendUnbindEvent(ServiceReference reference) { if (usage == null) { return; } vertx.eventBus().publish(usage, new JsonObject() .put("type", "release") .put("record", reference.record().toJson()) .put("id", id)); }
private void sendBindEvent(ServiceReference reference) { if (usage == null) { return; } vertx.eventBus().publish(usage, new JsonObject() .put("type", "bind") .put("record", reference.record().toJson()) .put("id", id)); }
private void sendUnbindEvent(ServiceReference reference) { if (usage == null) { return; } vertx.eventBus().publish(usage, new JsonObject() .put("type", "release") .put("record", reference.record().toJson()) .put("id", id)); }
private void sendBindEvent(ServiceReference reference) { if (usage == null) { return; } vertx.eventBus().publish(usage, new JsonObject() .put("type", "bind") .put("record", reference.record().toJson()) .put("id", id)); }
@Test public void testAutoCloseable(TestContext context) { Async async = context.async(); // Publish the service Record record = HttpEndpoint.createRecord("hello-service", "localhost", 8080, "/foo"); discovery.publish(record, rec -> { Record published = rec.result(); discovery.getRecord(new JsonObject().put("name", "hello-service"), found -> { context.assertTrue(found.succeeded()); context.assertTrue(found.result() != null); Record match = found.result(); try (ServiceReference reference = discovery.getReference(match)) { context.assertEquals(reference.record().getLocation().getString("endpoint"), "http://localhost:8080/foo"); context.assertFalse(reference.record().getLocation().getBoolean("ssl")); WebClient client = reference.getAs(WebClient.class); WebClient client2 = reference.cachedAs(WebClient.class); context.assertTrue(client == client2); } catch (Exception e) { context.fail(e); } discovery.unpublish(published.getRegistration(), v -> async.complete()); }); }); }
@Test public void testAutoCloseable(TestContext context) { Async async = context.async(); // Publish the service Record record = HttpEndpoint.createRecord("hello-service", "localhost", 8080, "/foo"); discovery.publish(record, rec -> { Record published = rec.result(); discovery.getRecord(new JsonObject().put("name", "hello-service"), found -> { context.assertTrue(found.succeeded()); context.assertTrue(found.result() != null); Record match = found.result(); try (ServiceReference reference = discovery.getReference(match)) { context.assertEquals(reference.record().getLocation().getString("endpoint"), "http://localhost:8080/foo"); context.assertFalse(reference.record().getLocation().getBoolean("ssl")); WebClient client = reference.getAs(WebClient.class); WebClient client2 = reference.cachedAs(WebClient.class); context.assertTrue(client == client2); } catch (Exception e) { context.fail(e); } discovery.unpublish(published.getRegistration(), v -> async.complete()); }); }); }
Record match = found.result(); ServiceReference reference = discovery.getReference(match); context.assertEquals(reference.record().getLocation().getString("endpoint"), "http://localhost:8080/foo"); context.assertFalse(reference.record().getLocation().getBoolean("ssl")); WebClient client = reference.getAs(WebClient.class); WebClient client2 = reference.cachedAs(WebClient.class);
Record match = found.result(); ServiceReference reference = discovery.getReference(match); context.assertEquals(reference.record().getLocation().getString("endpoint"), "http://localhost:8080/foo"); context.assertFalse(reference.record().getLocation().getBoolean("ssl")); WebClient client = reference.getAs(WebClient.class); WebClient client2 = reference.cachedAs(WebClient.class);
@Test public void testPublicationAndConsumption(TestContext context) { Async async = context.async(); // Publish the service Record record = HttpEndpoint.createRecord("hello-service", "localhost", 8080, "/foo"); discovery.publish(record, rec -> { Record published = rec.result(); discovery.getRecord(new JsonObject().put("name", "hello-service"), found -> { context.assertTrue(found.succeeded()); context.assertTrue(found.result() != null); Record match = found.result(); ServiceReference reference = discovery.getReference(match); context.assertEquals(reference.record().getLocation().getString("endpoint"), "http://localhost:8080/foo"); context.assertFalse(reference.record().getLocation().getBoolean("ssl")); HttpClient client = reference.get(); HttpClient client2 = reference.get(); context.assertTrue(client == client2); client.getNow("/foo", response -> { context.assertEquals(response.statusCode(), 200); response.bodyHandler(body -> { context.assertEquals(body.toString(), "hello"); reference.release(); discovery.unpublish(published.getRegistration(), v -> { async.complete(); }); }); }); }); }); }
@Test public void testPublicationAndConsumption(TestContext context) { Async async = context.async(); // Publish the service Record record = HttpEndpoint.createRecord("hello-service", "localhost", 8080, "/foo"); discovery.publish(record, rec -> { Record published = rec.result(); discovery.getRecord(new JsonObject().put("name", "hello-service"), found -> { context.assertTrue(found.succeeded()); context.assertTrue(found.result() != null); Record match = found.result(); ServiceReference reference = discovery.getReference(match); context.assertEquals(reference.record().getLocation().getString("endpoint"), "http://localhost:8080/foo"); context.assertFalse(reference.record().getLocation().getBoolean("ssl")); HttpClient client = reference.get(); HttpClient client2 = reference.get(); context.assertTrue(client == client2); client.getNow("/foo", context.asyncAssertSuccess(response -> { context.assertEquals(response.statusCode(), 200); response.bodyHandler(body -> { context.assertEquals(body.toString(), "hello"); reference.release(); discovery.unpublish(published.getRegistration(), v -> { async.complete(); }); }); })); }); }); }