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


Java ServiceDiscovery.create方法代码示例

本文整理汇总了Java中io.vertx.servicediscovery.ServiceDiscovery.create方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceDiscovery.create方法的具体用法?Java ServiceDiscovery.create怎么用?Java ServiceDiscovery.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.vertx.servicediscovery.ServiceDiscovery的用法示例。


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

示例1: start

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

    router.get("/shopping").handler(this::getList);
    router.route().handler(BodyHandler.create());
    router.post("/shopping").handler(this::addToList);
    router.delete("/shopping/:name").handler(this::deleteFromList);

    ServiceDiscovery.create(vertx, discovery -> {
        RedisDataSource.getRedisClient(discovery, rec -> rec.getName().equals("redis"), ar -> {
            redis = ar.result();
            vertx.createHttpServer()
                .requestHandler(router::accept)
                .listen(8080);
        });
    });
}
 
开发者ID:cescoffier,项目名称:vertx-chtijug-2017,代码行数:19,代码来源:MyShoppingVerticle.java

示例2: getServiceDiscovery

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
static ServiceDiscovery getServiceDiscovery(io.vertx.core.Vertx vertx) {
  // Discovery settings
  ServiceDiscoveryOptions serviceDiscoveryOptions = new ServiceDiscoveryOptions();
  
  // Redis settings with the standard Redis Backend
  Integer redisPort = Integer.parseInt(Optional.ofNullable(System.getenv("REDIS_PORT")).orElse("6379"));
  String redisHost = Optional.ofNullable(System.getenv("REDIS_HOST")).orElse("127.0.0.1");
  String redisAuth = Optional.ofNullable(System.getenv("REDIS_PASSWORD")).orElse(null);
  String redisRecordsKey = Optional.ofNullable(System.getenv("REDIS_RECORDS_KEY")).orElse("vert.x.ms");    // the redis hash
  
  return ServiceDiscovery.create(
    vertx,
    serviceDiscoveryOptions.setBackendConfiguration(
      new JsonObject()
        .put("host", redisHost)
        .put("port", redisPort)
        .put("auth", redisAuth)
        .put("key", redisRecordsKey)
    ));
}
 
开发者ID:the-big-bang-theory,项目名称:penny,代码行数:21,代码来源:Parameters.java

示例3: start

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
@Override
public void start() {

    Router router = Router.router(vertx);
    router.get("/").handler(rc -> rc.response().end("hello "));
    router.get("/shopping").handler(this::getList);
    router.post().handler(BodyHandler.create());
    router.post("/shopping").handler(this::addToList);
    router.delete("/shopping/:name").handler(this::removeFromList);

    ServiceDiscovery.create(vertx, discovery -> {
        RedisDataSource.getRedisClient(discovery, svc -> svc.getName().equals("redis"), ar -> {
            if (ar.failed()) {
                System.out.println("D'oh");
            } else {
                redis = ar.result();
                vertx.createHttpServer()
                    .requestHandler(router::accept)
                    .listen(8080);
            }
        });
    });


}
 
开发者ID:cescoffier,项目名称:vertx-kubernetes-live-coding-devoxx-ma,代码行数:26,代码来源:ShoppingBackendVerticle.java

示例4: start

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
@Override
public void start() {
    Router router = Router.router(vertx);
    router.get("/").handler(rc -> rc.response().end("Hello Austin"));
    router.get("/shopping").handler(this::getList);
    router.post().handler(BodyHandler.create());
    router.post("/shopping").handler(this::addToList);
    router.delete("/shopping/:name").handler(this::deleteFromList);

    ServiceDiscovery.create(vertx, discovery -> {
        RedisDataSource.getRedisClient(discovery, svc -> svc.getName().equals("redis"), ar -> {
            if (ar.failed()) {
                System.out.println("D'oh");
            } else {
                redis = ar.result();
                vertx.createHttpServer()
                    .requestHandler(router::accept)
                    .listen(8080);
            }
        });
    });

}
 
开发者ID:cescoffier,项目名称:vertx-reactive-summit-2017,代码行数:24,代码来源:ShoppingBackendVerticle.java

