Skip to content

Extract load balancing logic in a separate class #265

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

Merged
merged 3 commits into from
Jul 11, 2017

Conversation

lutovich
Copy link
Contributor

@lutovich lutovich commented Jul 8, 2017

Previously load balancing logic for read and write servers was coupled with storage of server addresses in RoundRobinArray class. Such approach was problematic because it made hard to use different load balancing strategy.

This PR pulls load balancing in a separate class and removes RoundRobinArray. Instead addresses are stored in simple arrays and load balancing logic is applied to those arrays. Such approach makes it easy to plug a different load balancing strategy.

lutovich added 2 commits July 10, 2017 18:55
Previously load balancing logic for read and write servers was coupled
with storage of server addresses in `RoundRobinArray` class. Such
approach was problematic because it made hard to use different load
balancing strategy.

This commit pulls load balancing in a separate class and removes
`RoundRobinArray`. Instead addresses are stored in simple arrays
and load balancing logic is applied to those arrays. Such approach
makes it easy to plug a different load balancing strategy.
Previously `RoundRobinArray`s in a routing table were recreated on
every rediscovery. This caused round robin index to be reset to zero.
It is no longer true because `RoundRobinLoadBalancingStrategy` does
not reset indexes.
}
}

export class RoundRobinLoadBalancingStrategy extends LoadBalancingStrategy {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we maybe extract this to a file of it's own. It has it's own purpose and it makes sense in imports to import it as
import {RoundRobinLoadBalancingStrategy} from './round-robin-load-balancing-strategy';

@lutovich lutovich merged commit 963aeae into neo4j:1.5 Jul 11, 2017
@lutovich lutovich deleted the 1.5-lb-infra branch July 11, 2017 16:11
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