You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by se...@apache.org on 2023/07/06 02:11:59 UTC

[brpc] branch master updated: Fix typo of WeightedRoundRobinLoadBalancer (#2299)

This is an automated email from the ASF dual-hosted git repository.

serverglen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git


The following commit(s) were added to refs/heads/master by this push:
     new e4abb3fa Fix typo of WeightedRoundRobinLoadBalancer (#2299)
e4abb3fa is described below

commit e4abb3fab3bacbbf127dcda553ddc6b67a2a0888
Author: Bright Chen <ch...@foxmail.com>
AuthorDate: Thu Jul 6 10:11:53 2023 +0800

    Fix typo of WeightedRoundRobinLoadBalancer (#2299)
---
 src/brpc/policy/weighted_round_robin_load_balancer.cpp | 4 ++--
 src/brpc/policy/weighted_round_robin_load_balancer.h   | 6 +++---
 test/brpc_load_balancer_unittest.cpp                   | 6 +++---
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/brpc/policy/weighted_round_robin_load_balancer.cpp b/src/brpc/policy/weighted_round_robin_load_balancer.cpp
index 82c20085..eefc11d4 100644
--- a/src/brpc/policy/weighted_round_robin_load_balancer.cpp
+++ b/src/brpc/policy/weighted_round_robin_load_balancer.cpp
@@ -165,7 +165,7 @@ int WeightedRoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut*
         return ENODATA;
     }
     TLS& tls = s.tls();
-    if (tls.IsNeededCaculateNewStride(s->weight_sum, s->server_list.size())) {
+    if (tls.IsNeededCalculateNewStride(s->weight_sum, s->server_list.size())) {
       if (tls.stride == 0) {
           tls.position = butil::fast_rand_less_than(s->server_list.size());
       }
@@ -178,7 +178,7 @@ int WeightedRoundRobinLoadBalancer::SelectServer(const SelectIn& in, SelectOut*
         tls.remain_server.id != s->server_list[tls.position].id) {
         tls.remain_server.weight = 0;
     }
-    // The servers that can not be choosed.
+    // The servers that can not be chosen.
     std::unordered_set<SocketId> filter;
     TLS tls_temp = tls;
     uint64_t remain_weight = s->weight_sum;
diff --git a/src/brpc/policy/weighted_round_robin_load_balancer.h b/src/brpc/policy/weighted_round_robin_load_balancer.h
index 0e923885..fc3df2da 100644
--- a/src/brpc/policy/weighted_round_robin_load_balancer.h
+++ b/src/brpc/policy/weighted_round_robin_load_balancer.h
@@ -58,9 +58,9 @@ private:
         size_t position = 0;
         uint64_t stride = 0;
         Server remain_server;
-        // If server list changed, we need caculate a new stride.
-        bool IsNeededCaculateNewStride(const uint64_t curr_weight_sum, 
-                                       const size_t curr_servers_num) {
+        // If server list changed, we need calculate a new stride.
+        bool IsNeededCalculateNewStride(const uint64_t curr_weight_sum,
+                                        const size_t curr_servers_num) {
             if (curr_weight_sum != weight_sum 
                 || curr_servers_num != servers_num) {
                 weight_sum = curr_weight_sum;
diff --git a/test/brpc_load_balancer_unittest.cpp b/test/brpc_load_balancer_unittest.cpp
index 019f40dd..d98c11b5 100644
--- a/test/brpc_load_balancer_unittest.cpp
+++ b/test/brpc_load_balancer_unittest.cpp
@@ -843,7 +843,7 @@ TEST_F(LoadBalancerTest, weighted_round_robin) {
 
     // Select the best server according to weight configured.
     // There are 3 valid servers with weight 3, 2 and 7 respectively.
-    // We run SelectServer for 12 times. The result number of each server seleted should be 
+    // We run SelectServer for 12 times. The result number of each server selected should be
     // consistent with weight configured.
     std::map<butil::EndPoint, size_t> select_result;
     brpc::SocketUniquePtr ptr;
@@ -861,7 +861,7 @@ TEST_F(LoadBalancerTest, weighted_round_robin) {
         std::cout << "1=" << s << ", ";
     } 
     std::cout << std::endl;   
-    // Check whether slected result is consistent with expected.
+    // Check whether selected result is consistent with expected.
     EXPECT_EQ((size_t)3, select_result.size());
     for (const auto& result : select_result) {
         std::cout << result.first << " result=" << result.second 
@@ -951,7 +951,7 @@ TEST_F(LoadBalancerTest, weighted_randomized) {
 
     // Select the best server according to weight configured.
     // There are 4 valid servers with weight 3, 2, 5 and 10 respectively.
-    // We run SelectServer for multiple times. The result number of each server seleted should be
+    // We run SelectServer for multiple times. The result number of each server selected should be
     // weight randomized with weight configured.
     std::map<butil::EndPoint, size_t> select_result;
     brpc::SocketUniquePtr ptr;


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