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


Java MethodType.CLIENT_STREAMING属性代码示例

本文整理汇总了Java中io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING属性的典型用法代码示例。如果您正苦于以下问题:Java MethodType.CLIENT_STREAMING属性的具体用法?Java MethodType.CLIENT_STREAMING怎么用?Java MethodType.CLIENT_STREAMING使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在io.grpc.MethodDescriptor.MethodType的用法示例。


在下文中一共展示了MethodType.CLIENT_STREAMING属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: call

/**
 * Makes an rpc to the remote endpoint and respects the supplied callback. Returns a future which
 * terminates once the call has ended. For calls which are single-request, this throws
 * {@link IllegalArgumentException} if the size of {@code requests} is not exactly 1.
 */
public ListenableFuture<Void> call(
    ImmutableList<DynamicMessage> requests,
    StreamObserver<DynamicMessage> responseObserver,
    CallOptions callOptions) {
  Preconditions.checkArgument(!requests.isEmpty(), "Can't make call without any requests");
  MethodType methodType = getMethodType();
  long numRequests = requests.size();
  if (methodType == MethodType.UNARY) {
    logger.info("Making unary call");
    Preconditions.checkArgument(numRequests == 1,
        "Need exactly 1 request for unary call, but got: " + numRequests);
    return callUnary(requests.get(0), responseObserver, callOptions);
  } else if (methodType == MethodType.SERVER_STREAMING) {
    logger.info("Making server streaming call");
    Preconditions.checkArgument(numRequests == 1,
        "Need exactly 1 request for server streaming call, but got: " + numRequests);
    return callServerStreaming(requests.get(0), responseObserver, callOptions);
  } else if (methodType == MethodType.CLIENT_STREAMING) {
    logger.info("Making client streaming call with " + requests.size() + " requests");
    return callClientStreaming(requests, responseObserver, callOptions);
  } else {
    // Bidi streaming.
    logger.info("Making bidi streaming call with " + requests.size() + " requests");
    return callBidiStreaming(requests, responseObserver, callOptions);
  }
}
 
开发者ID:grpc-ecosystem,项目名称:polyglot,代码行数:31,代码来源:DynamicGrpcClient.java

示例2: getMethodType

/** Returns the appropriate method type based on whether the client or server expect streams. */
private MethodType getMethodType() {
  boolean clientStreaming = protoMethodDescriptor.toProto().getClientStreaming();
  boolean serverStreaming = protoMethodDescriptor.toProto().getServerStreaming();

  if (!clientStreaming && !serverStreaming) {
    return MethodType.UNARY;
  } else if (!clientStreaming && serverStreaming) {
    return MethodType.SERVER_STREAMING;
  } else if (clientStreaming && !serverStreaming) {
    return MethodType.CLIENT_STREAMING;
  } else {
    return MethodType.BIDI_STREAMING;
  }
}
 
开发者ID:grpc-ecosystem,项目名称:polyglot,代码行数:15,代码来源:DynamicGrpcClient.java

示例3: streamsRequests

boolean streamsRequests() {
  return type == MethodType.CLIENT_STREAMING || type == MethodType.BIDI_STREAMING;
}
 
开发者ID:grpc-ecosystem,项目名称:java-grpc-prometheus,代码行数:3,代码来源:GrpcMethod.java


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