api,stub:Stabilize part of compression agreed to in the stabilization meeting (#9942)

* api,stub:Stabilize part of compression agreed to in the stabilization meeting.

addresses part of #1704
This commit is contained in:
Larry Safran 2023-03-09 20:25:43 +00:00 committed by GitHub
parent 7ecb909776
commit 136665f00e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 13 deletions

View File

@ -138,13 +138,12 @@ public final class CallOptions {
/** /**
* Sets the compression to use for the call. The compressor must be a valid name known in the * Sets the compression to use for the call. The compressor must be a valid name known in the
* {@link CompressorRegistry}. * {@link CompressorRegistry}. By default, the "gzip" compressor will be available.
* *
* <p>It is only safe to call this if the server supports the compression format chosen. There is * <p>It is only safe to call this if the server supports the compression format chosen. There is
* no negotiation performed; if the server does not support the compression chosen, the call will * no negotiation performed; if the server does not support the compression chosen, the call will
* fail. * fail.
*/ */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1704")
public CallOptions withCompression(@Nullable String compressorName) { public CallOptions withCompression(@Nullable String compressorName) {
Builder builder = toBuilder(this); Builder builder = toBuilder(this);
builder.compressorName = compressorName; builder.compressorName = compressorName;
@ -207,7 +206,6 @@ public final class CallOptions {
/** /**
* Returns the compressor's name. * Returns the compressor's name.
*/ */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1704")
@Nullable @Nullable
public String getCompressor() { public String getCompressor() {
return compressorName; return compressorName;

View File

@ -189,16 +189,15 @@ public abstract class ServerCall<ReqT, RespT> {
* encoding has been negotiated, this is a no-op. By default per-message compression is enabled, * encoding has been negotiated, this is a no-op. By default per-message compression is enabled,
* but may not have any effect if compression is not enabled on the call. * but may not have any effect if compression is not enabled on the call.
*/ */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1704")
public void setMessageCompression(boolean enabled) { public void setMessageCompression(boolean enabled) {
// noop // noop
} }
/** /**
* Sets the compression algorithm for this call. If the server does not support the compression * Sets the compression algorithm for this call. This compression is utilized for sending. If
* algorithm, the call will fail. This method may only be called before {@link #sendHeaders}. * the server does not support the compression algorithm, the call will fail. This method may
* The compressor to use will be looked up in the {@link CompressorRegistry}. Default gRPC * only be called before {@link #sendHeaders}. The compressor to use will be looked up in the
* servers support the "gzip" compressor. * {@link CompressorRegistry}. Default gRPC servers support the "gzip" compressor.
* *
* <p>It is safe to call this even if the client does not support the compression format chosen. * <p>It is safe to call this even if the client does not support the compression format chosen.
* The implementation will handle negotiation with the client and may fall back to no compression. * The implementation will handle negotiation with the client and may fall back to no compression.
@ -206,7 +205,6 @@ public abstract class ServerCall<ReqT, RespT> {
* @param compressor the name of the compressor to use. * @param compressor the name of the compressor to use.
* @throws IllegalArgumentException if the compressor name can not be found. * @throws IllegalArgumentException if the compressor name can not be found.
*/ */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1704")
public void setCompression(String compressor) { public void setCompression(String compressor) {
// noop // noop
} }

View File

@ -163,14 +163,11 @@ public abstract class AbstractStub<S extends AbstractStub<S>> {
/** /**
* Set's the compressor name to use for the call. It is the responsibility of the application * Set's the compressor name to use for the call. It is the responsibility of the application
* to make sure the server supports decoding the compressor picked by the client. To be clear, * to make sure the server supports decoding the compressor picked by the client. To be clear,
* this is the compressor used by the stub to compress messages to the server. To get * this is the compressor used by the stub to compress messages to the server.
* compressed responses from the server, set the appropriate {@link io.grpc.DecompressorRegistry}
* on the {@link io.grpc.ManagedChannelBuilder}.
* *
* @since 1.0.0 * @since 1.0.0
* @param compressorName the name (e.g. "gzip") of the compressor to use. * @param compressorName the name (e.g. "gzip") of the compressor to use.
*/ */
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1704")
public final S withCompression(String compressorName) { public final S withCompression(String compressorName) {
return build(channel, callOptions.withCompression(compressorName)); return build(channel, callOptions.withCompression(compressorName));
} }