/** * @return the JSON representation of the current * {@link SchemaReferenceData}. */ public JsonObject toJson() { return new JsonObject() .put("id", id) .put("record", record.toJson()) .put("type", Status.RELEASED.equals(status) ? "release" : "bind"); }
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 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)); }
@Override public void update(Record record, Handler<AsyncResult<Void>> resultHandler) { Objects.requireNonNull(record.getRegistration(), "No registration id in the record"); redis.hset(key, record.getRegistration(), record.toJson().encode(), ar -> { if (ar.succeeded()) { resultHandler.handle(Future.succeededFuture()); } else { resultHandler.handle(Future.failedFuture(ar.cause())); } }); }
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 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); } } }); }
public static java.util.Map<String, Object> createRecord(io.vertx.servicediscovery.types.MessageSource j_receiver, java.lang.String name, java.lang.String address, java.lang.String type) { return io.vertx.servicediscovery.types.MessageSource.createRecord(name, address, type) != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(io.vertx.servicediscovery.types.MessageSource.createRecord(name, address, type).toJson()) : null; } public static java.util.Map<String, Object> createRecord(io.vertx.servicediscovery.types.MessageSource j_receiver, java.lang.String name, java.lang.String address) {
public static java.util.Map<String, Object> createRecord(io.vertx.servicediscovery.types.EventBusService j_receiver, java.lang.String name, java.lang.String address, java.lang.String classname) { return io.vertx.servicediscovery.types.EventBusService.createRecord(name, address, classname) != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(io.vertx.servicediscovery.types.EventBusService.createRecord(name, address, classname).toJson()) : null; } }
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) { return io.vertx.servicediscovery.types.HttpEndpoint.createRecord(name, host, port, root) != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(io.vertx.servicediscovery.types.HttpEndpoint.createRecord(name, host, port, root).toJson()) : null; } public static java.util.Map<String, Object> createRecord(io.vertx.servicediscovery.types.HttpEndpoint j_receiver, java.lang.String name, java.lang.String host) {
public static java.util.Map<String, Object> createRecord(io.vertx.servicediscovery.types.HttpEndpoint j_receiver, java.lang.String name, java.lang.String host) { return io.vertx.servicediscovery.types.HttpEndpoint.createRecord(name, host) != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(io.vertx.servicediscovery.types.HttpEndpoint.createRecord(name, host).toJson()) : null; } public static void getClient(io.vertx.servicediscovery.types.HttpEndpoint j_receiver, io.vertx.servicediscovery.ServiceDiscovery discovery, java.util.Map<String, Object> filter, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.core.http.HttpClient>> resultHandler) {
public static java.util.Map<String, Object> createRecord(io.vertx.servicediscovery.types.MessageSource j_receiver, java.lang.String name, java.lang.String address) { return io.vertx.servicediscovery.types.MessageSource.createRecord(name, address) != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(io.vertx.servicediscovery.types.MessageSource.createRecord(name, address).toJson()) : null; } public static <T>void getConsumer(io.vertx.servicediscovery.types.MessageSource j_receiver, io.vertx.servicediscovery.ServiceDiscovery discovery, java.util.Map<String, Object> filter, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.core.eventbus.MessageConsumer<java.lang.Object>>> resultHandler) {
public static java.util.Map<String, Object> createRecord(io.vertx.servicediscovery.types.EventBusService j_receiver, java.lang.String name, java.lang.String address, java.lang.String itf, java.util.Map<String, Object> metadata) { return io.vertx.servicediscovery.types.EventBusService.createRecord(name, address, itf, metadata != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(metadata) : null) != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(io.vertx.servicediscovery.types.EventBusService.createRecord(name, address, itf, metadata != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(metadata) : null).toJson()) : null; } public static <T>java.lang.Object getServiceProxy(io.vertx.servicediscovery.types.EventBusService j_receiver, io.vertx.servicediscovery.ServiceDiscovery discovery, java.util.function.Function<java.util.Map<String, Object>, java.lang.Boolean> filter, java.lang.Class<java.lang.Object> clientClass, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Object>> resultHandler) {
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) {
public static java.util.Map<String, Object> createRecord(io.vertx.servicediscovery.types.MessageSource j_receiver, java.lang.String name, java.lang.String address, java.lang.String type, java.util.Map<String, Object> metadata) { return io.vertx.servicediscovery.types.MessageSource.createRecord(name, address, type, metadata != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(metadata) : null) != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(io.vertx.servicediscovery.types.MessageSource.createRecord(name, address, type, metadata != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(metadata) : null).toJson()) : null; } public static java.util.Map<String, Object> createRecord(io.vertx.servicediscovery.types.MessageSource j_receiver, java.lang.String name, java.lang.String address, java.lang.String type) {
public static java.util.Map<String, Object> createRecord(io.vertx.servicediscovery.types.RedisDataSource j_receiver, java.lang.String name, java.util.Map<String, Object> location, java.util.Map<String, Object> metadata) { return io.vertx.servicediscovery.types.RedisDataSource.createRecord(name, location != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(location) : null, metadata != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(metadata) : null) != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(io.vertx.servicediscovery.types.RedisDataSource.createRecord(name, location != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(location) : null, metadata != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(metadata) : null).toJson()) : null; } public static void getRedisClient(io.vertx.servicediscovery.types.RedisDataSource j_receiver, io.vertx.servicediscovery.ServiceDiscovery discovery, java.util.Map<String, Object> filter, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.redis.RedisClient>> resultHandler) {
public static java.util.Map<String, Object> createRecord(io.vertx.servicediscovery.types.JDBCDataSource j_receiver, java.lang.String name, java.util.Map<String, Object> location, java.util.Map<String, Object> metadata) { return io.vertx.servicediscovery.types.JDBCDataSource.createRecord(name, location != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(location) : null, metadata != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(metadata) : null) != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(io.vertx.servicediscovery.types.JDBCDataSource.createRecord(name, location != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(location) : null, metadata != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(metadata) : null).toJson()) : null; } public static void getJDBCClient(io.vertx.servicediscovery.types.JDBCDataSource j_receiver, io.vertx.servicediscovery.ServiceDiscovery discovery, java.util.Map<String, Object> filter, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.jdbc.JDBCClient>> resultHandler) {
public static java.util.Map<String, Object> createRecord(io.vertx.servicediscovery.types.MongoDataSource j_receiver, java.lang.String name, java.util.Map<String, Object> location, java.util.Map<String, Object> metadata) { return io.vertx.servicediscovery.types.MongoDataSource.createRecord(name, location != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(location) : null, metadata != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(metadata) : null) != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(io.vertx.servicediscovery.types.MongoDataSource.createRecord(name, location != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(location) : null, metadata != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(metadata) : null).toJson()) : null; } public static void getMongoClient(io.vertx.servicediscovery.types.MongoDataSource j_receiver, io.vertx.servicediscovery.ServiceDiscovery discovery, java.util.Map<String, Object> filter, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.mongo.MongoClient>> resultHandler) {
@Test public void testFailedPublication() { HelloService svc = new HelloServiceImpl("stuff"); ProxyHelper.registerService(HelloService.class, vertx, svc, "address"); Record record = new Record() .setName("Hello") .setRegistration("this-is-not-allowed") .setLocation(new JsonObject().put(Record.ENDPOINT, "address")); Restafari.Response response = given().request().body(record.toJson().toString()).post("/discovery"); assertThat(response.getStatusCode()).isEqualTo(500); }
@Test public void testFailedPublication() { HelloService svc = new HelloServiceImpl("stuff"); ProxyHelper.registerService(HelloService.class, vertx, svc, "address"); Record record = new Record() .setName("Hello") .setRegistration("this-is-not-allowed") .setLocation(new JsonObject().put(Record.ENDPOINT, "address")); Restafari.Response response = given().request().body(record.toJson().toString()).post("/discovery"); assertThat(response.getStatusCode()).isEqualTo(500); }