本文整理匯總了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();
}