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

migrates weighted loadbalance strategy to user new RequestInterceptors for Stats tracking #946

Merged
merged 2 commits into from
Oct 22, 2020

Conversation

OlegDokuka
Copy link
Member

This PR refactors current weighted rsocket to another mechanism which makes Stats to be hidden from the outside world and make it accessible only for WeighetedLoadbalanceStrategy.

This PR introduces StatsRequestInterceptor, which is a public class, hence can be used not only for Client-side but as well as for the server one (e.g. broker case).

The WeightedLoadbalanceStrategy, gets a new constructor API which lets one using selected RSocket to extract associated StatsRequestInterceptor and then calculate the weight.

Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
Copy link
Contributor

@rstoyanchev rstoyanchev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great overall.

One consequence is that WeightedLoadBalanceStrategy can no longer be instantiated directly for the purpose of being used with LoadbalanceRSocketClient. I think WeightedLoadbalanceStrategy should be an InitializingLoadbalanceStrategy but the management of that Map as well as the logic to initialize the connector could be in an inner class (rather than a sub-class) which implements Function<RSocket, StatsRequestInterceptor>. So then if WeightedLoadbalanceStrategy is created without an externally provided Function it falls back on an instance of that inner class.

Signed-off-by: Oleh Dokuka <shadowgun@i.ua>
@OlegDokuka OlegDokuka force-pushed the enhancement/loadbalance-improvements branch from bf34b21 to 626a9f5 Compare October 22, 2020 17:12
@OlegDokuka OlegDokuka merged commit 41eec02 into master Oct 22, 2020
@OlegDokuka OlegDokuka deleted the enhancement/loadbalance-improvements branch October 22, 2020 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants