Decodes the locality string to a pair of locality prefix and its value. The prefix could be dcid, processid, machineid, processid.
| 1736 | // Decodes the locality string to a pair of locality prefix and its value. |
| 1737 | // The prefix could be dcid, processid, machineid, processid. |
| 1738 | std::pair<std::string, std::string> decodeLocality(const std::string& locality) { |
| 1739 | StringRef localityRef((const uint8_t*)(locality.c_str()), locality.size()); |
| 1740 | |
| 1741 | std::string localityKeyValue = localityRef.removePrefix(LocalityData::ExcludeLocalityPrefix).toString(); |
| 1742 | int split = localityKeyValue.find(':'); |
| 1743 | if (split != std::string::npos) { |
| 1744 | return std::make_pair(localityKeyValue.substr(0, split), localityKeyValue.substr(split + 1)); |
| 1745 | } |
| 1746 | |
| 1747 | return std::make_pair("", ""); |
| 1748 | } |
| 1749 | |
| 1750 | // Returns the list of IPAddresses of the workers that match the given locality. |
| 1751 | // Example: locality="dcid:primary" returns all the ip addresses of the workers in the primary dc. |
no test coverage detected