cdjingit commented on a change in pull request #592: lb configurable && consistency hash lb refactor URL: https://github.com/apache/incubator-brpc/pull/592#discussion_r273790313
########## File path: src/brpc/policy/consistent_hashing_load_balancer.h ########## @@ -56,14 +54,28 @@ class ConsistentHashingLoadBalancer : public LoadBalancer { return hash < code; } }; + explicit ConsistentHashingLoadBalancer(ConsistentHashingLoadBalancerType type); + bool AddServer(const ServerId& server); + bool RemoveServer(const ServerId& server); + size_t AddServersInBatch(const std::vector<ServerId> &servers); + size_t RemoveServersInBatch(const std::vector<ServerId> &servers); + LoadBalancer *New(const butil::StringPiece& params) const; + void Destroy(); + int SelectServer(const SelectIn &in, SelectOut *out); + void Describe(std::ostream &os, const DescribeOptions& options); + +private: + bool SetParameters(const butil::StringPiece& params); + void GetLoads(std::map<butil::EndPoint, double> *load_map); static size_t AddBatch(std::vector<Node> &bg, const std::vector<Node> &fg, const std::vector<Node> &servers, bool *executed); static size_t RemoveBatch(std::vector<Node> &bg, const std::vector<Node> &fg, const std::vector<ServerId> &servers, bool *executed); static size_t Remove(std::vector<Node> &bg, const std::vector<Node> &fg, const ServerId& server, bool *executed); - HashFunc _hash; + const ReplicaPolicy* _replicas_policy; size_t _num_replicas; + ConsistentHashingLoadBalancerType _type; Review comment: 放到GetReplicaPolicy()中 作为局部static ---------------------------------------------------------------- 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