Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

levon-a-akopian
Copy link
Contributor

No description provided.

@ol-imorozko
Copy link
Collaborator

Could you please improve the commit message?

Change wlc moved to from dataplane to controlplane to Move wlc from dataplane to controlplane

Also, add a short description explaining why this change is needed, please

Comment on lines +889 to +893
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();
}
Copy link
Collaborator

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;
}

Comment on lines +995 to +1005
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();
}
}
}
Copy link
Collaborator

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;

Comment on lines +1027 to +1031
if (it == real_connections.end())
{
continue;
}
connections += it->second;
Copy link
Collaborator

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

@GeorgyKirichenko GeorgyKirichenko changed the title wlc mowed to from dataplane to controlplane WIP: wlc moved to from dataplane to controlplane Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants