• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java HttpEndpoint类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: addWeightService

import io.vertx.servicediscovery.types.HttpEndpoint; //导入依赖的package包/类
private void addWeightService(AtomicInteger seq) {
  discovery.publish(HttpEndpoint.createRecord(service, "localhost", 8081, "/"),
                    ar -> {
                      LoadBalanceStats.instance().get(ar.result().getRegistration()).setWeight(5);
                      seq.incrementAndGet();
                    });
  discovery.publish(HttpEndpoint.createRecord(service, "localhost", 8082, "/"),
                    ar -> {
                      LoadBalanceStats.instance().get(ar.result().getRegistration()).setWeight(1);
                      seq.incrementAndGet();
                    });
  discovery.publish(HttpEndpoint.createRecord(service, "localhost", 8083, "/"),
                    ar -> {
                      LoadBalanceStats.instance().get(ar.result().getRegistration()).setWeight(1);
                      seq.incrementAndGet();
                    });
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:18,代码来源:ServiceProviderTest.java


示例2: undefinedMethodShouldThrowInvalidArg

import io.vertx.servicediscovery.types.HttpEndpoint; //导入依赖的package包/类
@Test
public void undefinedMethodShouldThrowInvalidArg(TestContext context) {
  HttpRpcRequest rpcRequest = SdHttpRequest.create("abc", "device")
          .setRecord(HttpEndpoint.createRecord("device", "localhost", port, "/")
                             .setRegistration(serviceId))
          .setPath("devices")
          .setHttpMethod(HttpMethod.OPTIONS);

  Future<RpcResponse> future = rpcHandler.handle(rpcRequest);
  Async async = context.async();
  future.setHandler(ar -> {
    if (ar.succeeded()) {
      context.fail();
    } else {
      Throwable t = ar.cause();
      context.assertTrue(t instanceof SystemException);
      SystemException ex = (SystemException) t;
      context.assertEquals(DefaultErrorCode.INVALID_ARGS, ex.getErrorCode());
      async.complete();
    }
  });
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:23,代码来源:HttpRpcHandlerTest.java


示例3: postMissBodyShouldThrowMissArg

import io.vertx.servicediscovery.types.HttpEndpoint; //导入依赖的package包/类
@Test
public void postMissBodyShouldThrowMissArg(TestContext context) {
  HttpRpcRequest rpcRequest = SdHttpRequest.create("abc", "device")
          .setRecord(HttpEndpoint.createRecord("device", "localhost", port, "/")
                             .setRegistration(serviceId))
          .setPath("devices")
          .setHttpMethod(HttpMethod.POST);

  Future<RpcResponse> future = rpcHandler.handle(rpcRequest);
  Async async = context.async();
  future.setHandler(ar -> {
    if (ar.succeeded()) {
      context.fail();
    } else {
      Throwable t = ar.cause();
      context.assertTrue(t instanceof SystemException);
      SystemException ex = (SystemException) t;
      context.assertEquals(DefaultErrorCode.MISSING_ARGS, ex.getErrorCode());
      async.complete();
    }
  });
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:23,代码来源:HttpRpcHandlerTest.java


示例4: putMissBodyShouldThrowMissArg

import io.vertx.servicediscovery.types.HttpEndpoint; //导入依赖的package包/类
@Test
public void putMissBodyShouldThrowMissArg(TestContext context) {
  HttpRpcRequest rpcRequest = SdHttpRequest.create("abc", "device")
          .setRecord(HttpEndpoint.createRecord("device", "localhost", port, "/")
                             .setRegistration(serviceId))
          .setPath("devices")
          .setHttpMethod(HttpMethod.PUT);

  Future<RpcResponse> future = rpcHandler.handle(rpcRequest);
  Async async = context.async();
  future.setHandler(ar -> {
    if (ar.succeeded()) {
      context.fail();
    } else {
      Throwable t = ar.cause();
      context.assertTrue(t instanceof SystemException);
      SystemException ex = (SystemException) t;
      context.assertEquals(DefaultErrorCode.MISSING_ARGS, ex.getErrorCode());
      async.complete();
    }
  });
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:23,代码来源:HttpRpcHandlerTest.java


示例5: testGetArray

import io.vertx.servicediscovery.types.HttpEndpoint; //导入依赖的package包/类
@Test
public void testGetArray(TestContext context) {
  HttpRpcRequest rpcRequest = SdHttpRequest.create("abc", "device")
          .setRecord(HttpEndpoint.createRecord("device", "localhost", port, "/")
                             .setRegistration(serviceId))
          .setPath("/devices")
          .setHttpMethod(HttpMethod.GET);

  Future<RpcResponse> future = rpcHandler.handle(rpcRequest);
  Async async = context.async();
  future.setHandler(ar -> {
    if (ar.succeeded()) {
      RpcResponse rpcResponse = ar.result();
      context.assertTrue(rpcResponse.isArray());
      context.assertEquals(2, rpcResponse.responseArray().size());
      async.complete();
    } else {
      ar.cause().printStackTrace();
      context.fail();
    }
  });
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:23,代码来源:HttpRpcHandlerTest.java


示例6: testDelete

import io.vertx.servicediscovery.types.HttpEndpoint; //导入依赖的package包/类
@Test
public void testDelete(TestContext context) {
  HttpRpcRequest rpcRequest = SdHttpRequest.create("abc", "device")
          .setRecord(HttpEndpoint.createRecord("device", "localhost", port, "/")
                             .setRegistration(serviceId))
          .setPath("devices")
          .setHttpMethod(HttpMethod.DELETE)
          .addParam("userId", "2");

  Future<RpcResponse> future = rpcHandler.handle(rpcRequest);
  Async async = context.async();
  future.setHandler(ar -> {
    if (ar.succeeded()) {
      RpcResponse rpcResponse = ar.result();
      context.assertFalse(rpcResponse.isArray());
      context.assertEquals("1", rpcResponse.responseObject().getString("result"));
      async.complete();
    } else {
      ar.cause().printStackTrace();
      context.fail();
    }
  });
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:24,代码来源:HttpRpcHandlerTest.java


示例7: testPost

import io.vertx.servicediscovery.types.HttpEndpoint; //导入依赖的package包/类
@Test
public void testPost(TestContext context) {
  HttpRpcRequest rpcRequest = SdHttpRequest.create("abc", "device")
          .setRecord(HttpEndpoint.createRecord("device", "localhost", port, "/")
                             .setRegistration(serviceId))
          .setPath("devices?type=2")
          .setHttpMethod(HttpMethod.POST)
          .setBody(new JsonObject().put("foo", "bar"))
          .addParam("userId", "2");

  Future<RpcResponse> future = rpcHandler.handle(rpcRequest);

  Async async = context.async();
  future.setHandler(ar -> {
    if (ar.succeeded()) {
      RpcResponse rpcResponse = ar.result();
      context.assertFalse(rpcResponse.isArray());
      context.assertEquals("bar", rpcResponse.responseObject().getString("foo"));
      context.assertEquals("abc", rpcResponse.id());
      async.complete();
    } else {
      context.fail();
    }
  });
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:26,代码来源:HttpRpcHandlerTest.java


示例8: testPut

import io.vertx.servicediscovery.types.HttpEndpoint; //导入依赖的package包/类
@Test
public void testPut(TestContext context) {
  HttpRpcRequest rpcRequest = SdHttpRequest.create("abc", "device")
          .setRecord(HttpEndpoint.createRecord("device", "localhost", port, "/")
                             .setRegistration(serviceId))
          .setPath("devices?type=2")
          .setHttpMethod(HttpMethod.PUT)
          .setBody(new JsonObject().put("foo", "bar"))
          .addParam("userId", "2");

  Future<RpcResponse> future = rpcHandler.handle(rpcRequest);
  Async async = context.async();
  future.setHandler(ar -> {
    if (ar.succeeded()) {
      RpcResponse rpcResponse = ar.result();
      context.assertFalse(rpcResponse.isArray());
      context.assertEquals("bar", rpcResponse.responseObject().getString("foo"));
      context.assertEquals("abc", rpcResponse.id());
      async.complete();
    } else {
      context.fail();
    }
  });
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:25,代码来源:HttpRpcHandlerTest.java


示例9: testHttpImport

import io.vertx.servicediscovery.types.HttpEndpoint; //导入依赖的package包/类
@Test
public void testHttpImport() throws InterruptedException {
  services.add(new JsonObject("{\n" +
      "  \"Node\" : \"node1\",\n" +
      "  \"Address\" : \"172.17.0.2\",\n" +
      "  \"ServiceID\" : \"web\",\n" +
      "  \"ServiceName\" : \"web\",\n" +
      "  \"ServiceTags\" : [ \"rails\", \"http-endpoint\" ],\n" +
      "  \"ServiceAddress\" : \"\",\n" +
      "  \"ServicePort\" : 80\n" +
      "}"));

  discovery = ServiceDiscovery.create(vertx)
      .registerServiceImporter(new ConsulServiceImporter(),
          new JsonObject().put("host", "localhost").put("port", 5601));

  await().until(() -> getAllRecordsBlocking().size() > 0);
  List<Record> list = getAllRecordsBlocking();

  assertThat(list).hasSize(1);

  assertThat(list.get(0).getType()).isEqualTo(HttpEndpoint.TYPE);
  assertThat(list.get(0).getLocation().getString("endpoint")).isEqualTo("http://172.17.0.2:80/");
}
 
开发者ID:vert-x3,项目名称:vertx-service-discovery,代码行数:25,代码来源:ConsulServiceImporterTest.java


示例10: example1

import io.vertx.servicediscovery.types.HttpEndpoint; //导入依赖的package包/类
public void example1(ServiceDiscovery discovery) {
  Record record1 = HttpEndpoint.createRecord(
    "some-http-service", // The service name
    "localhost", // The host
    8433, // the port
    "/api" // the root of the service
  );

  discovery.publish(record1, ar -> {
    // ...
  });

  Record record2 = HttpEndpoint.createRecord(
    "some-other-name", // the service name
    true, // whether or not the service requires HTTPs
    "localhost", // The host
    8433, // the port
    "/api", // the root of the service
    new JsonObject().put("some-metadata", "some value")
  );

}
 
开发者ID:vert-x3,项目名称:vertx-service-discovery,代码行数:23,代码来源:HTTPEndpointExamples.java


示例11: example3

import io.vertx.servicediscovery.types.HttpEndpoint; //导入依赖的package包/类
public void example3(ServiceDiscovery discovery) {
  HttpEndpoint.getClient(discovery, new JsonObject().put("name", "some-http-service"), ar -> {
    if (ar.succeeded()) {
      HttpClient client = ar.result();

      // You need to path the complete path
      client.getNow("/api/persons", response -> {

        // ...

        // Dont' forget to release the service
        ServiceDiscovery.releaseServiceObject(discovery, client);

      });
    }
  });
}
 
开发者ID:vert-x3,项目名称:vertx-service-discovery,代码行数:18,代码来源:HTTPEndpointExamples.java


示例12: example3_webclient

import io.vertx.servicediscovery.types.HttpEndpoint; //导入依赖的package包/类
public void example3_webclient(ServiceDiscovery discovery) {
  HttpEndpoint.getWebClient(discovery, new JsonObject().put("name", "some-http-service"), ar -> {
    if (ar.succeeded()) {
      WebClient client = ar.result();

      // You need to path the complete path
      client.get("/api/persons")
        .send(response -> {

          // ...

          // Dont' forget to release the service
          ServiceDiscovery.releaseServiceObject(discovery, client);

        });
    }
  });
}
 
开发者ID:vert-x3,项目名称:vertx-service-discovery,代码行数:19,代码来源:HTTPEndpointExamples.java


示例13: evaluate

import io.vertx.servicediscovery.types.HttpEndpoint; //导入依赖的package包/类
@Override
public void evaluate(Handler<AsyncResult<Double>> resultHandler) {
  // ----
  // First we need to discover and get a HTTP client for the `quotes` service:
  HttpEndpoint.getWebClient(discovery, new JsonObject().put("name", "quotes"),
      client -> {
        if (client.failed()) {
          // It failed...
          resultHandler.handle(Future.failedFuture(client.cause()));
        } else {
          // We have the client
          WebClient webClient = client.result();
          computeEvaluation(webClient, resultHandler);
        }
      });

  // ---
}
 
开发者ID:cescoffier,项目名称:vertx-microservices-workshop,代码行数:19,代码来源:PortfolioServiceImpl.java


示例14: getMicroServiceRecord

import io.vertx.servicediscovery.types.HttpEndpoint; //导入依赖的package包/类
/**
 * Define microservice options
 * servicePort: this is the visible port from outside
 * for example you run your service with 8080 on a platform (Clever Cloud, Docker, ...)
 * and the visible port is 80
 */
static Record getMicroServiceRecord() {
  
  String serviceName = Optional.ofNullable(System.getenv("SERVICE_NAME")).orElse("John Doe");
  String serviceHost = Optional.ofNullable(System.getenv("SERVICE_HOST")).orElse("localhost"); // domain name
  Integer servicePort = Integer.parseInt(Optional.ofNullable(System.getenv("SERVICE_PORT")).orElse("80")); // set to 80 on Clever Cloud
  String serviceRoot = Optional.ofNullable(System.getenv("SERVICE_ROOT")).orElse("/api");
  
  return HttpEndpoint.createRecord(
    serviceName,
    serviceHost,
    servicePort,
    serviceRoot
  );
}
 
开发者ID:the-big-bang-theory,项目名称:penny,代码行数:21,代码来源:Parameters.java


示例15: createRecord

import io.vertx.servicediscovery.types.HttpEndpoint; //导入依赖的package包/类
private Record createRecord(final JsonObject item) {
    final String name = item.getString(NAME);
    final String host = item.getString(HOST);
    final Integer port = item.getInteger(PORT);
    final JsonObject meta = item.getJsonObject(META);
    return HttpEndpoint.createRecord(
            name, host, port, "/*", meta
    );
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:10,代码来源:EndPointOrigin.java


示例16: createHttpEndpointRecord

import io.vertx.servicediscovery.types.HttpEndpoint; //导入依赖的package包/类
private Record createHttpEndpointRecord(HttpEndpointConfiguration configuration) {
    return HttpEndpoint.createRecord(configuration.getName(),
            configuration.isSsl(),
            configuration.getHost(),
            configuration.getPort(),
            configuration.getRoot(),
            configuration.getMetadata());
}
 
开发者ID:GwtDomino,项目名称:domino,代码行数:9,代码来源:HttpServiceDiscovery.java


示例17: setUp

import io.vertx.servicediscovery.types.HttpEndpoint; //导入依赖的package包/类
@Before
public void setUp() {
  instances.clear();
  instances.add(HttpEndpoint.createRecord("test", "localhost", 8081, "/").setRegistration("a"));
  instances.add(HttpEndpoint.createRecord("test", "localhost", 8082, "/").setRegistration("b"));
  instances.add(HttpEndpoint.createRecord("test", "localhost", 8083, "/").setRegistration("c"));
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:8,代码来源:StrategyTest.java


示例18: addService

import io.vertx.servicediscovery.types.HttpEndpoint; //导入依赖的package包/类
private void addService(AtomicInteger seq) {
  discovery.publish(HttpEndpoint.createRecord(service, "localhost", 8081, "/"),
                    ar -> seq.incrementAndGet());
  discovery.publish(HttpEndpoint.createRecord(service, "localhost", 8082, "/"),
                    ar -> seq.incrementAndGet());
  discovery.publish(HttpEndpoint.createRecord(service, "localhost", 8083, "/"),
                    ar -> seq.incrementAndGet());
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:9,代码来源:ServiceProviderTest.java


示例19: setUp

import io.vertx.servicediscovery.types.HttpEndpoint; //导入依赖的package包/类
@Before
public void setUp() {
  instances.clear();
  Record a = HttpEndpoint.createRecord("test", "localhost", 8081, "/").setRegistration("a");
  LoadBalanceStats.instance().get("a").setWeight(5);
  Record b = HttpEndpoint.createRecord("test", "localhost", 8082, "/").setRegistration("b");
  LoadBalanceStats.instance().get("b").setWeight(1);
  Record c = HttpEndpoint.createRecord("test", "localhost", 8083, "/").setRegistration("c");
  LoadBalanceStats.instance().get("c").setWeight(1);
  instances.add(a);
  instances.add(b);
  instances.add(c);
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:14,代码来源:WeightRoundRobinStrategyTest.java


示例20: testAddServiceAfterCacheConstruct

import io.vertx.servicediscovery.types.HttpEndpoint; //导入依赖的package包/类
@Test
public void testAddServiceAfterCacheConstruct(TestContext testContext) {
  serviceFinder = ServiceFinder.create(vertx, discovery);

  AtomicInteger seq = new AtomicInteger();
  addService(seq);

  Awaitility.await().until(() -> seq.get() == 4);

  AtomicBoolean check = new AtomicBoolean();
  serviceFinder.getRecords(r -> "random".equals(r.getName()), ar -> {
    if (ar.succeeded()) {
      testContext.assertEquals(1, ar.result().size());
      check.set(true);
    }
  });

  Awaitility.await().until(() -> check.get());

  AtomicBoolean check2 = new AtomicBoolean();
  discovery.publish(HttpEndpoint.createRecord("random", "localhost", 8085, "/"),
                    ar -> check2.set(true));
  Awaitility.await().until(() -> check2.get());

  AtomicBoolean check3 = new AtomicBoolean();
  serviceFinder.getRecords(r -> "random".equals(r.getName()), ar -> {
    if (ar.succeeded()) {
      testContext.assertEquals(2, ar.result().size());
      check3.set(true);
    }
  });

  Awaitility.await().until(() -> check3.get());
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:35,代码来源:ServiceFinderTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ICamera类代码示例发布时间:2022-05-21
下一篇:
Java Ad类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap