/** * Add a new check to the local agent. The agent is responsible for managing the status of the check * and keeping the Catalog in sync. * @param checkOptions options used to register new check * @param resultHandler will be called when complete * @return reference to this, for fluency */ public io.vertx.rxjava.ext.consul.ConsulClient registerCheck(CheckOptions checkOptions, Handler<AsyncResult<Void>> resultHandler) { delegate.registerCheck(checkOptions, resultHandler); return this; }
@Override public ConsulService registerCheck(CheckOptions checkOptions, Handler<AsyncResult<Void>> resultHandler) { consulClient.registerCheck(checkOptions, resultHandler); return this; }
/** * Add a new check to the local agent. The agent is responsible for managing the status of the check * and keeping the Catalog in sync. * @param checkOptions options used to register new check * @param resultHandler will be called when complete * @return reference to this, for fluency */ public io.vertx.rxjava.ext.consul.ConsulClient registerCheck(CheckOptions checkOptions, Handler<AsyncResult<Void>> resultHandler) { delegate.registerCheck(checkOptions, resultHandler); return this; }
public static io.vertx.ext.consul.ConsulClient registerCheck(io.vertx.ext.consul.ConsulClient j_receiver, java.util.Map<String, Object> checkOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> resultHandler) { io.vertx.core.impl.ConversionHelper.fromObject(j_receiver.registerCheck(checkOptions != null ? new io.vertx.ext.consul.CheckOptions(io.vertx.core.impl.ConversionHelper.toJsonObject(checkOptions)) : null, resultHandler != null ? new io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>() { public void handle(io.vertx.core.AsyncResult<java.lang.Void> ar) { resultHandler.handle(ar.map(event -> io.vertx.core.impl.ConversionHelper.fromObject(event))); } } : null)); return j_receiver; } public static io.vertx.ext.consul.ConsulClient createSessionWithOptions(io.vertx.ext.consul.ConsulClient j_receiver, java.util.Map<String, Object> options, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>> idHandler) {
@Override String createCheck(CheckOptions opts) { String id = opts.getId(); if (id == null) { id = "checkId"; opts.setId(id); } runAsync(h -> ctx.writeClient().registerCheck(opts, h)); return id; }
@Override void createCheck(TestContext tc, CheckOptions opts, Handler<String> idHandler) { String id = opts.getId() == null ? randomAlphaString(10) : opts.getId(); opts.setId(id); ctx.writeClient().registerCheck(opts, tc.asyncAssertSuccess(v -> idHandler.handle(id))); }
@Test public void bindCheckToService() { String serviceName = "serviceName"; ServiceOptions service = new ServiceOptions() .setName(serviceName) .setAddress("10.0.0.1") .setPort(8080); runAsync(h -> ctx.writeClient().registerService(service, h)); List<Service> services = getAsync(h -> ctx.writeClient().localServices(h)); Service s = services.stream().filter(i -> "serviceName".equals(i.getName())).findFirst().get(); String serviceId = s.getId(); assertEquals(s.getAddress(), "10.0.0.1"); assertEquals(s.getPort(), 8080); CheckOptions check = new CheckOptions() .setId("checkId") .setName("checkName") .setNotes("checkNotes") .setServiceId(serviceId) .setStatus(CheckStatus.PASSING) .setTtl("10s"); runAsync(h -> ctx.writeClient().registerCheck(check, h)); List<Check> checks = getAsync(h -> ctx.writeClient().localChecks(h)); Check c = checks.stream().filter(i -> "checkId".equals(i.getId())).findFirst().get(); assertEquals(c.getServiceId(), serviceId); assertEquals(c.getStatus(), CheckStatus.PASSING); assertEquals(c.getNotes(), "checkNotes"); runAsync(h -> ctx.writeClient().deregisterService(serviceId, h)); }
.setTags(Collections.singletonList("tag1")); runAsync(h -> ctx.writeClient().registerService(opts, h)); runAsync(h -> ctx.writeClient().registerCheck(new CheckOptions() .setTtl("10s") .setServiceId("serviceId") assertEquals(latch.getCount(), 1); runAsync(h -> ctx.writeClient().registerCheck(new CheckOptions() .setTtl("10s") .setServiceId("serviceId")