feat: add random shuffle for name server addresses
diff --git a/src/transport/TcpRemotingClient.cpp b/src/transport/TcpRemotingClient.cpp
index a077406..fa60e3c 100644
--- a/src/transport/TcpRemotingClient.cpp
+++ b/src/transport/TcpRemotingClient.cpp
@@ -24,6 +24,8 @@
#include "MemoryOutputStream.h"
#include "TopAddressing.h"
#include "UtilAll.h"
+#include <algorithm>
+#include <random>
namespace rocketmq {
@@ -150,6 +152,11 @@
vector<string> out;
UtilAll::Split(out, addrs, ";");
+
+ std::random_device rd;
+ std::mt19937 g(rd());
+ std::shuffle(out.begin(), out.end(), g);
+
for (auto addr : out) {
UtilAll::Trim(addr);