From f31f0962740cd263dffe383f6bf1b8a56c4ddbdb Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Fri, 10 Feb 2017 14:53:58 -0800 Subject: Use call context to propagare LR costs --- include/grpc++/impl/codegen/server_context.h | 9 +++++++-- include/grpc++/test/server_context_test_spouse.h | 14 +++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'include/grpc++') diff --git a/include/grpc++/impl/codegen/server_context.h b/include/grpc++/impl/codegen/server_context.h index 8c7fe0809e..43bbff6ce9 100644 --- a/include/grpc++/impl/codegen/server_context.h +++ b/include/grpc++/impl/codegen/server_context.h @@ -36,6 +36,10 @@ #include #include +#include + +#include +#include #include #include @@ -43,14 +47,12 @@ #include #include #include -#include struct grpc_metadata; struct grpc_call; struct census_context; namespace grpc { - class ClientContext; template class ServerAsyncReader; @@ -143,6 +145,9 @@ class ServerContext { } void set_compression_algorithm(grpc_compression_algorithm algorithm); + // Set the load reporting costs in \a cost_data for the call. + void SetLoadReportingCosts(const std::vector& cost_data); + std::shared_ptr auth_context() const { if (auth_context_.get() == nullptr) { auth_context_ = CreateAuthContext(call_); diff --git a/include/grpc++/test/server_context_test_spouse.h b/include/grpc++/test/server_context_test_spouse.h index b2482854b5..4cb84e77c1 100644 --- a/include/grpc++/test/server_context_test_spouse.h +++ b/include/grpc++/test/server_context_test_spouse.h @@ -48,10 +48,22 @@ class ServerContextTestSpouse { // Inject client metadata to the ServerContext for the test. The test spouse // must be alive when ServerContext::client_metadata is called. - void AddClientMetadata(const grpc::string& key, const grpc::string& value); + void AddClientMetadata(const grpc::string& key, const grpc::string& value) { + client_metadata_storage_.insert( + std::pair(key, value)); + ctx_->client_metadata_.map()->clear(); + for (auto iter = client_metadata_storage_.begin(); + iter != client_metadata_storage_.end(); ++iter) { + ctx_->client_metadata_.map()->insert( + std::pair(iter->first.c_str(), + iter->second.c_str())); + } + } + std::multimap GetInitialMetadata() const { return ctx_->initial_metadata_; } + std::multimap GetTrailingMetadata() const { return ctx_->trailing_metadata_; } -- cgit v1.2.3