当前位置: 首页>>代码示例>>Java>>正文


Java ConsulClient类代码示例

本文整理汇总了Java中io.vertx.ext.consul.ConsulClient的典型用法代码示例。如果您正苦于以下问题:Java ConsulClient类的具体用法?Java ConsulClient怎么用?Java ConsulClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ConsulClient类属于io.vertx.ext.consul包,在下文中一共展示了ConsulClient类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import io.vertx.ext.consul.ConsulClient; //导入依赖的package包/类
@Before
public void setUp(TestContext tc) throws Exception {
  vertx = Vertx.vertx();
  vertx.exceptionHandler(tc.exceptionHandler());

  client = ConsulClient.create(vertx, new ConsulClientOptions().setPort(consulProcess.getHttpPort()));
}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:8,代码来源:ConsulConfigStoreTest.java

示例2: createQuery

import io.vertx.ext.consul.ConsulClient; //导入依赖的package包/类
public void createQuery(ConsulClient consulClient, PreparedQueryDefinition def) {

    consulClient.createPreparedQuery(def, res -> {
      if (res.succeeded()) {
        String queryId = res.result();
        System.out.println("Query created: " + queryId);
      } else {
        res.cause().printStackTrace();
      }
    });

  }
 
开发者ID:vert-x3,项目名称:vertx-consul-client,代码行数:13,代码来源:PreparedQueries.java

示例3: executeQuery

import io.vertx.ext.consul.ConsulClient; //导入依赖的package包/类
public void executeQuery(ConsulClient consulClient) {

    consulClient.executePreparedQuery("find_1_2", res -> {
      // matches template regexp "^find_(.+?)_(.+?)$"
      if (res.succeeded()) {
        PreparedQueryExecuteResponse response = res.result();
        System.out.println("Found " + response.getNodes().size() + " nodes");
      } else {
        res.cause().printStackTrace();
      }
    });

  }
 
开发者ID:vert-x3,项目名称:vertx-consul-client,代码行数:14,代码来源:PreparedQueries.java

示例4: executeQueryId

import io.vertx.ext.consul.ConsulClient; //导入依赖的package包/类
public void executeQueryId(ConsulClient consulClient, String id) {

    consulClient.executePreparedQuery(id, res -> {
      if (res.succeeded()) {
        PreparedQueryExecuteResponse response = res.result();
        System.out.println("Found " + response.getNodes().size() + " nodes");
      } else {
        res.cause().printStackTrace();
      }
    });

  }
 
开发者ID:vert-x3,项目名称:vertx-consul-client,代码行数:13,代码来源:PreparedQueries.java

示例5: deleteQuery

import io.vertx.ext.consul.ConsulClient; //导入依赖的package包/类
public void deleteQuery(ConsulClient consulClient, String query) {

    consulClient.deletePreparedQuery(query, res -> {
      if (res.succeeded()) {
        System.out.println("Query deleted");
      } else {
        res.cause().printStackTrace();
      }
    });

  }
 
开发者ID:vert-x3,项目名称:vertx-consul-client,代码行数:12,代码来源:PreparedQueries.java

示例6: tcpHealth

import io.vertx.ext.consul.ConsulClient; //导入依赖的package包/类
public void tcpHealth(ConsulClient consulClient, CheckOptions opts) {

    consulClient.registerCheck(opts, res -> {
      if (res.succeeded()) {
        System.out.println("check successfully registered");
      } else {
        res.cause().printStackTrace();
      }
    });

  }
 
开发者ID:vert-x3,项目名称:vertx-consul-client,代码行数:12,代码来源:Health.java

示例7: catalogNodes

import io.vertx.ext.consul.ConsulClient; //导入依赖的package包/类
public void catalogNodes(ConsulClient consulClient) {

    consulClient.catalogNodes(res -> {
      if (res.succeeded()) {
        System.out.println("found " + res.result().getList().size() + " nodes");
        System.out.println("consul state index " + res.result().getIndex());
      } else {
        res.cause().printStackTrace();
      }
    });

  }
 
开发者ID:vert-x3,项目名称:vertx-consul-client,代码行数:13,代码来源:Nodes.java

示例8: blockingQuery

