mirror of
https://github.com/sogou/workflow.git
synced 2026-02-08 01:33:17 +08:00
ConsistentHashPolicy: change std_hash to rand.
This commit is contained in:
@@ -56,9 +56,8 @@ UPSAddrParams::UPSAddrParams(const struct AddressParams *params,
|
||||
const std::string& address) :
|
||||
PolicyAddrParams(params)
|
||||
{
|
||||
static std::hash<std::string> std_hash;
|
||||
for (int i = 0; i < VIRTUAL_GROUP_SIZE; i++)
|
||||
this->consistent_hash[i] = std_hash(address + "|v" + std::to_string(i));
|
||||
this->consistent_hash[i] = rand();
|
||||
|
||||
this->weight = params->weight;
|
||||
this->server_type = params->server_type;
|
||||
|
||||
@@ -61,7 +61,7 @@ void register_upstream_hosts()
|
||||
UpstreamManager::upstream_create_consistent_hash(
|
||||
"hash",
|
||||
[](const char *path, const char *query, const char *fragment) -> unsigned int {
|
||||
return 1;
|
||||
return 1315634022;
|
||||
});
|
||||
UpstreamManager::upstream_add_server("hash", "127.0.0.1:8001");
|
||||
UpstreamManager::upstream_add_server("hash", "127.0.0.1:8002");
|
||||
|
||||
Reference in New Issue
Block a user