Skip to content

Commit

Permalink
Merge pull request #5 from polarismesh/hotfix/fix_lb_mode
Browse files Browse the repository at this point in the history
fix lb_mode enum bug.
  • Loading branch information
wssgyyg authored Jan 12, 2022
2 parents b3470c5 + bf0d4b2 commit 758d7d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion nginx_polaris_module/ngx_http_upstream_polaris_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ typedef struct {
ngx_str_t polaris_service_name;
ngx_int_t polaris_timeout;
ngx_str_t polaris_lb_key;
polaris::LoadBalanceType polaris_lb_mode;
ngx_int_t polaris_lb_mode;

ngx_int_t polaris_dynamic_route_enabled;
ngx_str_t polaris_dynamic_route_metadata_list;
Expand Down
14 changes: 8 additions & 6 deletions nginx_polaris_module/ngx_http_upstream_polaris_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,19 +354,19 @@ void set_polaris_lb_mode(ngx_http_upstream_polaris_srv_conf_t* srv, ngx_http_req
ngx_http_upstream_polaris_ctx_t* ctx) {
switch (srv->polaris_lb_mode) {
case POLARIS_DEFAULT:
ctx->polaris_lb_mode = polaris::kLoadBalanceTypeDefaultConfig;
ctx->polaris_lb_mode = 0;
break;
case POLARIS_WEIGHTED_RANDOM:
ctx->polaris_lb_mode = polaris::kLoadBalanceTypeWeightedRandom;
ctx->polaris_lb_mode = 0;
break;
case POLARIS_RING_HASH:
ctx->polaris_lb_mode = polaris::kLoadBalanceTypeRingHash;
ctx->polaris_lb_mode = 1;
break;
case POLARIS_L5_CST_HASH:
ctx->polaris_lb_mode = polaris::kLoadBalanceTypeL5CstHash;
ctx->polaris_lb_mode = 1;
break;
default:
ctx->polaris_lb_mode = polaris::kLoadBalanceTypeDefaultConfig;
ctx->polaris_lb_mode = 0;
}
}

Expand Down Expand Up @@ -449,7 +449,9 @@ int polaris_get_addr(ngx_http_upstream_polaris_ctx_t* ctx) {
polaris::Instance instance;
polaris::GetOneInstanceRequest request(serviceKey);
request.SetTimeout(ctx->polaris_timeout);
request.SetLoadBalanceType(ctx->polaris_lb_mode);
if (ctx->polaris_lb_mode > 0) {
request.SetLoadBalanceType(polaris::kLoadBalanceTypeRingHash);
}
set_request_hash_str(ctx, request);

if (ctx->polaris_dynamic_route_enabled) {
Expand Down

0 comments on commit 758d7d3

Please sign in to comment.