void read_service_ids_from_config_files()

in src/config/ConfigFile.cpp [111:148]


    void read_service_ids_from_config_files(std::vector<std::string> const & file_paths, unordered_set<string> const & service_ids, unordered_map<string, string> & serviceId_to_endpoint_mapping)
    {
        for (auto file_path: file_paths)
        {
            boost::property_tree::ptree pt;
            // If find all the service ids, stop searching
            if (serviceId_to_endpoint_mapping.size() == service_ids.size())
            {
                break;
            }
            // Parse file in .ini format, if having issues, skip this file and read the next file in the folder.
            try {
                boost::property_tree::ini_parser::read_ini(file_path, pt);
            }
            catch (const std::exception & e) {
                BOOST_LOG_SEV(log, warning) << "Fail to parse " << file_path << " .Please make sure your file is in .ini format.";
                BOOST_LOG_SEV(log, warning) <<  "Error message from parsing: " << e.what() << " .Continue to the next file.";
                continue;
            }
            for (auto service_id: service_ids) {
                 /**
                  * Search for service ids that does not have a port mapping detected.
                  * If more than one service id mappings found in the configuration files, use the first one found.
                  */
                if (serviceId_to_endpoint_mapping.find(service_id) != serviceId_to_endpoint_mapping.end())
                {
                    continue;
                }
                try {
                    string endpoint = pt.get<std::string>(service_id);
                    serviceId_to_endpoint_mapping.insert({service_id, endpoint});
                }
                catch (boost::property_tree::ptree_bad_path &e) {
                    BOOST_LOG_SEV(log, warning) << "Fail to read file: " << file_path << ". Error message: " << e.what() << ". Ignore this file.";
                }
            }
        }
    }