discovery.getRecord(r -> r.getName().equals(record2.getName()), ar -> { if (ar.succeeded()) { if (ar.result() != null) {
/** * {@inheritDoc} */ @Override public void getRecord(JsonObject filter, Handler<AsyncResult<Record>> resultHandler) { unmanagedDiscoveryInstance.getRecord(filter, resultHandler); }
/** * {@inheritDoc} */ @Override public void getRecord(Function<Record, Boolean> filter, boolean includeOutOfService, Handler<AsyncResult<Record>> resultHandler) { unmanagedDiscoveryInstance.getRecord(filter, includeOutOfService, resultHandler); }
/** * {@inheritDoc} */ @Override public void getRecord(Function<Record, Boolean> filter, Handler<AsyncResult<Record>> resultHandler) { unmanagedDiscoveryInstance.getRecord(filter, resultHandler); }
/** * Lookups for a single record. * <p> * The filter is a taking a {@link io.vertx.servicediscovery.Record} as argument and returning a boolean. You should see it * as an <code>accept</code> method of a filter. This method return a record passing the filter. * <p> * This method only looks for records with a <code>UP</code> status. * @param filter the filter, must not be <code>null</code>. To return all records, use a function accepting all records * @param resultHandler the result handler called when the lookup has been completed. When there are no matching record, the operation succeed, but the async result has no result. */ public void getRecord(Function<Record, Boolean> filter, Handler<AsyncResult<Record>> resultHandler) { delegate.getRecord(filter, resultHandler); }
/** * Lookups for a single record. * <p> * The filter is a taking a {@link io.vertx.servicediscovery.Record} as argument and returning a boolean. You should see it * as an <code>accept</code> method of a filter. This method return a record passing the filter. * <p> * This method only looks for records with a <code>UP</code> status. * @param filter the filter, must not be <code>null</code>. To return all records, use a function accepting all records * @param resultHandler the result handler called when the lookup has been completed. When there are no matching record, the operation succeed, but the async result has no result. */ public void getRecord(Function<Record, Boolean> filter, Handler<AsyncResult<Record>> resultHandler) { delegate.getRecord(filter, resultHandler); }
public void lookupByJson(JsonObject jsonFilter, Handler<AsyncResult<Record>> handler) { serviceDiscovery.getRecord(jsonFilter, handler); }
public static void getRecord(io.vertx.servicediscovery.ServiceDiscovery j_receiver, java.util.function.Function<java.util.Map<String, Object>, java.lang.Boolean> filter, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) { j_receiver.getRecord(filter != null ? new java.util.function.Function<io.vertx.servicediscovery.Record, java.lang.Boolean>() { public java.lang.Boolean apply(io.vertx.servicediscovery.Record t) { java.util.Map<String, Object> o = t != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(t.toJson()) : null; java.lang.Boolean p = filter.apply(o); return p; } } : 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.function.Function<java.util.Map<String, Object>, java.lang.Boolean> filter, boolean includeOutOfService, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) {
/** * Lookups for a single record. * <p> * The filter is a taking a {@link io.vertx.servicediscovery.Record} as argument and returning a boolean. You should see it * as an <code>accept</code> method of a filter. This method return a record passing the filter. * <p> * Unlike {@link io.vertx.rxjava.servicediscovery.ServiceDiscovery#getRecord}, this method may accept records with a <code>OUT OF SERVICE</code> * status, if the <code>includeOutOfService</code> parameter is set to <code>true</code>. * @param filter the filter, must not be <code>null</code>. To return all records, use a function accepting all records * @param includeOutOfService whether or not the filter accepts <code>OUT OF SERVICE</code> records * @param resultHandler the result handler called when the lookup has been completed. When there are no matching record, the operation succeed, but the async result has no result. */ public void getRecord(Function<Record, Boolean> filter, boolean includeOutOfService, Handler<AsyncResult<Record>> resultHandler) { delegate.getRecord(filter, includeOutOfService, resultHandler); }
/** * Lookups for a single record. * <p> * The filter is a taking a {@link io.vertx.servicediscovery.Record} as argument and returning a boolean. You should see it * as an <code>accept</code> method of a filter. This method return a record passing the filter. * <p> * Unlike {@link io.vertx.rxjava.servicediscovery.ServiceDiscovery#getRecord}, this method may accept records with a <code>OUT OF SERVICE</code> * status, if the <code>includeOutOfService</code> parameter is set to <code>true</code>. * @param filter the filter, must not be <code>null</code>. To return all records, use a function accepting all records * @param includeOutOfService whether or not the filter accepts <code>OUT OF SERVICE</code> records * @param resultHandler the result handler called when the lookup has been completed. When there are no matching record, the operation succeed, but the async result has no result. */ public void getRecord(Function<Record, Boolean> filter, boolean includeOutOfService, Handler<AsyncResult<Record>> resultHandler) { delegate.getRecord(filter, includeOutOfService, resultHandler); }
public static void getRecord(io.vertx.servicediscovery.ServiceDiscovery j_receiver, java.util.function.Function<java.util.Map<String, Object>, java.lang.Boolean> filter, boolean includeOutOfService, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) { j_receiver.getRecord(filter != null ? new java.util.function.Function<io.vertx.servicediscovery.Record, java.lang.Boolean>() { public java.lang.Boolean apply(io.vertx.servicediscovery.Record t) { java.util.Map<String, Object> o = t != null ? io.vertx.core.impl.ConversionHelper.fromJsonObject(t.toJson()) : null; java.lang.Boolean p = filter.apply(o); return p; } } : null, includeOutOfService, 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 getRecords(io.vertx.servicediscovery.ServiceDiscovery j_receiver, java.util.Map<String, Object> filter, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<java.util.Map<String, Object>>>> resultHandler) {
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) { j_receiver.getRecord(filter != null ? io.vertx.core.impl.ConversionHelper.toJsonObject(filter) : 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.function.Function<java.util.Map<String, Object>, java.lang.Boolean> filter, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<String, Object>>> resultHandler) {
private void lookup(Function<Record, Boolean> filter, boolean includeOutOfService, Handler<AsyncResult<Record>> handler) { if (isNull(filter)) throw new InvalidFilterException(); serviceDiscovery.getRecord(filter, includeOutOfService, handler); }
/** * Convenient method that looks for a HTTP endpoint and provides the configured {@link HttpClient}. The async result * is marked as failed is there are no matching services, or if the lookup fails. * * @param discovery The service discovery instance * @param filter The filter * @param resultHandler The result handler */ static void getClient(ServiceDiscovery discovery, Function<Record, Boolean> filter, Handler<AsyncResult<HttpClient>> resultHandler) { discovery.getRecord(filter, ar -> { if (ar.failed() || ar.result() == null) { resultHandler.handle(Future.failedFuture("No matching record")); } else { resultHandler.handle(Future.succeededFuture(discovery.<HttpClient>getReference(ar.result()).get())); } }); }
/** * Convenient method that looks for a HTTP endpoint and provides the configured {@link WebClient}. The async result * is marked as failed is there are no matching services, or if the lookup fails. * * @param discovery The service discovery instance * @param filter The filter * @param resultHandler The result handler */ static void getWebClient(ServiceDiscovery discovery, Function<Record, Boolean> filter, Handler<AsyncResult<WebClient>> resultHandler) { discovery.getRecord(filter, ar -> { if (ar.failed() || ar.result() == null) { resultHandler.handle(Future.failedFuture("No matching record")); } else { resultHandler.handle(Future.succeededFuture(discovery.<HttpClient>getReference(ar.result()).getAs(WebClient.class))); } }); }
/** * Convenient method that looks for a JDBC datasource source and provides the configured {@link io.vertx.ext.jdbc.JDBCClient}. The * async result is marked as failed is there are no matching services, or if the lookup fails. * * @param discovery The service discovery instance * @param filter The filter (must not be {@code null}) * @param resultHandler The result handler */ static void getJDBCClient(ServiceDiscovery discovery, Function<Record, Boolean> filter, Handler<AsyncResult<JDBCClient>> resultHandler) { discovery.getRecord(filter, ar -> { if (ar.failed() || ar.result() == null) { resultHandler.handle(Future.failedFuture("No matching record")); } else { resultHandler.handle(Future.succeededFuture(discovery.<JDBCClient>getReference(ar.result()).get())); } }); }
/** * Convenient method that looks for a Redis data source and provides the configured {@link io.vertx.redis.RedisClient}. * The async result is marked as failed is there are no matching services, or if the lookup fails. * * @param discovery The service discovery instance * @param filter The filter, cannot be {@code null} * @param resultHandler The result handler */ static void getRedisClient(ServiceDiscovery discovery, Function<Record, Boolean> filter, Handler<AsyncResult<RedisClient>> resultHandler) { discovery.getRecord(filter, ar -> { if (ar.failed() || ar.result() == null) { resultHandler.handle(Future.failedFuture("No matching record")); } else { resultHandler.handle(Future.succeededFuture(discovery.<RedisClient>getReference(ar.result()).get())); } }); }
/** * Convenient method that looks for a HTTP endpoint and provides the configured {@linkWebClient}. The async result * is marked as failed is there are no matching services, or if the lookup fails. * * @param discovery The service discovery instance * @param filter The filter, optional * @param resultHandler The result handler */ static void getWebClient(ServiceDiscovery discovery, JsonObject filter, Handler<AsyncResult<WebClient>> resultHandler) { discovery.getRecord(filter, ar -> { if (ar.failed() || ar.result() == null) { resultHandler.handle(Future.failedFuture("No matching record")); } else { resultHandler.handle(Future.succeededFuture(discovery.<HttpClient>getReference(ar.result()).getAs(WebClient.class))); } }); }
private void one(RoutingContext routingContext) { discovery.getRecord(new JsonObject().put("registration", routingContext.request().getParam("uuid")), ar -> { if (ar.failed()) { routingContext.fail(ar.cause()); } else { if (ar.result() == null) { routingContext.response().setStatusCode(404).end(); } else { routingContext.response().setStatusCode(200) .putHeader("Content-Type", "application/json") .end(ar.result().toJson().toString()); } } }); }
private void one(RoutingContext routingContext) { discovery.getRecord(new JsonObject().put("registration", routingContext.request().getParam("uuid")), ar -> { if (ar.failed()) { routingContext.fail(ar.cause()); } else { if (ar.result() == null) { routingContext.response().setStatusCode(404).end(); } else { routingContext.response().setStatusCode(200) .putHeader("Content-Type", "application/json") .end(ar.result().toJson().toString()); } } }); }