jamesge commented on a change in pull request #592: lb configurable && 
consistency hash lb refactor
URL: https://github.com/apache/incubator-brpc/pull/592#discussion_r272216066
 
 

 ##########
 File path: src/brpc/policy/consistent_hashing_load_balancer.cpp
 ##########
 @@ -29,16 +31,111 @@ namespace policy {
 DEFINE_int32(chash_num_replicas, 100, 
              "default number of replicas per server in chash");
 
-ConsistentHashingLoadBalancer::ConsistentHashingLoadBalancer(HashFunc hash) 
-    : _hash(hash)
-    , _num_replicas(FLAGS_chash_num_replicas) {
+class ReplicaPolicy {
+public:
+    ReplicaPolicy() : _hash_func(nullptr) {}
+    ReplicaPolicy(HashFunc hash) : _hash_func(hash) {}
+    virtual ~ReplicaPolicy() = default;
+
+    virtual bool Build(ServerId server, 
+                       size_t num_replicas,
+                       std::vector<ConsistentHashingLoadBalancer::Node>* 
replicas) const = 0;
+
+protected:
+    HashFunc _hash_func;
 
 Review comment:
   这东西和基类有关系么?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org

Reply via email to