Java 类io.grpc.Compressor 实例源码

项目:grpc-java    文件:ClientCallImpl.java   
@VisibleForTesting
static void prepareHeaders(
    Metadata headers,
    DecompressorRegistry decompressorRegistry,
    Compressor compressor,
    boolean fullStreamDecompression) {
  headers.discardAll(MESSAGE_ENCODING_KEY);
  if (compressor != Codec.Identity.NONE) {
    headers.put(MESSAGE_ENCODING_KEY, compressor.getMessageEncoding());
  }

  headers.discardAll(MESSAGE_ACCEPT_ENCODING_KEY);
  byte[] advertisedEncodings =
      InternalDecompressorRegistry.getRawAdvertisedMessageEncodings(decompressorRegistry);
  if (advertisedEncodings.length != 0) {
    headers.put(MESSAGE_ACCEPT_ENCODING_KEY, advertisedEncodings);
  }

  headers.discardAll(CONTENT_ENCODING_KEY);
  headers.discardAll(CONTENT_ACCEPT_ENCODING_KEY);
  if (fullStreamDecompression) {
    headers.put(CONTENT_ACCEPT_ENCODING_KEY, FULL_STREAM_DECOMPRESSION_ENCODINGS);
  }
}
项目:armeria    文件:ArmeriaClientCall.java   
@Override
public void start(Listener<O> responseListener, Metadata unused) {
    requireNonNull(responseListener, "responseListener");
    final Compressor compressor;
    if (callOptions.getCompressor() != null) {
        compressor = compressorRegistry.lookupCompressor(callOptions.getCompressor());
        if (compressor == null) {
            responseListener.onClose(
                    Status.INTERNAL.withDescription(
                            "Unable to find compressor by name " + callOptions.getCompressor()),
                    EMPTY_METADATA);
            return;
        }
    } else {
        compressor = Identity.NONE;
    }
    messageFramer.setCompressor(compressor);
    prepareHeaders(req.headers(), compressor);
    listener = responseListener;
    final HttpResponse res;
    try {
        res = httpClient.execute(ctx, req);
    } catch (Exception e) {
        close(Status.fromThrowable(e));
        return;
    }
    res.subscribe(responseReader, ctx.eventLoop(), true);
}
项目:armeria    文件:ArmeriaClientCall.java   
private void prepareHeaders(HttpHeaders headers, Compressor compressor) {
    if (compressor != Identity.NONE) {
        headers.set(GrpcHeaderNames.GRPC_ENCODING, compressor.getMessageEncoding());
    }
    String advertisedEncodings = String.join(",", decompressorRegistry.getAdvertisedMessageEncodings());
    if (!advertisedEncodings.isEmpty()) {
        headers.add(GrpcHeaderNames.GRPC_ACCEPT_ENCODING, advertisedEncodings);
    }
    headers.add(GrpcHeaderNames.GRPC_TIMEOUT,
                TimeoutHeaderUtil.toHeaderValue(
                        TimeUnit.MILLISECONDS.toNanos(ctx.responseTimeoutMillis())));
}
项目:grpc-java    文件:DelayedStream.java   
@Override
public void setCompressor(final Compressor compressor) {
  checkNotNull(compressor, "compressor");
  delayOrExecute(new Runnable() {
    @Override
    public void run() {
      realStream.setCompressor(compressor);
    }
  });
}
项目:grpc-java    文件:RetriableStream.java   
@Override
public final void setCompressor(final Compressor compressor) {
  class CompressorEntry implements BufferEntry {
    @Override
    public void runWith(Substream substream) {
      substream.stream.setCompressor(compressor);
    }
  }

  delayOrExecute(new CompressorEntry());
}
项目:armeria    文件:ArmeriaMessageFramer.java   
public void setCompressor(Compressor compressor) {
    this.compressor = compressor;
}
项目:grpc-java    文件:InProcessTransport.java   
@Override
public void setCompressor(Compressor compressor) {}
项目:grpc-java    文件:InProcessTransport.java   
@Override
public void setCompressor(Compressor compressor) {}
项目:grpc-java    文件:Framer.java   
/** Set the compressor used for compression. */
Framer setCompressor(Compressor compressor);
项目:grpc-java    文件:AbstractClientStream.java   
@Override
public Framer setCompressor(Compressor compressor) {
  return this;
}
项目:grpc-java    文件:MessageFramer.java   
@Override
public MessageFramer setCompressor(Compressor compressor) {
  this.compressor = checkNotNull(compressor, "Can't pass an empty compressor");
  return this;
}
项目:grpc-java    文件:AbstractStream.java   
@Override
public final void setCompressor(Compressor compressor) {
  framer().setCompressor(checkNotNull(compressor, "compressor"));
}
项目:grpc-java    文件:NoopClientStream.java   
@Override
public void setCompressor(Compressor compressor) {}
项目:grpc-java    文件:Stream.java   
/**
 * Sets the compressor on the framer.
 *
 * @param compressor the compressor to use
 */
void setCompressor(Compressor compressor);