@Override public void start() { Router router = Router.router(vertx); router.get("/").handler(this::invoke); // Retrieve the service discovery ServiceDiscovery.create(vertx, discovery -> // Retrieve a web client HttpEndpoint.getWebClient(discovery, svc -> svc.getName().equals("vertx-greeting"), ar -> { if (ar.failed()) { System.out.println("D'oh the service is not available"); } else { client = ar.result(); vertx.createHttpServer().requestHandler(router).listen(8080); } })); }
Record record2 = HttpEndpoint.createRecord("some-rest-api", "localhost", 8080, "/api");
/** * Same as {@link io.vertx.rxjava.servicediscovery.types.MessageSource#createRecord} without additional metadata, and no type for * the payload. * @param name the name of the service * @param address the address on which the data is sent. * @return the created record */ public static Record createRecord(String name, String address) { Record ret = io.vertx.servicediscovery.types.MessageSource.createRecord(name, address); return ret; }
/** * Creates a record based on the parameters. * @param name the service name * @param address the address * @param classname the payload class * @return the record */ public static Record createRecord(String name, String address, String classname) { Record ret = io.vertx.servicediscovery.types.EventBusService.createRecord(name, address, classname); return ret; }
/** * Convenient method to create a record for a Redis data source. * @param name the service name * @param location the location of the service (e.g. url, port...) * @param metadata additional metadata * @return the created record */ public static Record createRecord(String name, JsonObject location, JsonObject metadata) { Record ret = io.vertx.servicediscovery.types.RedisDataSource.createRecord(name, location, metadata); return ret; }
/** * Convenient method to create a record for a Mongo data source. * @param name the service name * @param location the location of the service (e.g. url, port...) * @param metadata additional metadata * @return the created record */ public static Record createRecord(String name, JsonObject location, JsonObject metadata) { Record ret = io.vertx.servicediscovery.types.MongoDataSource.createRecord(name, location, metadata); return ret; }
/** * Sets the host. * * @param host the host * @return the current {@link HttpLocation} */ public HttpLocation setHost(String host) { this.host = host; updateLocation(); return this; }
/** * Creates a new {@link HttpLocation} from the given json object * * @param json the json object */ public HttpLocation(JsonObject json) { this(); HttpLocationConverter.fromJson(json, this); }
/** * 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; }
/** * Create a record representing a data producer. * @param name the name of the service * @param address the address on which the data is sent * @param type the type of payload (fully qualified name of the class) * @param metadata additional metadata * @return the created record */ public static Record createRecord(String name, String address, String type, JsonObject metadata) { Record ret = io.vertx.servicediscovery.types.MessageSource.createRecord(name, address, type, metadata); return ret; }
/** * Creates a record based on the parameters. * * @param name the service name * @param address the address * @param classname the payload class * @return the record */ static Record createRecord(String name, String address, String classname) { return createRecord(name, address, classname, null); } }
/** * Sets whether or not the HTTP service is using {@code https}. * * @param ssl {@code true} to denotes that the service use {@code https} * @return the current {@link HttpLocation} */ public HttpLocation setSsl(boolean ssl) { this.ssl = ssl; updateLocation(); return this; }
/** * 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 io.vertx.rxjava.servicediscovery.types.MessageSource#createRecord} without additional metadata. * @param name the name of the service * @param address the address on which the data is sent * @param type the type of payload * @return the created record */ public static Record createRecord(String name, String address, String type) { Record ret = io.vertx.servicediscovery.types.MessageSource.createRecord(name, address, type); return ret; }
/** * Sets the port * * @param port the port * @return the current {@link HttpLocation} */ public HttpLocation setPort(int port) { this.port = port; updateLocation(); return this; }
/** * 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); }
/** * Create a record representing a data producer. * @param name the name of the service * @param address the address on which the data is sent * @param type the type of payload (fully qualified name of the class) * @param metadata additional metadata * @return the created record */ public static Record createRecord(String name, String address, String type, JsonObject metadata) { Record ret = io.vertx.servicediscovery.types.MessageSource.createRecord(name, address, type, metadata); return ret; }
/** * Same as {@link #createRecord(String, String, Class, JsonObject)} without additional metadata, and no type for * the payload. * * @param name the name of the service * @param address the address on which the data is sent. * @return the created record */ static Record createRecord(String name, String address) { return createRecord(name, address, (String) null); }
/** * Same as {@link #createRecord(String, String, String, JsonObject)} without additional metadata. * * @param name the name of the service * @param address the address on which the data is sent * @param type the type of payload * @return the created record */ static Record createRecord(String name, String address, String type) { return createRecord(name, address, type, null); }