本文整理汇总了Java中io.vertx.servicediscovery.types.HttpEndpoint.createRecord方法的典型用法代码示例。如果您正苦于以下问题:Java HttpEndpoint.createRecord方法的具体用法?Java HttpEndpoint.createRecord怎么用?Java HttpEndpoint.createRecord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.servicediscovery.types.HttpEndpoint
的用法示例。
在下文中一共展示了HttpEndpoint.createRecord方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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")
);
}
示例2: 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
);
}
示例3: 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
);
}
示例4: 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());
}
示例5: publishRecord
import io.vertx.servicediscovery.types.HttpEndpoint; //导入方法依赖的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());
}
});
}
}
示例6: testPublicationWithoutStatus
import io.vertx.servicediscovery.types.HttpEndpoint; //导入方法依赖的package包/类
@Test
public void testPublicationWithoutStatus() {
AtomicReference<Record> ref = new AtomicReference<>();
Record record = HttpEndpoint.createRecord("some-service", "localhost");
discovery.publish(record, ar -> {
ref.set(ar.result());
});
await().untilAtomic(ref, is(notNullValue()));
assertThat(ref.get().getRegistration()).isNotNull();
assertThat(ref.get().getStatus()).isEqualTo(Status.UP);
}
示例7: publishHttpEndpoint
import io.vertx.servicediscovery.types.HttpEndpoint; //导入方法依赖的package包/类
public void publishHttpEndpoint(String name, String host, int port, String root, Handler<AsyncResult<Void>>
completionHandler) {
Record record = HttpEndpoint.createRecord(name, host, port, root);
publish(record, completionHandler);
}
示例8: testBridges
import io.vertx.servicediscovery.types.HttpEndpoint; //导入方法依赖的package包/类
@Test
public void testBridges() {
AtomicBoolean closed = new AtomicBoolean();
AtomicBoolean registered = new AtomicBoolean();
ServiceImporter bridge = new ServiceImporter() {
@Override
public void start(Vertx vertx, ServicePublisher publisher, JsonObject configuration, Future<Void> future) {
Record rec1 = HttpEndpoint.createRecord("static-record-1", "acme.org");
Record rec2 = HttpEndpoint.createRecord("static-record-2", "example.com");
publisher.publish(rec1,
ar -> publisher.publish(rec2, ar2 -> {
registered.set(true);
future.complete();
}));
}
@Override
public void close(Handler<Void> closeHandler) {
closed.set(true);
closeHandler.handle(null);
}
};
discovery.registerServiceImporter(bridge, null);
await().untilAtomic(registered, is(true));
AtomicReference<Record> record1 = new AtomicReference<>();
AtomicReference<Record> record2 = new AtomicReference<>();
discovery.getRecord(new JsonObject().put("name", "static-record-1"), found -> {
record1.set(found.result());
});
discovery.getRecord(new JsonObject().put("name", "static-record-2"), found -> {
record2.set(found.result());
});
assertThat(record1).isNotNull();
assertThat(record2).isNotNull();
discovery.close();
await().untilAtomic(closed, is(true));
}
示例9: publishHttpEndpoint
import io.vertx.servicediscovery.types.HttpEndpoint; //导入方法依赖的package包/类
protected Future<Void> publishHttpEndpoint(String name, String host, int port) {
Record record = HttpEndpoint.createRecord(name, host, port, "/",
new JsonObject().put("api.name", config().getString("api.name", ""))
);
return publish(record);
}
示例10: publishHttpEndpoint
import io.vertx.servicediscovery.types.HttpEndpoint; //导入方法依赖的package包/类
protected Single<Void> publishHttpEndpoint(String name, String host, int port) {
Record record = HttpEndpoint.createRecord(name, host, port, "/",
new JsonObject().put("api.name", config().getString("api.name", ""))
);
return publish(record);
}
示例11: publishHttpEndpoint
import io.vertx.servicediscovery.types.HttpEndpoint; //导入方法依赖的package包/类
public void publishHttpEndpoint(String name, String host, int port, Handler<AsyncResult<Void>>
completionHandler) {
Record record = HttpEndpoint.createRecord(name, host, port, "/");
publish(record, completionHandler);
}
示例12: publishHttpEndpoint
import io.vertx.servicediscovery.types.HttpEndpoint; //导入方法依赖的package包/类
protected Future<Record> publishHttpEndpoint(Integer port, boolean ssl) {
String address = getAddress();
RecordMetadata metadata = new RecordMetadata().setName(getAPIName()).setHealthPathCheck(options.getHealthPathCheck())
.setHealthCheck(options.isHealthCheck());
Record record = HttpEndpoint.createRecord(getAPIName(), ssl, address, port, ROOT, metadata.toJson());
return publish(record);
}