diff options
author | Craig Tiller <craig.tiller@gmail.com> | 2015-07-19 15:35:17 -0700 |
---|---|---|
committer | Craig Tiller <craig.tiller@gmail.com> | 2015-07-19 15:35:17 -0700 |
commit | b4e70366c6b25d1127e66fd28c6256b19467dd9b (patch) | |
tree | 7f51ee747a9ed1200899b1c3e19752d85ce878ed /src/cpp | |
parent | d82d0b295b51e1385481be381eef325423441a65 (diff) | |
parent | 0c2f1626c0082ab91aed27f77bbe01008d878db2 (diff) |
Merge branch 'decompression' of https://github.com/dgquintas/grpc into dgquintas-decompression
Conflicts:
Makefile
vsprojects/Grpc.mak
Diffstat (limited to 'src/cpp')
-rw-r--r-- | src/cpp/client/channel_arguments.cc | 5 | ||||
-rw-r--r-- | src/cpp/client/client_context.cc | 15 | ||||
-rw-r--r-- | src/cpp/proto/proto_utils.cc | 4 | ||||
-rw-r--r-- | src/cpp/server/server_context.cc | 19 |
4 files changed, 40 insertions, 3 deletions
diff --git a/src/cpp/client/channel_arguments.cc b/src/cpp/client/channel_arguments.cc index b271650673..92ac5ea6fd 100644 --- a/src/cpp/client/channel_arguments.cc +++ b/src/cpp/client/channel_arguments.cc @@ -37,8 +37,9 @@ namespace grpc { -void ChannelArguments::SetCompressionLevel(grpc_compression_level level) { - SetInt(GRPC_COMPRESSION_LEVEL_ARG, level); +void ChannelArguments::_Experimental_SetCompressionAlgorithm( + grpc_compression_algorithm algorithm) { + SetInt(GRPC_COMPRESSION_ALGORITHM_ARG, algorithm); } void ChannelArguments::SetInt(const grpc::string& key, int value) { diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index 372f3e27ec..69216d2030 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -34,8 +34,11 @@ #include <grpc++/client_context.h> #include <grpc/grpc.h> +#include <grpc/support/string_util.h> #include <grpc++/credentials.h> #include <grpc++/time.h> + +#include "src/core/channel/compress_filter.h" #include "src/cpp/common/create_auth_context.h" namespace grpc { @@ -76,6 +79,18 @@ void ClientContext::set_call(grpc_call* call, } } +void ClientContext::_experimental_set_compression_algorithm( + grpc_compression_algorithm algorithm) { + char* algorithm_name = NULL; + if (!grpc_compression_algorithm_name(algorithm, &algorithm_name)) { + gpr_log(GPR_ERROR, "Name for compression algorithm '%d' unknown.", + algorithm); + abort(); + } + GPR_ASSERT(algorithm_name != NULL); + AddMetadata(GRPC_COMPRESS_REQUEST_ALGORITHM_KEY, algorithm_name); +} + std::shared_ptr<const AuthContext> ClientContext::auth_context() const { if (auth_context_.get() == nullptr) { auth_context_ = CreateAuthContext(call_); diff --git a/src/cpp/proto/proto_utils.cc b/src/cpp/proto/proto_utils.cc index 7b2a65e99b..63f4a3a0bc 100644 --- a/src/cpp/proto/proto_utils.cc +++ b/src/cpp/proto/proto_utils.cc @@ -103,7 +103,9 @@ class GrpcBufferReader GRPC_FINAL : byte_count_(0), backup_count_(0) { grpc_byte_buffer_reader_init(&reader_, buffer); } - ~GrpcBufferReader() GRPC_OVERRIDE {} + ~GrpcBufferReader() GRPC_OVERRIDE { + grpc_byte_buffer_reader_destroy(&reader_); + } bool Next(const void** data, int* size) GRPC_OVERRIDE { if (backup_count_ > 0) { diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc index 3b8a026996..bf7a4ba5ec 100644 --- a/src/cpp/server/server_context.cc +++ b/src/cpp/server/server_context.cc @@ -39,6 +39,7 @@ #include <grpc++/impl/sync.h> #include <grpc++/time.h> +#include "src/core/channel/compress_filter.h" #include "src/cpp/common/create_auth_context.h" namespace grpc { @@ -148,6 +149,24 @@ bool ServerContext::IsCancelled() const { return completion_op_ && completion_op_->CheckCancelled(cq_); } +void ServerContext::set_compression_level(grpc_compression_level level) { + const grpc_compression_algorithm algorithm_for_level = + grpc_compression_algorithm_for_level(level); + set_compression_algorithm(algorithm_for_level); +} + +void ServerContext::set_compression_algorithm( + grpc_compression_algorithm algorithm) { + char* algorithm_name = NULL; + if (!grpc_compression_algorithm_name(algorithm, &algorithm_name)) { + gpr_log(GPR_ERROR, "Name for compression algorithm '%d' unknown.", + algorithm); + abort(); + } + GPR_ASSERT(algorithm_name != NULL); + AddInitialMetadata(GRPC_COMPRESS_REQUEST_ALGORITHM_KEY, algorithm_name); +} + void ServerContext::set_call(grpc_call* call) { call_ = call; auth_context_ = CreateAuthContext(call); |