remove unused code

pull/23533/head
Mark D. Roth 5 years ago
parent 87238bc226
commit bc06fdc559
  1. 116
      src/core/ext/xds/xds_api.cc

@ -653,122 +653,6 @@ inline std::string UpbStringToStdString(const upb_strview& str) {
return std::string(str.data, str.size);
}
inline void AddStringField(const char* name, const upb_strview& value,
std::vector<std::string>* fields,
bool add_if_empty = false) {
if (value.size > 0 || add_if_empty) {
fields->emplace_back(
absl::StrCat(name, ": \"", UpbStringToAbsl(value), "\""));
}
}
inline void AddUInt32ValueField(const char* name,
const google_protobuf_UInt32Value* value,
std::vector<std::string>* fields) {
if (value != nullptr) {
fields->emplace_back(absl::StrCat(
name, " { value: ", google_protobuf_UInt32Value_value(value), " }"));
}
}
inline void AddLocalityField(int indent_level,
const envoy_config_core_v3_Locality* locality,
std::vector<std::string>* fields) {
std::string indent =
absl::StrJoin(std::vector<std::string>(indent_level, " "), "");
// region
std::string field = absl::StrCat(indent, "region");
AddStringField(field.c_str(), envoy_config_core_v3_Locality_region(locality),
fields);
// zone
field = absl::StrCat(indent, "zone");
AddStringField(field.c_str(), envoy_config_core_v3_Locality_zone(locality),
fields);
// sub_zone
field = absl::StrCat(indent, "sub_zone");
AddStringField(field.c_str(),
envoy_config_core_v3_Locality_sub_zone(locality), fields);
}
void AddNodeLogFields(const envoy_config_core_v3_Node* node,
const std::string& build_version,
std::vector<std::string>* fields) {
fields->emplace_back("node {");
// id
AddStringField(" id", envoy_config_core_v3_Node_id(node), fields);
// metadata
const google_protobuf_Struct* metadata =
envoy_config_core_v3_Node_metadata(node);
if (metadata != nullptr) {
fields->emplace_back(" metadata {");
size_t entry_idx = UPB_MAP_BEGIN;
while (true) {
const google_protobuf_Struct_FieldsEntry* entry =
google_protobuf_Struct_fields_next(metadata, &entry_idx);
if (entry == nullptr) break;
fields->emplace_back(" field {");
// key
AddStringField(" key", google_protobuf_Struct_FieldsEntry_key(entry),
fields);
// value
const google_protobuf_Value* value =
google_protobuf_Struct_FieldsEntry_value(entry);
if (value != nullptr) {
std::string value_str;
if (google_protobuf_Value_has_string_value(value)) {
value_str = absl::StrCat(
"string_value: \"",
UpbStringToAbsl(google_protobuf_Value_string_value(value)), "\"");
} else if (google_protobuf_Value_has_null_value(value)) {
value_str = "null_value: NULL_VALUE";
} else if (google_protobuf_Value_has_number_value(value)) {
value_str = absl::StrCat("double_value: ",
google_protobuf_Value_number_value(value));
} else if (google_protobuf_Value_has_bool_value(value)) {
value_str = absl::StrCat("bool_value: ",
google_protobuf_Value_bool_value(value));
} else if (google_protobuf_Value_has_struct_value(value)) {
value_str = "struct_value: <not printed>";
} else if (google_protobuf_Value_has_list_value(value)) {
value_str = "list_value: <not printed>";
} else {
value_str = "<unknown>";
}
fields->emplace_back(absl::StrCat(" value { ", value_str, " }"));
}
fields->emplace_back(" }");
}
fields->emplace_back(" }");
}
// locality
const envoy_config_core_v3_Locality* locality =
envoy_config_core_v3_Node_locality(node);
if (locality != nullptr) {
fields->emplace_back(" locality {");
AddLocalityField(2, locality, fields);
fields->emplace_back(" }");
}
// build_version (doesn't exist in v3 proto; this is a horrible hack)
if (!build_version.empty()) {
fields->emplace_back(
absl::StrCat(" build_version: \"", build_version, "\""));
}
// user_agent_name
AddStringField(" user_agent_name",
envoy_config_core_v3_Node_user_agent_name(node), fields);
// user_agent_version
AddStringField(" user_agent_version",
envoy_config_core_v3_Node_user_agent_version(node), fields);
// client_features
size_t num_client_features;
const upb_strview* client_features =
envoy_config_core_v3_Node_client_features(node, &num_client_features);
for (size_t i = 0; i < num_client_features; ++i) {
AddStringField(" client_features", client_features[i], fields);
}
fields->emplace_back("}");
}
void MaybeLogDiscoveryRequest(
XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
const envoy_service_discovery_v3_DiscoveryRequest* request) {

Loading…
Cancel
Save