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


Java ServiceDiscoveryRestEndpoint类代码示例

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


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

示例1: start

import io.vertx.servicediscovery.rest.ServiceDiscoveryRestEndpoint; //导入依赖的package包/类
@Override
public void start() throws Exception {
  super.start();
  Router router = Router.router(vertx);

  // create Dropwizard metrics service
  MetricsService service = MetricsService.create(vertx);

  // event bus bridge
  SockJSHandler sockJSHandler = SockJSHandler.create(vertx);
  BridgeOptions options = new BridgeOptions()
    .addOutboundPermitted(new PermittedOptions().setAddress("microservice.monitor.metrics"))
    .addOutboundPermitted(new PermittedOptions().setAddress("events.log"));

  sockJSHandler.bridge(options);
  router.route("/eventbus/*").handler(sockJSHandler);

  // discovery endpoint
  ServiceDiscoveryRestEndpoint.create(router, discovery);

  // static content
  router.route("/*").handler(StaticHandler.create());

  int port = config().getInteger("monitor.http.port", 9100);
  String host = config().getString("monitor.http.host", "0.0.0.0");
  int metricsInterval = config().getInteger("monitor.metrics.interval", 5000);

  vertx.createHttpServer()
    .requestHandler(router::accept)
    .listen(port, host);

  // send metrics message to the event bus
  vertx.setPeriodic(metricsInterval, t -> {
    JsonObject metrics = service.getMetricsSnapshot(vertx);
    vertx.eventBus().publish("microservice.monitor.metrics", metrics);
  });
}
 
开发者ID:sczyh30,项目名称:vertx-blueprint-microservice,代码行数:38,代码来源:MonitorDashboardVerticle.java

示例2: start

import io.vertx.servicediscovery.rest.ServiceDiscoveryRestEndpoint; //导入依赖的package包/类
@Override
public void start(Future<Void> future) {
    // Get configuration
    config = ConfigFactory.load();

    discovery = ServiceDiscovery.create(vertx, new ServiceDiscoveryOptions().setBackendConfiguration(config()));
    Router router = Router.router(vertx);

    // Event bus bridge
    SockJSHandler sockJSHandler = SockJSHandler.create(vertx);
    BridgeOptions options = new BridgeOptions();
    options
            .addOutboundPermitted(new PermittedOptions().setAddress(config.getString("market.address")))
            .addOutboundPermitted(new PermittedOptions().setAddress(config.getString("portfolio.address")))
            .addOutboundPermitted(new PermittedOptions().setAddress("service.portfolio"))
            .addInboundPermitted(new PermittedOptions().setAddress("service.portfolio"))
            .addOutboundPermitted(new PermittedOptions().setAddress("vertx.circuit-breaker"));

    sockJSHandler.bridge(options);
    router.route("/eventbus/*").handler(sockJSHandler);

    // Discovery endpoint
    ServiceDiscoveryRestEndpoint.create(router, discovery);

    // Last operations
    router.get("/operations").handler(this::callAuditServiceWithExceptionHandlerWithCircuitBreaker);

    // Static content
    router.route("/*").handler(StaticHandler.create());

    // Create a circuit breaker.
    circuit = CircuitBreaker.create("http-audit-service", vertx,
            new CircuitBreakerOptions()
                    .setMaxFailures(2)
                    .setFallbackOnFailure(true)
                    .setResetTimeout(2000)
                    .setTimeout(1000))
                    .openHandler(v -> retrieveAuditService());

    vertx.createHttpServer()
            .requestHandler(router::accept)
            .listen(config.getInt("http.port"), ar -> {
                if (ar.failed()) {
                    future.fail(ar.cause());
                } else {
                    retrieveAuditService();
                    future.complete();
                }
            });
}
 
开发者ID:docker-production-aws,项目名称:microtrader,代码行数:51,代码来源:DashboardVerticle.java

示例3: start

import io.vertx.servicediscovery.rest.ServiceDiscoveryRestEndpoint; //导入依赖的package包/类
@Override
public void start(Future<Void> future) {
  super.start();
  Router router = Router.router(vertx);

  // Event bus bridge
  SockJSHandler sockJSHandler = SockJSHandler.create(vertx);
  BridgeOptions options = new BridgeOptions();
  options
      .addOutboundPermitted(new PermittedOptions().setAddress("market"))
      .addOutboundPermitted(new PermittedOptions().setAddress("portfolio"))
      .addOutboundPermitted(new PermittedOptions().setAddress("service.portfolio"))
      .addInboundPermitted(new PermittedOptions().setAddress("service.portfolio"))
      .addOutboundPermitted(new PermittedOptions().setAddress("vertx.circuit-breaker"));

  sockJSHandler.bridge(options);
  router.route("/eventbus/*").handler(sockJSHandler);

  // Discovery endpoint
  ServiceDiscoveryRestEndpoint.create(router, discovery);

  // Last operations
  router.get("/operations").handler(this::callAuditServiceWithExceptionHandlerWithCircuitBreaker);

  // Static content
  router.route("/*").handler(StaticHandler.create());

  // Create a circuit breaker.
  circuit = CircuitBreaker.create("http-audit-service", vertx,
      new CircuitBreakerOptions()
          .setMaxFailures(2)
          .setFallbackOnFailure(true)
          .setResetTimeout(2000)
          .setTimeout(1000))
      .openHandler(v -> retrieveAuditService());

  vertx.createHttpServer()
      .requestHandler(router::accept)
      .listen(8080, ar -> {
        if (ar.failed()) {
          future.fail(ar.cause());
        } else {
          retrieveAuditService();
          future.complete();
        }
      });
}
 
开发者ID:cescoffier,项目名称:vertx-microservices-workshop,代码行数:48,代码来源:DashboardVerticle.java

示例4: start

import io.vertx.servicediscovery.rest.ServiceDiscoveryRestEndpoint; //导入依赖的package包/类
@Override
public void start(Future<Void> future) {
  super.start();
  Router router = Router.router(vertx);

  // Event bus bridge
  SockJSHandler sockJSHandler = SockJSHandler.create(vertx);
  BridgeOptions options = new BridgeOptions();
  options
      .addOutboundPermitted(new PermittedOptions().setAddress("market"))
      .addOutboundPermitted(new PermittedOptions().setAddress("portfolio"))
      .addOutboundPermitted(new PermittedOptions().setAddress("service.portfolio"))
      .addInboundPermitted(new PermittedOptions().setAddress("service.portfolio"))
      .addOutboundPermitted(new PermittedOptions().setAddress("vertx.circuit-breaker"));

  sockJSHandler.bridge(options);
  router.route("/eventbus/*").handler(sockJSHandler);

  // Discovery endpoint
  ServiceDiscoveryRestEndpoint.create(router, discovery);

  // Last operations
  router.get("/operations").handler(this::callAuditService);

  // Static content
  router.route("/*").handler(StaticHandler.create());

  // Create a circuit breaker.
  circuit = CircuitBreaker.create("http-audit-service", vertx,
      new CircuitBreakerOptions()
          .setMaxFailures(2)
          .setFallbackOnFailure(true)
          .setResetTimeout(2000)
          .setTimeout(1000))
      .openHandler(v -> retrieveAuditService());

  vertx.createHttpServer()
      .requestHandler(router::accept)
      .listen(8080, ar -> {
        if (ar.failed()) {
          future.fail(ar.cause());
        } else {
          retrieveAuditService();
          future.complete();
        }
      });
}
 
开发者ID:cescoffier,项目名称:vertx-microservices-workshop,代码行数:48,代码来源:DashboardVerticle.java


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