示例5: should_Manage_Registrations

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
@Test
public void should_Manage_Registrations() {
    abstractRegistrar.getOrCreateDiscovery(options, () -> {
        abstractRegistrar.closeServiceDiscovery(options.getName());
        return null;
    });
    TestRegistration registration1 = new TestRegistration(ServiceDiscovery.create(vertx, options), options);
    assertNotNull(abstractRegistrar.registrations());
    abstractRegistrar.register(options.getName(), registration1);
    assertEquals(1, abstractRegistrar.registrations().size());

    TestRegistration registration2 = new TestRegistration(ServiceDiscovery.create(vertx, options), options);
    abstractRegistrar.register(options.getName(), registration2);
    assertEquals(2, abstractRegistrar.registrations().size());

    abstractRegistrar.unregister(registration2);
    assertEquals(1, abstractRegistrar.registrations().size());
    assertEquals(1, abstractRegistrar.serviceDiscoveryNames().size());
    abstractRegistrar.unregister(registration1);
    assertEquals(0, abstractRegistrar.registrations().size());
    assertEquals(0, abstractRegistrar.serviceDiscoveryNames().size());

    abstractRegistrar.close();
}
 
开发者ID:engagingspaces,项目名称:vertx-graphql-service-discovery,代码行数:25,代码来源:AbstractRegistrarTest.java

示例6: setUp

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
@Before
public void setUp() {
  init();

  client = DockerClientBuilder.getInstance().build();
  List<Container> running = client.listContainersCmd().withStatusFilter("running").exec();
  if (running != null) {
    running.forEach(container -> client.stopContainerCmd(container.getId()).exec());
  }

  vertx = Vertx.vertx();
  discovery = ServiceDiscovery.create(vertx);
  bridge = new DockerServiceImporter();
  discovery.registerServiceImporter(bridge,
      new JsonObject().put("scan-period", -1));

  await().until(() -> bridge.started);
}
 
开发者ID:vert-x3,项目名称:vertx-service-discovery,代码行数:19,代码来源:DockerBridgeTest.java

示例7: start

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
@Override
public void start() throws Exception {
  // init service discovery instance
  discovery = ServiceDiscovery.create(vertx, new ServiceDiscoveryOptions().setBackendConfiguration(config()));

  // init circuit breaker instance
  JsonObject cbOptions = config().getJsonObject("circuit-breaker") != null ?
    config().getJsonObject("circuit-breaker") : new JsonObject();
  circuitBreaker = CircuitBreaker.create(cbOptions.getString("name", "circuit-breaker"), vertx,
    new CircuitBreakerOptions()
      .setMaxFailures(cbOptions.getInteger("max-failures", 5))
      .setTimeout(cbOptions.getLong("timeout", 10000L))
      .setFallbackOnFailure(true)
      .setResetTimeout(cbOptions.getLong("reset-timeout", 30000L))
  );
}
 
开发者ID:sczyh30,项目名称:vertx-blueprint-microservice,代码行数:17,代码来源:BaseMicroserviceVerticle.java

示例8: setUp

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
@Before
public void setUp() {
    vertx = Vertx.vertx();
    options = new ServiceDiscoveryOptions().setName("theDiscovery")
            .setAnnounceAddress("theAnnounceAddress").setUsageAddress("theUsageAddress");
    discovery = ServiceDiscovery.create(vertx, options);
    record = new Record()
            .setName("theRecord")
            .setType(Queryable.SERVICE_TYPE)
            .setMetadata(new JsonObject().put("publisherId", "thePublisherId"))
            .setLocation(new JsonObject().put(Record.ENDPOINT, Queryable.ADDRESS_PREFIX + ".DroidQueries"))
            .setStatus(Status.UP);
    definition = SchemaDefinition.createInstance(droidsSchema,
            SchemaMetadata.create(new JsonObject().put("publisherId", "thePublisherId")));
    consumer = ProxyHelper.registerService(Queryable.class,
            vertx, definition, Queryable.ADDRESS_PREFIX + ".DroidQueries");
}
 
开发者ID:engagingspaces,项目名称:vertx-graphql-service-discovery,代码行数:18,代码来源:SchemaRegistrationTest.java

示例9: start

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
@Override
public void start() throws Exception {
    Router router = Router.router(vertx);
    ServiceDiscovery.create(vertx, discovery -> {
        RedisDataSource.getRedisClient(discovery, rec -> rec.getName().equals("redis"), ar -> {
            if (ar.failed()) {
                redis = RedisClient.create(vertx);
            } else {
                redis = ar.result();
            }

            router.get("/shopping").handler(this::getShoppingList);
            router.route().handler(BodyHandler.create());
            router.post("/shopping").handler(this::addItem);
            router.get("/health").handler(rc -> rc.response().end("OK"));

            vertx.createHttpServer()
                .requestHandler(router::accept)
                .listen(8080);
        });
    });
}
 
