26 #include "absl/memory/memory.h"
27 #include "absl/strings/str_cat.h"
28 #include "absl/strings/str_join.h"
30 #define GRPC_ARG_HIERARCHICAL_PATH "grpc.internal.address.hierarchical_path"
40 explicit HierarchicalPathAttribute(std::vector<std::string>
path)
43 std::unique_ptr<AttributeInterface>
Copy()
const override {
44 return absl::make_unique<HierarchicalPathAttribute>(
path_);
47 int Cmp(
const AttributeInterface* other)
const override {
48 const std::vector<std::string>& other_path =
49 static_cast<const HierarchicalPathAttribute*
>(other)->
path_;
50 for (
size_t i = 0;
i <
path_.size(); ++
i) {
51 if (other_path.size() ==
i)
return 1;
52 int r =
path_[
i].compare(other_path[
i]);
55 if (other_path.size() >
path_.size())
return -1;
63 const std::vector<std::string>&
path()
const {
return path_; }
71 std::unique_ptr<ServerAddress::AttributeInterface>
73 return absl::make_unique<HierarchicalPathAttribute>(
std::move(
path));
78 if (!addresses.
ok())
return addresses.
status();
81 const HierarchicalPathAttribute* path_attribute =
82 static_cast<const HierarchicalPathAttribute*
>(
84 if (path_attribute ==
nullptr)
continue;
85 const std::vector<std::string>&
path = path_attribute->path();
88 std::unique_ptr<HierarchicalPathAttribute> new_attribute;
91 std::vector<std::string> remaining_path(
it,
path.end());
92 new_attribute = absl::make_unique<HierarchicalPathAttribute>(
95 target_list.emplace_back(address.WithAttribute(