3 * Copyright 2016 gRPC authors.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 #ifndef GRPC_IMPL_CODEGEN_COMPRESSION_TYPES_H
20 #define GRPC_IMPL_CODEGEN_COMPRESSION_TYPES_H
22 #include <grpc/impl/codegen/port_platform.h>
28 /** To be used as initial metadata key for the request of a concrete compression
30 #define GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY \
31 "grpc-internal-encoding-request"
33 /** To be used in channel arguments.
35 * \addtogroup grpc_arg_keys
37 /** Default compression algorithm for the channel.
38 * Its value is an int from the \a grpc_compression_algorithm enum. */
39 #define GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM \
40 "grpc.default_compression_algorithm"
41 /** Default compression level for the channel.
42 * Its value is an int from the \a grpc_compression_level enum. */
43 #define GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL "grpc.default_compression_level"
44 /** Compression algorithms supported by the channel.
45 * Its value is a bitset (an int). Bits correspond to algorithms in \a
46 * grpc_compression_algorithm. For example, its LSB corresponds to
47 * GRPC_COMPRESS_NONE, the next bit to GRPC_COMPRESS_DEFLATE, etc.
48 * Unset bits disable support for the algorithm. By default all algorithms are
49 * supported. It's not possible to disable GRPC_COMPRESS_NONE (the attempt will
51 #define GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET \
52 "grpc.compression_enabled_algorithms_bitset"
55 /** The various compression algorithms supported by gRPC (not sorted by
56 * compression level) */
58 GRPC_COMPRESS_NONE = 0,
59 GRPC_COMPRESS_DEFLATE,
61 /* EXPERIMENTAL: Stream compression is currently experimental. */
62 GRPC_COMPRESS_STREAM_GZIP,
63 /* TODO(ctiller): snappy */
64 GRPC_COMPRESS_ALGORITHMS_COUNT
65 } grpc_compression_algorithm;
67 /** Compression levels allow a party with knowledge of its peer's accepted
68 * encodings to request compression in an abstract way. The level-algorithm
69 * mapping is performed internally and depends on the peer's supported
70 * compression algorithms. */
72 GRPC_COMPRESS_LEVEL_NONE = 0,
73 GRPC_COMPRESS_LEVEL_LOW,
74 GRPC_COMPRESS_LEVEL_MED,
75 GRPC_COMPRESS_LEVEL_HIGH,
76 GRPC_COMPRESS_LEVEL_COUNT
77 } grpc_compression_level;
79 typedef struct grpc_compression_options {
80 /** All algs are enabled by default. This option corresponds to the channel
81 * argument key behind \a GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET
83 uint32_t enabled_algorithms_bitset;
85 /** The default compression level. It'll be used in the absence of call
86 * specific settings. This option corresponds to the channel
87 * argument key behind \a GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL. If present,
88 * takes precedence over \a default_algorithm.
89 * TODO(dgq): currently only available for server channels. */
90 struct grpc_compression_options_default_level {
92 grpc_compression_level level;
95 /** The default message compression algorithm. It'll be used in the absence of
96 * call specific settings. This option corresponds to the channel argument key
97 * behind \a GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM. */
98 struct grpc_compression_options_default_algorithm {
100 grpc_compression_algorithm algorithm;
102 } grpc_compression_options;
108 #endif /* GRPC_IMPL_CODEGEN_COMPRESSION_TYPES_H */