-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: wlc moved to from dataplane to controlplane #211
base: main
Are you sure you want to change the base?
Conversation
Could you please improve the commit message? Change Also, add a short description explaining why this change is needed, please |
auto reals_wlc = reals_wlc_weight.find(key); | ||
if (reals_wlc != reals_wlc_weight.end() && reals_wlc->second.has_value()) | ||
{ | ||
effective_weight = reals_wlc->second.value(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will have code duplication here with the following lines:
auto it = reals_enabled.find(key);
if (it != reals_enabled.end())
{
if (it->second.has_value())
{
effective_weight = it->second.value();
}
}
I think we can add a private method in balancer_t
like
template <typename Map>
std::optional<typename Map::mapped_type::value_type> get_effective_weight(const Map& map, const balancer::real_key_global_t& key) const {
auto it = map.find(key);
if (it != map.end() && it->second.has_value()) {
return it->second.value();
}
return std::nullopt;
}
And then use it, for example, with compound initialization:
if (auto found_weight = get_effective_weight(reals_wlc_weight, key); found_weight) {
effective_weight = *found_weight;
}
uint32_t effective_weight = weight; | ||
{ | ||
auto it = reals_enabled.find(key); | ||
if (it != reals_enabled.end()) | ||
{ | ||
if (it->second.has_value()) | ||
{ | ||
effective_weight = it->second.value(); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto found_weight = get_effective_weight(reals_enabled, key);
uint32_t effective_weight = found_weight ? *found_weight : weight;
if (it == real_connections.end()) | ||
{ | ||
continue; | ||
} | ||
connections += it->second; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO
if (it != real_connections.end())
{
connections += it->second;
}
is cleaner, but feel free no ignore
No description provided.