import io.vertx.ext.consul.ConsulClient; //导入依赖的package包/类
public void blockingQuery(ConsulClient consulClient, long lastIndex) {

    NodeQueryOptions opts = new NodeQueryOptions()
      .setNear("_agent")
      .setBlockingOptions(new BlockingQueryOptions().setIndex(lastIndex));

    consulClient.catalogNodesWithOptions(opts, res -> {
      if (res.succeeded()) {
        System.out.println("found " + res.result().getList().size() + " nodes");
      } else {
        res.cause().printStackTrace();
      }
    });

  }
 
开发者ID:vert-x3,项目名称:vertx-consul-client,代码行数:16,代码来源:Nodes.java

示例9: go

import io.vertx.ext.consul.ConsulClient; //导入依赖的package包/类
private void go(TestContext tc, boolean trustAll, PemTrustOptions trustOptions) {
  ConsulClient secureClient = ctx.createSecureClient(trustAll, trustOptions);
  secureClient.putValue("foo/bars42", "value42", tc.asyncAssertSuccess(b -> {
    tc.assertTrue(b);
    secureClient.getValue("foo/bars42", tc.asyncAssertSuccess(pair -> {
      tc.assertEquals(pair.getValue(), "value42");
      ctx.closeClient(secureClient);
    }));
  }));
}
 
开发者ID:vert-x3,项目名称:vertx-consul-client,代码行数:11,代码来源:SecureClient.java

示例10: timeout

import io.vertx.ext.consul.ConsulClient; //导入依赖的package包/类
@Test
public void timeout(TestContext tc) {
  SlowHttpServer slowConsul = new SlowHttpServer(vertx, 10000);
  ConsulClient client = ctx.createClient(new ConsulClientOptions().setPort(slowConsul.port()).setTimeout(1000));
  client.agentInfo(tc.asyncAssertFailure(t -> {
    ctx.closeClient(client);
    slowConsul.close();
    tc.assertTrue(t.getMessage().contains("The timeout period of 1000ms"));
  }));
}
 
开发者ID:vert-x3,项目名称:vertx-consul-client,代码行数:11,代码来源:BrokenConsul.java

示例11: closedConnection

import io.vertx.ext.consul.ConsulClient; //导入依赖的package包/类
@Test
public void closedConnection(TestContext tc) {
  BrokenHttpServer brokenConsul = new BrokenHttpServer(vertx);
  ConsulClient client = ctx.createClient(new ConsulClientOptions().setPort(brokenConsul.port()));
  client.agentInfo(tc.asyncAssertFailure(t -> {
    ctx.closeClient(client);
    brokenConsul.close();
    tc.assertTrue(t.getMessage().contains("Connection was closed"));
  }));
}
 
开发者ID:vert-x3,项目名称:vertx-consul-client,代码行数:11,代码来源:BrokenConsul.java

示例12: init

import io.vertx.ext.consul.ConsulClient; //导入依赖的package包/类
@Override
public void init(Vertx vertx, JsonObject config) {
  ConsulClientOptions opt = new ConsulClientOptions(config);
  this.client = ConsulClient.create(vertx, opt);
}
 
开发者ID:vert-x3,项目名称:vertx-service-discovery,代码行数:6,代码来源:ConsulBackendService.java

示例13: ConsulConfigStore

import io.vertx.ext.consul.ConsulClient; //导入依赖的package包/类
ConsulConfigStore(Vertx vertx, JsonObject configuration) {
  client = ConsulClient.create(vertx, new ConsulClientOptions(configuration));
  delimiter = configuration.getString("delimiter", "/");
  prefix = prefix(configuration.getString("prefix"), delimiter);
}
 
开发者ID:vert-x3,项目名称:vertx-config,代码行数:6,代码来源:ConsulConfigStore.java

示例14: tryClient

import io.vertx.ext.consul.ConsulClient; //导入依赖的package包/类
private void tryClient(TestContext tc, ConsulClient client, String expectedExceptionMessageSubstring) {
  client.agentInfo(tc.asyncAssertFailure(t -> {
    tc.assertTrue(t.getMessage().contains(expectedExceptionMessageSubstring));
    ctx.closeClient(client);
  }));
}
 
开发者ID:vert-x3,项目名称:vertx-consul-client,代码行数:7,代码来源:BrokenClient.java


注:本文中的io.vertx.ext.consul.ConsulClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。