diff options
author | David Garcia Quintas <dgq@google.com> | 2016-05-17 19:14:51 -0700 |
---|---|---|
committer | David Garcia Quintas <dgq@google.com> | 2016-05-17 19:14:51 -0700 |
commit | b0dd253a60921d0ec08d41af1204237a570d59d5 (patch) | |
tree | 81cb69b7fa71419e7ef7a80a1b22b1f8528e0e90 /src/core/lib | |
parent | f54171c18b427a3165b0612e316d0d86db96c176 (diff) |
Added grpc_channel_get_default_compression_level()
Diffstat (limited to 'src/core/lib')
-rw-r--r-- | src/core/lib/surface/channel.c | 25 | ||||
-rw-r--r-- | src/core/lib/surface/channel.h | 5 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/core/lib/surface/channel.c b/src/core/lib/surface/channel.c index b6b760b5d8..a7aa9365a0 100644 --- a/src/core/lib/surface/channel.c +++ b/src/core/lib/surface/channel.c @@ -68,7 +68,13 @@ struct grpc_channel { gpr_mu registered_call_mu; registered_call *registered_calls; + char *target; + + struct { + bool is_set; + grpc_compression_level default_compression_level; + } maybe_default_compression_level; }; #define CHANNEL_STACK_FROM_CHANNEL(c) ((grpc_channel_stack *)((c) + 1)) @@ -151,6 +157,13 @@ grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target, ":authority", args->args[i].value.string); } } + } else if (0 == strcmp(args->args[i].key, + GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL)) { + channel->maybe_default_compression_level.is_set = true; + GPR_ASSERT(args->args[i].value.integer >= 0 && + args->args[i].value.integer < GRPC_COMPRESS_LEVEL_COUNT); + channel->maybe_default_compression_level.default_compression_level = + (grpc_compression_level)args->args[i].value.integer; } } grpc_channel_args_destroy(args); @@ -324,3 +337,15 @@ grpc_mdelem *grpc_channel_get_reffed_status_elem(grpc_channel *channel, int i) { uint32_t grpc_channel_get_max_message_length(grpc_channel *channel) { return channel->max_message_length; } + +bool grpc_channel_default_compression_level(grpc_channel *channel, + grpc_compression_level *level) { + if (channel->maybe_default_compression_level.is_set) { + *level = channel->maybe_default_compression_level.default_compression_level; + return true; + } + return false; +} + +bool grpc_channel_default_compression_algorithm( + grpc_channel *channel, grpc_compression_algorithm *algorithm); diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h index 22dae930e4..a8631eea87 100644 --- a/src/core/lib/surface/channel.h +++ b/src/core/lib/surface/channel.h @@ -71,4 +71,9 @@ void grpc_channel_internal_unref(grpc_exec_ctx *exec_ctx, grpc_channel_internal_unref(exec_ctx, channel) #endif +/** If the channel has an associated default compression level, return it in \a + * level and return true. Otherwise return false. */ +bool grpc_channel_default_compression_level(grpc_channel *channel, + grpc_compression_level *level); + #endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_H */ |