Skip to content

Commit

Permalink
[coro_io] fix rename
Browse files Browse the repository at this point in the history
  • Loading branch information
poor-circle committed Aug 5, 2024
1 parent a0bd54c commit 2086dd4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions include/ylt/coro_io/load_blancer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(){};
};

Expand Down Expand Up @@ -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!");
}
Expand All @@ -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{};
}
Expand Down
8 changes: 4 additions & 4 deletions include/ylt/standalone/cinatra/coro_http_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ class coro_http_server {
template <http_method... method, typename... Aspects>
void set_http_proxy_handler(std::string url_path,
std::vector<std::string_view> 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<int> weights = {},
Aspects &&...aspects) {
if (hosts.empty()) {
Expand Down Expand Up @@ -248,8 +248,8 @@ class coro_http_server {
template <http_method... method, typename... Aspects>
void set_websocket_proxy_handler(std::string url_path,
std::vector<std::string_view> 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<int> weights = {},
Aspects &&...aspects) {
if (hosts.empty()) {
Expand Down
4 changes: 2 additions & 2 deletions src/coro_http/examples/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,12 +570,12 @@ void http_proxy() {
coro_http_server proxy_wrr(2, 8090);
proxy_wrr.set_http_proxy_handler<GET, POST>(
"/", {"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<GET, POST>(
"/", {"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<GET, POST>(
Expand Down
12 changes: 6 additions & 6 deletions src/coro_io/tests/test_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<coro_rpc::coro_rpc_client>::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<coro_rpc::coro_rpc_client>::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<coro_rpc::coro_rpc_client>::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);
}

Expand All @@ -75,7 +75,7 @@ TEST_CASE("test WRR") {
std::vector<std::string_view>{"127.0.0.1:8801", "127.0.0.1:8802"};
auto load_blancer =
coro_io::load_blancer<coro_rpc::coro_rpc_client>::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](
Expand All @@ -101,7 +101,7 @@ TEST_CASE("test WRR") {
std::vector<std::string_view>{"127.0.0.1:8801", "127.0.0.1:8802"};
auto load_blancer =
coro_io::load_blancer<coro_rpc::coro_rpc_client>::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](
Expand Down Expand Up @@ -129,7 +129,7 @@ TEST_CASE("test Random") {
std::vector<std::string_view>{"127.0.0.1:8801", "localhost:8801"};
auto load_blancer =
coro_io::load_blancer<coro_rpc::coro_rpc_client>::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(
Expand Down

0 comments on commit 2086dd4

Please sign in to comment.