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