diff --git a/include/ylt/coro_io/load_blancer.hpp b/include/ylt/coro_io/load_blancer.hpp index 33ba699cb..15e7fa13f 100644 --- a/include/ylt/coro_io/load_blancer.hpp +++ b/include/ylt/coro_io/load_blancer.hpp @@ -25,7 +25,7 @@ #include "io_context_pool.hpp" namespace coro_io { -enum class load_blancer_algorithm { +enum class load_blance_algorithm { RR = 0, // round-robin WRR, // weight round-robin random, @@ -39,7 +39,7 @@ class load_blancer { public: struct load_blancer_config { typename client_pool_t::pool_config pool_config; - load_blancer_algorithm lba = load_blancer_algorithm::RR; + load_blance_algorithm lba = load_blance_algorithm::RR; ~load_blancer_config(){}; }; @@ -215,10 +215,10 @@ class load_blancer { client_pools_.emplace_back(client_pools.at(host, config.pool_config)); } switch (config_.lba) { - case load_blancer_algorithm::RR: + case load_blance_algorithm::RR: lb_worker = RRLoadBlancer{}; break; - case load_blancer_algorithm::WRR: { + case load_blance_algorithm::WRR: { if (hosts.empty() || weights.empty()) { throw std::invalid_argument("host/weight list is empty!"); } @@ -227,7 +227,7 @@ class load_blancer { } lb_worker = WRRLoadBlancer(weights); } break; - case load_blancer_algorithm::random: + case load_blance_algorithm::random: default: lb_worker = RandomLoadBlancer{}; } diff --git a/include/ylt/standalone/cinatra/coro_http_server.hpp b/include/ylt/standalone/cinatra/coro_http_server.hpp index 90294029f..803a62176 100644 --- a/include/ylt/standalone/cinatra/coro_http_server.hpp +++ b/include/ylt/standalone/cinatra/coro_http_server.hpp @@ -208,8 +208,8 @@ class coro_http_server { template void set_http_proxy_handler(std::string url_path, std::vector hosts, - coro_io::load_blancer_algorithm type = - coro_io::load_blancer_algorithm::random, + coro_io::load_blance_algorithm type = + coro_io::load_blance_algorithm::random, std::vector weights = {}, Aspects &&...aspects) { if (hosts.empty()) { @@ -248,8 +248,8 @@ class coro_http_server { template void set_websocket_proxy_handler(std::string url_path, std::vector hosts, - coro_io::load_blancer_algorithm type = - coro_io::load_blancer_algorithm::random, + coro_io::load_blance_algorithm type = + coro_io::load_blance_algorithm::random, std::vector weights = {}, Aspects &&...aspects) { if (hosts.empty()) { diff --git a/src/coro_http/examples/example.cpp b/src/coro_http/examples/example.cpp index 1888c7701..1256feed7 100644 --- a/src/coro_http/examples/example.cpp +++ b/src/coro_http/examples/example.cpp @@ -570,12 +570,12 @@ void http_proxy() { coro_http_server proxy_wrr(2, 8090); proxy_wrr.set_http_proxy_handler( "/", {"127.0.0.1:9001", "127.0.0.1:9002", "127.0.0.1:9003"}, - coro_io::load_blancer_algorithm::WRR, {10, 5, 5}); + coro_io::load_blance_algorithm::WRR, {10, 5, 5}); coro_http_server proxy_rr(2, 8091); proxy_rr.set_http_proxy_handler( "/", {"127.0.0.1:9001", "127.0.0.1:9002", "127.0.0.1:9003"}, - coro_io::load_blancer_algorithm::RR); + coro_io::load_blance_algorithm::RR); coro_http_server proxy_random(2, 8092); proxy_random.set_http_proxy_handler( diff --git a/src/coro_io/tests/test_channel.cpp b/src/coro_io/tests/test_channel.cpp index 8f04eb59b..8c737d9cb 100644 --- a/src/coro_io/tests/test_channel.cpp +++ b/src/coro_io/tests/test_channel.cpp @@ -49,17 +49,17 @@ TEST_CASE("test WRR") { "exception tests: empty hosts, empty weights test or count not equal") { CHECK_THROWS_AS( coro_io::load_blancer::create( - {}, {.lba = coro_io::load_blancer_algorithm::WRR}, {2, 1}), + {}, {.lba = coro_io::load_blance_algorithm::WRR}, {2, 1}), std::invalid_argument); CHECK_THROWS_AS(coro_io::load_blancer::create( {"127.0.0.1:8801", "127.0.0.1:8802"}, - {.lba = coro_io::load_blancer_algorithm::WRR}), + {.lba = coro_io::load_blance_algorithm::WRR}), std::invalid_argument); CHECK_THROWS_AS(coro_io::load_blancer::create( {"127.0.0.1:8801", "127.0.0.1:8802"}, - {.lba = coro_io::load_blancer_algorithm::WRR}, {1}), + {.lba = coro_io::load_blance_algorithm::WRR}, {1}), std::invalid_argument); } @@ -75,7 +75,7 @@ TEST_CASE("test WRR") { std::vector{"127.0.0.1:8801", "127.0.0.1:8802"}; auto load_blancer = coro_io::load_blancer::create( - hosts, {.lba = coro_io::load_blancer_algorithm::WRR}, {2, 1}); + hosts, {.lba = coro_io::load_blance_algorithm::WRR}, {2, 1}); for (int i = 0; i < 6; ++i) { auto res = co_await load_blancer.send_request( [&i, &hosts]( @@ -101,7 +101,7 @@ TEST_CASE("test WRR") { std::vector{"127.0.0.1:8801", "127.0.0.1:8802"}; auto load_blancer = coro_io::load_blancer::create( - hosts, {.lba = coro_io::load_blancer_algorithm::WRR}, {0, 0}); + hosts, {.lba = coro_io::load_blance_algorithm::WRR}, {0, 0}); for (int i = 0; i < 6; ++i) { auto res = co_await load_blancer.send_request( [&i, &hosts]( @@ -129,7 +129,7 @@ TEST_CASE("test Random") { std::vector{"127.0.0.1:8801", "localhost:8801"}; auto load_blancer = coro_io::load_blancer::create( - hosts, {.lba = coro_io::load_blancer_algorithm::random}); + hosts, {.lba = coro_io::load_blance_algorithm::random}); int host0_cnt = 0, hostRR_cnt = 0; for (int i = 0; i < 100; ++i) { auto res = co_await load_blancer.send_request(