-
Notifications
You must be signed in to change notification settings - Fork 532
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
Implements BalancedPool #1064
Implements BalancedPool #1064
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1064 +/- ##
=======================================
Coverage 94.92% 94.93%
=======================================
Files 37 38 +1
Lines 3647 3709 +62
=======================================
+ Hits 3462 3521 +59
- Misses 185 188 +3
Continue to review full report at Codecov.
|
lib/balanced_pool.js
Outdated
| const pool = this[kPools].find((pool) => pool.upstream === upstream) | ||
| const idx = this[kPools].indexOf(pool) | ||
| this[kPools].splice(idx, 1) | ||
| pool.close() |
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.
there is a race here I believe. If you remove upstream the event handlers are still there and the pool is still closing. What if upstream is re-added added before finishing closing? Can be a little confusing behavior.
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.
I think destroy and close need to return promsie if not passed callback.
They already do. What's missing specifically? |
You don’t return anything? |
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.
LGTM.
I still think there is a race here with removing/adding upstreams but it's kind of an unlikely edge case.
There is room for improvement in regards to the algorithm but this should be good enough to be useful.
I'll open an issue afterwards, the selection algorithm can be improved significantly and it will be a good contribution! |
Co-authored-by: Robert Nagy <ronagy@icloud.com>
|
Updated things a bit, tests are passing |
Co-authored-by: Robert Nagy <ronagy@icloud.com>
* Implements BalancedPool * added new doc page to sidebar * Review comments * removed todos * Update lib/balanced_pool.js Co-authored-by: Robert Nagy <ronagy@icloud.com> * Apply suggestions from code review Co-authored-by: Robert Nagy <ronagy@icloud.com> * fixup * fixup * fixup * Fixed load balancing * Update lib/balanced-pool.js Co-authored-by: Robert Nagy <ronagy@icloud.com> Co-authored-by: Robert Nagy <ronagy@icloud.com>
* Implements BalancedPool * added new doc page to sidebar * Review comments * removed todos * Update lib/balanced_pool.js Co-authored-by: Robert Nagy <ronagy@icloud.com> * Apply suggestions from code review Co-authored-by: Robert Nagy <ronagy@icloud.com> * fixup * fixup * fixup * Fixed load balancing * Update lib/balanced-pool.js Co-authored-by: Robert Nagy <ronagy@icloud.com> Co-authored-by: Robert Nagy <ronagy@icloud.com>
No description provided.