开发者ID:cescoffier,项目名称:vertx-chtijug-2017,代码行数:23,代码来源:MyShoppingListVerticle.java

示例10: start

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
@Override
public void start() throws Exception {
    Router router = Router.router(vertx);
    router.get("/")
        .handler(rc -> rc.response()
            .end("Bonjour Tourcoing"));

    router.get("/shopping").handler(this::getList);
    router.route().handler(BodyHandler.create());
    router.post("/shopping")
        .handler(this::addToList);
    router.delete("/shopping/:name").handler(this::deleteFromList);

    ServiceDiscovery.create(vertx, discovery -> {
        RedisDataSource.getRedisClient(discovery,
            svc -> svc.getName().equals("redis"),
            ar -> {
                if (ar.failed()) {
                    System.out.println("D'oh !");
                } else {
                    client = ar.result();
                    vertx.createHttpServer()
                        .requestHandler(router::accept)
                        .listen(8080);
                }
            });
    });

}
 
开发者ID:cescoffier,项目名称:vertx-chtijug-2017,代码行数:30,代码来源:ShoppingBackend.java

示例11: start

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
@Override
public void start() throws Exception {
    Router router = Router.router(vertx);
    router.get("/").handler(rc -> rc.response().end("Hello"));

    router.get("/shopping").handler(this::getList);
    router.route().handler(BodyHandler.create());
    router.post("/shopping").handler(this::addToList);
    router.delete("/shopping/:name").handler(this::removeFromList);

    ServiceDiscovery.create(vertx, discovery -> {
        RedisDataSource.getRedisClient(discovery,
            svc -> svc.getName().equals("redis"),
            ar -> {
                if (ar.failed()) {
                    System.out.println("D'oh !");
                } else {
                    client = ar.result();
                    vertx.createHttpServer()
                        .requestHandler(router::accept)
                        .listen(8080);
                }
            });
    });


}
 
开发者ID:cescoffier,项目名称:vertx-rhsummit-2017,代码行数:28,代码来源:ShoppingListVerticle.java

示例12: setUp

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    vertx = rule.vertx();
    serviceDiscovery = ServiceDiscovery.create(vertx);
    metadata = new JsonObject().put(KEY, VALUE);
    jsonFilter = new JsonObject().put("name", SERVICE_NAME);
    vertxServiceDiscovery = new VertxServiceDiscovery(vertx);
    onSetup();
}
 
开发者ID:GwtDomino,项目名称:domino,代码行数:10,代码来源:BaseVertxServiceDiscoveryTest.java

示例13: setUp

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
@Before
public void setUp() {
  service = UUID.randomUUID().toString();
  vertx = Vertx.vertx();
  discovery = ServiceDiscovery.create(vertx);
  serviceFinder = ServiceFinder.create(vertx, discovery);
  try {
    TimeUnit.SECONDS.sleep(1);
  } catch (InterruptedException e) {
    e.printStackTrace();
  }
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:13,代码来源:ServiceProviderTest.java

示例14: should_Cleanup_On_Close

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
@Test
public void should_Cleanup_On_Close() {
    abstractRegistrar.getOrCreateDiscovery(options, () -> {
        abstractRegistrar.closeServiceDiscovery(options.getName());
        return null;
    });
    TestRegistration registration1 = new TestRegistration(ServiceDiscovery.create(vertx, options), options);
    abstractRegistrar.register(options.getName(), registration1);
    assertEquals(1, abstractRegistrar.registrations().size());
    assertEquals(1, abstractRegistrar.serviceDiscoveryNames().size());

    abstractRegistrar.close();
    assertEquals(0, abstractRegistrar.registrations().size());
    assertEquals(0, abstractRegistrar.serviceDiscoveryNames().size());
}
 
开发者ID:engagingspaces,项目名称:vertx-graphql-service-discovery,代码行数:16,代码来源:AbstractRegistrarTest.java

示例15: testSetup

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
@Before
public void testSetup(TestContext context) {
    Async async = context.async();
    vertx = Vertx.vertx();
    discovery = ServiceDiscovery
            .create(vertx, new ServiceDiscoveryOptions()
                    .setBackendConfiguration(vertx.getOrCreateContext().config()));
    svc = new PortfolioServiceImpl(vertx, discovery, 10000);
    svc.getPortfolio(ar -> {
        portfolio = ar.result();
        svc.buy(3, getQuote(), result -> {
            async.complete();
        });
    });
}
 
开发者ID:docker-production-aws,项目名称:microtrader,代码行数:16,代码来源:PortfolioServiceSellTest.java


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