Remove `include/grpcpp/impl/codegen/metadata_map.h` (#31531)

* Remove `include/grpcpp/impl/codegen/metadata_map.h`

* Automated change: Fix sanity tests
pull/31734/head
Cheng-Yu Chung 2 years ago committed by GitHub
parent 15c4a98bc7
commit e83d69bdf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      BUILD
  2. 2
      CMakeLists.txt
  3. 2
      build_autogenerated.yaml
  4. 1
      gRPC-C++.podspec
  5. 2
      include/grpcpp/client_context.h
  6. 84
      include/grpcpp/impl/codegen/metadata_map.h
  7. 105
      include/grpcpp/impl/metadata_map.h
  8. 1
      include/grpcpp/server_context.h
  9. 2
      include/grpcpp/support/interceptor.h
  10. 2
      src/cpp/server/server_cc.cc
  11. 2
      src/cpp/server/server_context.cc
  12. 2
      tools/codegen/core/gen_experiments.py
  13. 1
      tools/doxygen/Doxyfile.c++
  14. 1
      tools/doxygen/Doxyfile.c++.internal

@ -345,6 +345,7 @@ GRPCXX_PUBLIC_HDRS = [
"include/grpcpp/impl/delegating_channel.h", "include/grpcpp/impl/delegating_channel.h",
"include/grpcpp/impl/grpc_library.h", "include/grpcpp/impl/grpc_library.h",
"include/grpcpp/impl/intercepted_channel.h", "include/grpcpp/impl/intercepted_channel.h",
"include/grpcpp/impl/metadata_map.h",
"include/grpcpp/impl/method_handler_impl.h", "include/grpcpp/impl/method_handler_impl.h",
"include/grpcpp/impl/rpc_method.h", "include/grpcpp/impl/rpc_method.h",
"include/grpcpp/impl/rpc_service_method.h", "include/grpcpp/impl/rpc_service_method.h",

2
CMakeLists.txt generated

@ -3449,6 +3449,7 @@ foreach(_hdr
include/grpcpp/impl/delegating_channel.h include/grpcpp/impl/delegating_channel.h
include/grpcpp/impl/grpc_library.h include/grpcpp/impl/grpc_library.h
include/grpcpp/impl/intercepted_channel.h include/grpcpp/impl/intercepted_channel.h
include/grpcpp/impl/metadata_map.h
include/grpcpp/impl/method_handler_impl.h include/grpcpp/impl/method_handler_impl.h
include/grpcpp/impl/rpc_method.h include/grpcpp/impl/rpc_method.h
include/grpcpp/impl/rpc_service_method.h include/grpcpp/impl/rpc_service_method.h
@ -4140,6 +4141,7 @@ foreach(_hdr
include/grpcpp/impl/delegating_channel.h include/grpcpp/impl/delegating_channel.h
include/grpcpp/impl/grpc_library.h include/grpcpp/impl/grpc_library.h
include/grpcpp/impl/intercepted_channel.h include/grpcpp/impl/intercepted_channel.h
include/grpcpp/impl/metadata_map.h
include/grpcpp/impl/method_handler_impl.h include/grpcpp/impl/method_handler_impl.h
include/grpcpp/impl/rpc_method.h include/grpcpp/impl/rpc_method.h
include/grpcpp/impl/rpc_service_method.h include/grpcpp/impl/rpc_service_method.h

@ -2824,6 +2824,7 @@ libs:
- include/grpcpp/impl/delegating_channel.h - include/grpcpp/impl/delegating_channel.h
- include/grpcpp/impl/grpc_library.h - include/grpcpp/impl/grpc_library.h
- include/grpcpp/impl/intercepted_channel.h - include/grpcpp/impl/intercepted_channel.h
- include/grpcpp/impl/metadata_map.h
- include/grpcpp/impl/method_handler_impl.h - include/grpcpp/impl/method_handler_impl.h
- include/grpcpp/impl/rpc_method.h - include/grpcpp/impl/rpc_method.h
- include/grpcpp/impl/rpc_service_method.h - include/grpcpp/impl/rpc_service_method.h
@ -3246,6 +3247,7 @@ libs:
- include/grpcpp/impl/delegating_channel.h - include/grpcpp/impl/delegating_channel.h
- include/grpcpp/impl/grpc_library.h - include/grpcpp/impl/grpc_library.h
- include/grpcpp/impl/intercepted_channel.h - include/grpcpp/impl/intercepted_channel.h
- include/grpcpp/impl/metadata_map.h
- include/grpcpp/impl/method_handler_impl.h - include/grpcpp/impl/method_handler_impl.h
- include/grpcpp/impl/rpc_method.h - include/grpcpp/impl/rpc_method.h
- include/grpcpp/impl/rpc_service_method.h - include/grpcpp/impl/rpc_service_method.h

1
gRPC-C++.podspec generated

@ -150,6 +150,7 @@ Pod::Spec.new do |s|
'include/grpcpp/impl/delegating_channel.h', 'include/grpcpp/impl/delegating_channel.h',
'include/grpcpp/impl/grpc_library.h', 'include/grpcpp/impl/grpc_library.h',
'include/grpcpp/impl/intercepted_channel.h', 'include/grpcpp/impl/intercepted_channel.h',
'include/grpcpp/impl/metadata_map.h',
'include/grpcpp/impl/method_handler_impl.h', 'include/grpcpp/impl/method_handler_impl.h',
'include/grpcpp/impl/rpc_method.h', 'include/grpcpp/impl/rpc_method.h',
'include/grpcpp/impl/rpc_service_method.h', 'include/grpcpp/impl/rpc_service_method.h',

@ -42,8 +42,8 @@
#include <grpc/impl/codegen/propagation_bits.h> #include <grpc/impl/codegen/propagation_bits.h>
#include <grpcpp/impl/codegen/core_codegen_interface.h> #include <grpcpp/impl/codegen/core_codegen_interface.h>
#include <grpcpp/impl/codegen/create_auth_context.h> #include <grpcpp/impl/codegen/create_auth_context.h>
#include <grpcpp/impl/codegen/metadata_map.h>
#include <grpcpp/impl/codegen/sync.h> #include <grpcpp/impl/codegen/sync.h>
#include <grpcpp/impl/metadata_map.h>
#include <grpcpp/impl/rpc_method.h> #include <grpcpp/impl/rpc_method.h>
#include <grpcpp/security/auth_context.h> #include <grpcpp/security/auth_context.h>
#include <grpcpp/support/client_interceptor.h> #include <grpcpp/support/client_interceptor.h>

@ -21,87 +21,7 @@
// IWYU pragma: private // IWYU pragma: private
#include <map> /// TODO(chengyuc): Remove this file after solving compatibility.
#include <grpcpp/impl/metadata_map.h>
#include <grpc/impl/codegen/log.h>
#include <grpcpp/impl/codegen/slice.h>
namespace grpc {
namespace internal {
const char kBinaryErrorDetailsKey[] = "grpc-status-details-bin";
class MetadataMap {
public:
MetadataMap() { Setup(); }
~MetadataMap() { Destroy(); }
std::string GetBinaryErrorDetails() {
// if filled_, extract from the multimap for O(log(n))
if (filled_) {
auto iter = map_.find(kBinaryErrorDetailsKey);
if (iter != map_.end()) {
return std::string(iter->second.begin(), iter->second.length());
}
}
// if not yet filled, take the O(n) lookup to avoid allocating the
// multimap until it is requested.
// TODO(ncteisen): plumb this through core as a first class object, just
// like code and message.
else {
for (size_t i = 0; i < arr_.count; i++) {
if (strncmp(reinterpret_cast<const char*>(
GRPC_SLICE_START_PTR(arr_.metadata[i].key)),
kBinaryErrorDetailsKey,
GRPC_SLICE_LENGTH(arr_.metadata[i].key)) == 0) {
return std::string(reinterpret_cast<const char*>(
GRPC_SLICE_START_PTR(arr_.metadata[i].value)),
GRPC_SLICE_LENGTH(arr_.metadata[i].value));
}
}
}
return std::string();
}
std::multimap<grpc::string_ref, grpc::string_ref>* map() {
FillMap();
return &map_;
}
grpc_metadata_array* arr() { return &arr_; }
void Reset() {
filled_ = false;
map_.clear();
Destroy();
Setup();
}
private:
bool filled_ = false;
grpc_metadata_array arr_;
std::multimap<grpc::string_ref, grpc::string_ref> map_;
void Destroy() {
g_core_codegen_interface->grpc_metadata_array_destroy(&arr_);
}
void Setup() { memset(&arr_, 0, sizeof(arr_)); }
void FillMap() {
if (filled_) return;
filled_ = true;
for (size_t i = 0; i < arr_.count; i++) {
// TODO(yangg) handle duplicates?
map_.insert(std::pair<grpc::string_ref, grpc::string_ref>(
StringRefFromSlice(&arr_.metadata[i].key),
StringRefFromSlice(&arr_.metadata[i].value)));
}
}
};
} // namespace internal
} // namespace grpc
#endif // GRPCPP_IMPL_CODEGEN_METADATA_MAP_H #endif // GRPCPP_IMPL_CODEGEN_METADATA_MAP_H

@ -0,0 +1,105 @@
/*
*
* Copyright 2015 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPCPP_IMPL_METADATA_MAP_H
#define GRPCPP_IMPL_METADATA_MAP_H
#include <map>
#include <grpc/support/log.h>
#include <grpcpp/support/slice.h>
namespace grpc {
namespace internal {
const char kBinaryErrorDetailsKey[] = "grpc-status-details-bin";
class MetadataMap {
public:
MetadataMap() { Setup(); }
~MetadataMap() { Destroy(); }
std::string GetBinaryErrorDetails() {
// if filled_, extract from the multimap for O(log(n))
if (filled_) {
auto iter = map_.find(kBinaryErrorDetailsKey);
if (iter != map_.end()) {
return std::string(iter->second.begin(), iter->second.length());
}
}
// if not yet filled, take the O(n) lookup to avoid allocating the
// multimap until it is requested.
// TODO(ncteisen): plumb this through core as a first class object, just
// like code and message.
else {
for (size_t i = 0; i < arr_.count; i++) {
if (strncmp(reinterpret_cast<const char*>(
GRPC_SLICE_START_PTR(arr_.metadata[i].key)),
kBinaryErrorDetailsKey,
GRPC_SLICE_LENGTH(arr_.metadata[i].key)) == 0) {
return std::string(reinterpret_cast<const char*>(
GRPC_SLICE_START_PTR(arr_.metadata[i].value)),
GRPC_SLICE_LENGTH(arr_.metadata[i].value));
}
}
}
return std::string();
}
std::multimap<grpc::string_ref, grpc::string_ref>* map() {
FillMap();
return &map_;
}
grpc_metadata_array* arr() { return &arr_; }
void Reset() {
filled_ = false;
map_.clear();
Destroy();
Setup();
}
private:
bool filled_ = false;
grpc_metadata_array arr_;
std::multimap<grpc::string_ref, grpc::string_ref> map_;
void Destroy() {
g_core_codegen_interface->grpc_metadata_array_destroy(&arr_);
}
void Setup() { memset(&arr_, 0, sizeof(arr_)); }
void FillMap() {
if (filled_) return;
filled_ = true;
for (size_t i = 0; i < arr_.count; i++) {
// TODO(yangg) handle duplicates?
map_.insert(std::pair<grpc::string_ref, grpc::string_ref>(
StringRefFromSlice(&arr_.metadata[i].key),
StringRefFromSlice(&arr_.metadata[i].value)));
}
}
};
} // namespace internal
} // namespace grpc
#endif // GRPCPP_IMPL_METADATA_MAP_H

@ -34,6 +34,7 @@
#include <grpcpp/impl/codegen/create_auth_context.h> #include <grpcpp/impl/codegen/create_auth_context.h>
#include <grpcpp/impl/codegen/metadata_map.h> #include <grpcpp/impl/codegen/metadata_map.h>
#include <grpcpp/impl/completion_queue_tag.h> #include <grpcpp/impl/completion_queue_tag.h>
#include <grpcpp/impl/metadata_map.h>
#include <grpcpp/impl/rpc_service_method.h> #include <grpcpp/impl/rpc_service_method.h>
#include <grpcpp/security/auth_context.h> #include <grpcpp/security/auth_context.h>
#include <grpcpp/support/callback_common.h> #include <grpcpp/support/callback_common.h>

@ -25,7 +25,7 @@
#include <grpc/impl/codegen/grpc_types.h> #include <grpc/impl/codegen/grpc_types.h>
#include <grpcpp/impl/codegen/core_codegen_interface.h> #include <grpcpp/impl/codegen/core_codegen_interface.h>
#include <grpcpp/impl/codegen/metadata_map.h> #include <grpcpp/impl/metadata_map.h>
#include <grpcpp/support/byte_buffer.h> #include <grpcpp/support/byte_buffer.h>
#include <grpcpp/support/config.h> #include <grpcpp/support/config.h>
#include <grpcpp/support/string_ref.h> #include <grpcpp/support/string_ref.h>

@ -46,10 +46,10 @@
#include <grpcpp/impl/call_op_set.h> #include <grpcpp/impl/call_op_set.h>
#include <grpcpp/impl/call_op_set_interface.h> #include <grpcpp/impl/call_op_set_interface.h>
#include <grpcpp/impl/codegen/interceptor_common.h> #include <grpcpp/impl/codegen/interceptor_common.h>
#include <grpcpp/impl/codegen/metadata_map.h>
#include <grpcpp/impl/codegen/sync.h> #include <grpcpp/impl/codegen/sync.h>
#include <grpcpp/impl/completion_queue_tag.h> #include <grpcpp/impl/completion_queue_tag.h>
#include <grpcpp/impl/grpc_library.h> #include <grpcpp/impl/grpc_library.h>
#include <grpcpp/impl/metadata_map.h>
#include <grpcpp/impl/rpc_method.h> #include <grpcpp/impl/rpc_method.h>
#include <grpcpp/impl/rpc_service_method.h> #include <grpcpp/impl/rpc_service_method.h>
#include <grpcpp/impl/server_callback_handlers.h> #include <grpcpp/impl/server_callback_handlers.h>

@ -45,9 +45,9 @@
#include <grpcpp/impl/call_op_set.h> #include <grpcpp/impl/call_op_set.h>
#include <grpcpp/impl/call_op_set_interface.h> #include <grpcpp/impl/call_op_set_interface.h>
#include <grpcpp/impl/codegen/interceptor_common.h> #include <grpcpp/impl/codegen/interceptor_common.h>
#include <grpcpp/impl/codegen/metadata_map.h>
#include <grpcpp/impl/completion_queue_tag.h> #include <grpcpp/impl/completion_queue_tag.h>
#include <grpcpp/impl/grpc_library.h> #include <grpcpp/impl/grpc_library.h>
#include <grpcpp/impl/metadata_map.h>
#include <grpcpp/server_context.h> #include <grpcpp/server_context.h>
#include <grpcpp/support/callback_common.h> #include <grpcpp/support/callback_common.h>
#include <grpcpp/support/interceptor.h> #include <grpcpp/support/interceptor.h>

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
""" """
Generate experiment related code artifacts. Generate experiment related code artifacts.
Invoke as: tools/codegen/core/gen_experiments.py Invoke as: tools/codegen/core/gen_experiments.py
Experiment definitions are in src/core/lib/experiments/experiments.yaml Experiment definitions are in src/core/lib/experiments/experiments.yaml

@ -1014,6 +1014,7 @@ include/grpcpp/impl/completion_queue_tag.h \
include/grpcpp/impl/delegating_channel.h \ include/grpcpp/impl/delegating_channel.h \
include/grpcpp/impl/grpc_library.h \ include/grpcpp/impl/grpc_library.h \
include/grpcpp/impl/intercepted_channel.h \ include/grpcpp/impl/intercepted_channel.h \
include/grpcpp/impl/metadata_map.h \
include/grpcpp/impl/method_handler_impl.h \ include/grpcpp/impl/method_handler_impl.h \
include/grpcpp/impl/rpc_method.h \ include/grpcpp/impl/rpc_method.h \
include/grpcpp/impl/rpc_service_method.h \ include/grpcpp/impl/rpc_service_method.h \

@ -1014,6 +1014,7 @@ include/grpcpp/impl/completion_queue_tag.h \
include/grpcpp/impl/delegating_channel.h \ include/grpcpp/impl/delegating_channel.h \
include/grpcpp/impl/grpc_library.h \ include/grpcpp/impl/grpc_library.h \
include/grpcpp/impl/intercepted_channel.h \ include/grpcpp/impl/intercepted_channel.h \
include/grpcpp/impl/metadata_map.h \
include/grpcpp/impl/method_handler_impl.h \ include/grpcpp/impl/method_handler_impl.h \
include/grpcpp/impl/rpc_method.h \ include/grpcpp/impl/rpc_method.h \
include/grpcpp/impl/rpc_service_method.h \ include/grpcpp/impl/rpc_service_method.h \

Loading…
Cancel
Save