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


Java ServiceDiscovery.publish方法代码示例

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


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

示例1: example1

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的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

示例2: example1

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
public void example1(ServiceDiscovery discovery) {
  Record record = MessageSource.createRecord(
      "some-message-source-service", // The service name
      "some-address" // The event bus address
  );

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

  record = MessageSource.createRecord(
      "some-other-message-source-service", // The service name
      "some-address", // The event bus address
      "examples.MyData" // The payload type
  );
}
 
开发者ID:vert-x3,项目名称:vertx-service-discovery,代码行数:17,代码来源:MessageSourceExamples.java

示例3: publishRecord

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
private void publishRecord(ServiceDiscovery discovery, String name, JsonObject service) {
  String host = service.getString("host");
  Integer port = service.getInteger("port");
  if (host != null && port != null) {
    Record record = HttpEndpoint.createRecord(name, host, port, "/");
    record.setLocation(service);
    discovery.publish(record, ar -> {
      if (ar.succeeded()) {
        LOGGER.info("publish record succeeded: {}", ar.result().toJson().encode());
      } else {
        LOGGER.info("publish record failed: {}", record.toJson().encode());
      }
    });
  }
}
 
开发者ID:edgar615,项目名称:direwolves,代码行数:16,代码来源:JsonServiceDiscoveryVerticle.java

示例4: example1

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
public void example1(ServiceDiscovery discovery) {
  Record record = RedisDataSource.createRecord(
    "some-redis-data-source-service", // The service name
    new JsonObject().put("url", "localhost"), // The location
    new JsonObject().put("some-metadata", "some-value") // Some metadata
  );

  discovery.publish(record, ar -> {
    // ...
  });
}
 
开发者ID:vert-x3,项目名称:vertx-service-discovery,代码行数:12,代码来源:RedisDataSourceExamples.java

示例5: example1

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
public void example1(ServiceDiscovery discovery) {
  Record record = EventBusService.createRecord(
      "some-eventbus-service", // The service name
      "address", // the service address,
      MyService.class // the service interface
  );

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

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

示例6: example1

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
public void example1(ServiceDiscovery discovery) {
  Record record = JDBCDataSource.createRecord(
      "some-data-source-service", // The service name
      new JsonObject().put("url", "some jdbc url"), // The location
      new JsonObject().put("some-metadata", "some-value") // Some metadata
  );

  discovery.publish(record, ar -> {
    // ...
  });
}
 
开发者ID:vert-x3,项目名称:vertx-service-discovery,代码行数:12,代码来源:JDBCDataSourceExamples.java

示例7: example1

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
public void example1(ServiceDiscovery discovery) {
  Record record = MongoDataSource.createRecord(
    "some-data-source-service", // The service name
    new JsonObject().put("connection_string", "some mongo connection"), // The location
    new JsonObject().put("some-metadata", "some-value") // Some metadata
  );

  discovery.publish(record, ar -> {
    // ...
  });
}
 
开发者ID:vert-x3,项目名称:vertx-service-discovery,代码行数:12,代码来源:MongoDataSourceExamples.java

示例8: example1

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
public void example1(ServiceDiscovery discovery) {
  Record record = EventBusService.createRecord(
      "some-eventbus-service", // The service name
      "address", // the service address,
      "examples.MyService", // the service interface as string
      new JsonObject()
          .put("some-metadata", "some value")
  );

  discovery.publish(record, ar -> {
    // ...
  });
}
 
开发者ID:vert-x3,项目名称:vertx-service-discovery,代码行数:14,代码来源:EventBusServiceExamples.java

示例9: publish

import io.vertx.servicediscovery.ServiceDiscovery; //导入方法依赖的package包/类
/**
 * Publish a GraphQL schema for querying.
 * <p>
 * On success a {@link SchemaRegistration} is returned. It contains the message consumer of the
 * {@link Queryable} service proxy that supplies the published {@link SchemaDefinition}, the published service
 * discovery record, and the {@link ServiceDiscovery} it was published to.
 * <p>
 * Note that unless invoked from a {@link SchemaPublisher} a
 * client needs to keep hold of the returned {@link Record} as long as it is published.
 *
 * @param vertx         the vert.x instance
 * @param discovery     the service discovery instance
 * @param definition    the service proxy instance exposing the graphql schema
 * @param resultHandler the result handler that returns the registration
 */
static void publish(Vertx vertx, ServiceDiscovery discovery, SchemaDefinition definition,
                    Handler<AsyncResult<SchemaRegistration>> resultHandler) {

    Objects.requireNonNull(vertx, "Vertx cannot be null");
    Objects.requireNonNull(discovery, "Service discovery cannot be null");
    Objects.requireNonNull(definition, "GraphQL queryable cannot be null");
    Objects.requireNonNull(resultHandler, "Publication result handler cannot be null");

    // TODO Caching proxy ok?

    final MessageConsumer<JsonObject> serviceConsumer;
    if (definition.metadata().get("publisherId") == null) {
        serviceConsumer = ProxyHelper.registerService(
                Queryable.class, vertx, definition, definition.serviceAddress());
    } else {
        // Publisher handles service instantiation, manages consumer.
        serviceConsumer = null;
    }

    Record record = new Record()
            .setType(SERVICE_TYPE)
            .setName(definition.schemaName())
            .setMetadata(definition.metadata().toJson())
            .setLocation(new JsonObject().put(Record.ENDPOINT, definition.serviceAddress()));

    discovery.publish(record, rh -> {
        if (rh.succeeded()) {
            resultHandler.handle(Future.succeededFuture(
                    SchemaRegistration.create(discovery, null, rh.result(), definition, serviceConsumer)));
        } else {
            resultHandler.handle(Future.failedFuture(rh.cause()));
        }
    });
}
 
开发者ID:engagingspaces,项目名称:vertx-graphql-service-discovery,代码行数:50,代码来源:GraphQLService.java


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