本文整理汇总了Java中io.vertx.grpc.VertxServerBuilder类的典型用法代码示例。如果您正苦于以下问题:Java VertxServerBuilder类的具体用法?Java VertxServerBuilder怎么用?Java VertxServerBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VertxServerBuilder类属于io.vertx.grpc包,在下文中一共展示了VertxServerBuilder类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import io.vertx.grpc.VertxServerBuilder; //导入依赖的package包/类
@Override
public void start() {
/** 1. Iterate all the configuration **/
Fn.itMap(ZeroAtomic.RPC_OPTS, (port, config) -> {
/** 2.Rcp server builder initialized **/
final VertxServerBuilder builder = VertxServerBuilder
.forAddress(this.vertx, config.getHost(), config.getPort());
/**
* 3.Must contains following config item:
* ssl, alpn, jks, password
* **/
final JsonObject options = config.getOptions();
// 4.SSL Enabled
if (options.containsKey(SSL) && Boolean.valueOf(options.getValue(SSL).toString())) {
final Object type = options.getValue("type");
final CertType certType = null == type ?
CertType.PEM : Types.fromStr(CertType.class, type.toString());
final CertPipe<JsonObject> pipe = CertPipe.get(certType);
builder.useSsl(pipe.parse(options));
}
/**
* 5.Service added.
*/
{
// UnityService add
final Tunnel tunnel = Instance.singleton(UnityTunnel.class);
builder.addService(tunnel.init(this.vertx));
}
/**
* 6.Server added.
*/
final VertxServer server = builder.build();
server.start(handler -> registryServer(handler, config));
});
}
示例2: createGrpcServer
import io.vertx.grpc.VertxServerBuilder; //导入依赖的package包/类
private VertxServer createGrpcServer() {
return VertxServerBuilder
.forPort(vertx, TestConfig.STORE_MANAGER_PORT)
.addService(this.createService())
.useSsl(options -> options
.setSsl(true)
.setUseAlpn(true)
.setPemKeyCertOptions(TestConfig.HTTP_STORAGE_CERTIFICATE.keyCertOptions())
.setPemTrustOptions(TestConfig.HTTP_STORAGE_CERTIFICATE.trustOptions())
)
.build();
}