io.grpc.Status#augmentDescription ( )源码实例Demo

下面列出了io.grpc.Status#augmentDescription ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: grpc-nebula-java   文件: OkHttpClientTransport.java
@Override
public void goAway(int lastGoodStreamId, ErrorCode errorCode, ByteString debugData) {
  if (errorCode == ErrorCode.ENHANCE_YOUR_CALM) {
    String data = debugData.utf8();
    log.log(Level.WARNING, String.format(
        "%s: Received GOAWAY with ENHANCE_YOUR_CALM. Debug data: %s", this, data));
    if ("too_many_pings".equals(data)) {
      tooManyPingsRunnable.run();
    }
  }
  Status status = GrpcUtil.Http2Error.statusForCode(errorCode.httpCode)
      .augmentDescription("Received Goaway");
  if (debugData.size() > 0) {
    // If a debug message was provided, use it.
    status = status.augmentDescription(debugData.utf8());
  }
  startGoAway(lastGoodStreamId, null, status);
}
 
/**
 * Extract the response status from trailers.
 */
private Status statusFromTrailers(Metadata trailers) {
  Status status = trailers.get(InternalStatus.CODE_KEY);
  if (status != null) {
    return status.withDescription(trailers.get(InternalStatus.MESSAGE_KEY));
  }
  // No status; something is broken. Try to provide a resonanable error.
  if (headersReceived) {
    return Status.UNKNOWN.withDescription("missing GRPC status in response");
  }
  Integer httpStatus = trailers.get(HTTP2_STATUS);
  if (httpStatus != null) {
    status = GrpcUtil.httpStatusToGrpcStatus(httpStatus);
  } else {
    status = Status.INTERNAL.withDescription("missing HTTP status code");
  }
  return status.augmentDescription(
      "missing GRPC status, inferred error from HTTP status code");
}
 
源代码3 项目: grpc-java   文件: OkHttpClientTransport.java
@Override
public void goAway(int lastGoodStreamId, ErrorCode errorCode, ByteString debugData) {
  logger.logGoAway(OkHttpFrameLogger.Direction.INBOUND, lastGoodStreamId, errorCode, debugData);
  if (errorCode == ErrorCode.ENHANCE_YOUR_CALM) {
    String data = debugData.utf8();
    log.log(Level.WARNING, String.format(
        "%s: Received GOAWAY with ENHANCE_YOUR_CALM. Debug data: %s", this, data));
    if ("too_many_pings".equals(data)) {
      tooManyPingsRunnable.run();
    }
  }
  Status status = GrpcUtil.Http2Error.statusForCode(errorCode.httpCode)
      .augmentDescription("Received Goaway");
  if (debugData.size() > 0) {
    // If a debug message was provided, use it.
    status = status.augmentDescription(debugData.utf8());
  }
  startGoAway(lastGoodStreamId, null, status);
}
 
/**
 * Extract the response status from trailers.
 */
private Status statusFromTrailers(Metadata trailers) {
  Status status = trailers.get(InternalStatus.CODE_KEY);
  if (status != null) {
    return status.withDescription(trailers.get(InternalStatus.MESSAGE_KEY));
  }
  // No status; something is broken. Try to provide a resonanable error.
  if (headersReceived) {
    return Status.UNKNOWN.withDescription("missing GRPC status in response");
  }
  Integer httpStatus = trailers.get(HTTP2_STATUS);
  if (httpStatus != null) {
    status = GrpcUtil.httpStatusToGrpcStatus(httpStatus);
  } else {
    status = Status.INTERNAL.withDescription("missing HTTP status code");
  }
  return status.augmentDescription(
      "missing GRPC status, inferred error from HTTP status code");
}
 
源代码5 项目: grpc-nebula-java   文件: NettyClientHandler.java
private Status statusFromGoAway(long errorCode, byte[] debugData) {
  Status status = GrpcUtil.Http2Error.statusForCode((int) errorCode)
      .augmentDescription("Received Goaway");
  if (debugData != null && debugData.length > 0) {
    // If a debug message was provided, use it.
    String msg = new String(debugData, UTF_8);
    status = status.augmentDescription(msg);
  }
  return status;
}
 
源代码6 项目: grpc-java   文件: NettyClientHandler.java
private Status statusFromGoAway(long errorCode, byte[] debugData) {
  Status status = GrpcUtil.Http2Error.statusForCode((int) errorCode)
      .augmentDescription("Received Goaway");
  if (debugData != null && debugData.length > 0) {
    // If a debug message was provided, use it.
    String msg = new String(debugData, UTF_8);
    status = status.augmentDescription(msg);
  }
  return status;
}
 
源代码7 项目: grpc-nebula-java   文件: GrpcUtil.java
Http2Error(int code, Status status) {
  this.code = code;
  this.status = status.augmentDescription("HTTP/2 error code: " + this.name());
}
 
源代码8 项目: grpc-java   文件: GrpcUtil.java
Http2Error(int code, Status status) {
  this.code = code;
  this.status = status.augmentDescription("HTTP/2 error code: " + this.name());
}