当前位置: 首页>>代码示例>>Java>>正文


Java Server.getPort方法代码示例

本文整理汇总了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();
}
 
开发者ID:salesforce,项目名称:grpc-java-contrib,代码行数:15,代码来源:GrpcServerHost.java

示例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);
}
 
开发者ID:indeedeng-alpha,项目名称:indeed-grpc-java,代码行数:19,代码来源:ConsulServiceRegistrar.java


注:本文中的io.grpc.Server.getPort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。