本文整理汇总了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")
);
}
示例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
);
}
示例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());
}
});
}
}
示例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 -> {
// ...
});
}
示例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 -> {
// ...
});
}
示例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 -> {
// ...
});
}
示例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 -> {
// ...
});
}
示例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 -> {
// ...
});
}
示例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()));
}
});
}