| 63 | } |
| 64 | |
| 65 | void addInterfacesFromKVs(RangeResult& kvs, |
| 66 | std::map<Key, std::pair<Value, ClientLeaderRegInterface>>* address_interface) { |
| 67 | for (const auto& kv : kvs) { |
| 68 | ClientWorkerInterface workerInterf; |
| 69 | try { |
| 70 | // the interface is back-ward compatible, thus if parsing failed, it needs to upgrade cli version |
| 71 | workerInterf = BinaryReader::fromStringRef<ClientWorkerInterface>(kv.value, IncludeVersion()); |
| 72 | } catch (Error& e) { |
| 73 | fprintf(stderr, "Error: %s; CLI version is too old, please update to use a newer version\n", e.what()); |
| 74 | return; |
| 75 | } |
| 76 | ClientLeaderRegInterface leaderInterf(workerInterf.address()); |
| 77 | StringRef ip_port = |
| 78 | (kv.key.endsWith(LiteralStringRef(":tls")) ? kv.key.removeSuffix(LiteralStringRef(":tls")) : kv.key) |
| 79 | .removePrefix(LiteralStringRef("\xff\xff/worker_interfaces/")); |
| 80 | (*address_interface)[ip_port] = std::make_pair(kv.value, leaderInterf); |
| 81 | |
| 82 | if (workerInterf.reboot.getEndpoint().addresses.secondaryAddress.present()) { |
| 83 | Key full_ip_port2 = |
| 84 | StringRef(workerInterf.reboot.getEndpoint().addresses.secondaryAddress.get().toString()); |
| 85 | StringRef ip_port2 = full_ip_port2.endsWith(LiteralStringRef(":tls")) |
| 86 | ? full_ip_port2.removeSuffix(LiteralStringRef(":tls")) |
| 87 | : full_ip_port2; |
| 88 | (*address_interface)[ip_port2] = std::make_pair(kv.value, leaderInterf); |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | ACTOR Future<Void> getWorkerInterfaces(Reference<ITransaction> tr, |
| 94 | std::map<Key, std::pair<Value, ClientLeaderRegInterface>>* address_interface, |
no test coverage detected