aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/grpc
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2017-07-12 12:19:58 -0700
committerGravatar Muxi Yan <mxyan@google.com>2017-07-12 14:04:30 -0700
commita4dc077d3c1eef677102f68496732b7dd2374875 (patch)
tree5ed3896ce6db5112aa7e443aa8eef97d1bc0e864 /include/grpc
parent96e49785518fa6e8723a68433d783632acd43108 (diff)
Stream compression configuration
Diffstat (limited to 'include/grpc')
-rw-r--r--include/grpc/compression.h10
-rw-r--r--include/grpc/impl/codegen/compression_types.h21
2 files changed, 28 insertions, 3 deletions
diff --git a/include/grpc/compression.h b/include/grpc/compression.h
index d47074c9b7..c30f28e924 100644
--- a/include/grpc/compression.h
+++ b/include/grpc/compression.h
@@ -30,12 +30,16 @@
extern "C" {
#endif
-/** Parses the first \a name_length bytes of \a name as a
- * grpc_compression_algorithm instance, updating \a algorithm. Returns 1 upon
- * success, 0 otherwise. */
+/** Parses \a value as a grpc_compression_algorithm instance, updating \a
+ * algorithm. Returns 1 upon success, 0 otherwise. */
GRPCAPI int grpc_compression_algorithm_parse(
grpc_slice value, grpc_compression_algorithm *algorithm);
+/** Parses \a value as a grpc_compression_algorithm instance for stream
+ * compression, updating \a algorithm. Returns 1 upon success, 0 otherwise. */
+GRPCAPI int grpc_stream_compression_algorithm_parse(
+ grpc_slice value, grpc_compression_algorithm *algorithm);
+
/** Updates \a name with the encoding name corresponding to a valid \a
* algorithm. Note that \a name is statically allocated and must *not* be freed.
* Returns 1 upon success, 0 otherwise. */
diff --git a/include/grpc/impl/codegen/compression_types.h b/include/grpc/impl/codegen/compression_types.h
index e39c13e88d..e51099f8d5 100644
--- a/include/grpc/impl/codegen/compression_types.h
+++ b/include/grpc/impl/codegen/compression_types.h
@@ -58,9 +58,21 @@ typedef enum {
GRPC_COMPRESS_DEFLATE,
GRPC_COMPRESS_GZIP,
/* TODO(ctiller): snappy */
+ GRPC_STREAM_COMPRESS_GZIP,
GRPC_COMPRESS_ALGORITHMS_COUNT
} grpc_compression_algorithm;
+#define GRPC_IS_STREAM_COMPRESSION_ALGORITHM(x) \
+ ((x) >= GRPC_STREAM_COMPRESS_GZIP && (x) < GRPC_COMPRESS_ALGORITHMS_COUNT)
+#define GRPC_IS_MESSAGE_COMPRESSION_ALGORITHM(x) \
+ ((x) >= GRPC_COMPRESS_DEFLATE && (x) <= GRPC_COMPRESS_GZIP)
+#define GRPC_STREAM_COMPRESS_FLAG_OFFSET \
+ (GRPC_STREAM_COMPRESS_GZIP - GRPC_COMPRESS_DEFLATE)
+#define GRPC_MESSAGE_COMPRESSION_ALGORITHM_MASK \
+ ((1u << GRPC_COMPRESS_DEFLATE) | (1u << GRPC_COMPRESS_GZIP))
+#define GRPC_STREAM_COMPRESSION_ALGORITHM_MASK \
+ ((1u << GRPC_STREAM_COMPRESS_GZIP))
+
/** Compression levels allow a party with knowledge of its peer's accepted
* encodings to request compression in an abstract way. The level-algorithm
* mapping is performed internally and depends on the peer's supported
@@ -70,9 +82,18 @@ typedef enum {
GRPC_COMPRESS_LEVEL_LOW,
GRPC_COMPRESS_LEVEL_MED,
GRPC_COMPRESS_LEVEL_HIGH,
+ GRPC_STREAM_COMPRESS_LEVEL_LOW,
+ GRPC_STREAM_COMPRESS_LEVEL_MED,
+ GRPC_STREAM_COMPRESS_LEVEL_HIGH,
GRPC_COMPRESS_LEVEL_COUNT
} grpc_compression_level;
+#define GRPC_IS_STREAM_COMPRESSION_LEVEL(x) \
+ (((x) >= GRPC_STREAM_COMPRESS_LEVEL_LOW) && \
+ ((x) <= GRPC_STREAM_COMPRESS_LEVEL_HIGH))
+#define GRPC_IS_MESSAGE_COMPRESSION_LEVEL(x) \
+ (((x) >= GRPC_COMPRESS_LEVEL_LOW) && ((x) <= GRPC_COMPRESS_LEVEL_HIGH))
+
typedef struct grpc_compression_options {
/** All algs are enabled by default. This option corresponds to the channel
* argument key behind \a GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET