MCPcopy Create free account
hub / github.com/SNAS/openbmp / parseTopics

Method parseTopics

Server/src/Config.cpp:588–646  ·  view source on GitHub ↗

* Parse the kafka topics configuration * * \param [in] node Reference to the yaml NODE */

Source from the content-addressed store, hash-verified

586 * \param [in] node Reference to the yaml NODE
587 */
588void Config::parseTopics(const YAML::Node &node) {
589
590 if (node["variables"] and node["variables"].Type() == YAML::NodeType::Map) {
591 for (YAML::const_iterator it = node["variables"].begin(); it != node["variables"].end(); ++it) {
592 try {
593 const std::string &var = it->first.as<std::string>();
594
595 // make sure user-defined variable doesn't override app specific ones
596 if (var.compare("router_group") and var.compare("peer_group"))
597 topic_vars_map[var] = it->second.as<std::string>();
598
599 } catch (YAML::TypedBadConversion<std::string> err) {
600 printWarning("kafka.topics.variables error in map. Make sure to define var: <string value>", it->second);
601 }
602 }
603
604 if (debug_general) {
605 for (topic_vars_map_iter it = topic_vars_map.begin(); it != topic_vars_map.end(); ++it) {
606 std::cout << " Config: kafka.topics.variables: " << it->first << " = " << it->second << std::endl;
607 }
608 }
609 }
610
611 if (node["names"] and node["names"].Type() == YAML::NodeType::Map) {
612 for (YAML::const_iterator it = node["names"].begin(); it != node["names"].end(); ++it) {
613 try {
614 // Only add topic names that are initialized, otherwise ignore them
615 if (topic_names_map.find(it->first.as<std::string>()) != topic_names_map.end()) {
616 if (it->second.Type() == YAML::NodeType::Null) {
617 topic_names_map[it->first.as<std::string>()] = "";
618 } else {
619 topic_names_map[it->first.as<std::string>()] = it->second.as<std::string>();
620 }
621 } else if (debug_general)
622 std::cout << " Ignore: '" << it->first.as<std::string>()
623 << "' is not a valid topic name entry" << std::endl;
624
625
626 } catch (YAML::TypedBadConversion<std::string> err) {
627 printWarning("kafka.topics.names error in map. Make sure to define var: <string value>", it->second);
628 }
629 }
630
631 if (debug_general) {
632 for (topic_names_map_iter it = topic_names_map.begin(); it != topic_names_map.end(); ++it) {
633 std::cout << " Config: kafka.topics.names: " << it->first << " = " << it->second << std::endl;
634 }
635 }
636 }
637
638 // Update the topics based on user-defined variables
639 topicSubstitutions();
640
641 if (debug_general) {
642 for (topic_names_map_iter it = topic_names_map.begin(); it != topic_names_map.end(); ++it) {
643 std::cout << " Config: postsub: kafka.topics.names: " << it->first << " = " << it->second << std::endl;
644 }
645 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected