本文整理汇总了Java中io.grpc.Server.getPort方法的典型用法代码示例。如果您正苦于以下问题:Java Server.getPort方法的具体用法?Java Server.getPort怎么用?Java Server.getPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.grpc.Server
的用法示例。
在下文中一共展示了Server.getPort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPort
import io.grpc.Server; //导入方法依赖的package包/类
/**
* Returns the actual port of the running gRPC server. The port is only available once the server is up and running.
*
* @throws IllegalStateException if called either before the server has started or after it has stopped
*/
public final int getPort() {
final Server server = server();
if (server == null) {
throw new IllegalStateException("Cannot fetch port until server has started.");
}
return server.getPort();
}
示例2: registerServices
import io.grpc.Server; //导入方法依赖的package包/类
/**
* Pull all the specified services from the provided server and register
* them into consul. Services will be registered using the provided
* {@code advertiseAddress}. The {@code port} will be obtained from the
* provided {@code server}. Service names are filtered through the
* {@link #excludedServices} set before being registered into consul.
*
* @param advertiseAddress The address that the service is advertising on.
* @param server The server to pull the services and port from.
*/
public void registerServices(final String advertiseAddress, final Server server) {
final int port = server.getPort();
final Stream<String> services = server.getImmutableServices().stream()
.map((ssd) -> ssd.getServiceDescriptor().getName());
registerServices(advertiseAddress, port, services);
}