feat(NODE-3467): implement srvMaxHosts, srvServiceName options#3031
feat(NODE-3467): implement srvMaxHosts, srvServiceName options#3031
Conversation
dariakp
left a comment
There was a problem hiding this comment.
Some feedback just on the helpers
dariakp
left a comment
There was a problem hiding this comment.
More feedback on just the shuffle portion
b74b277 to
1d09e18
Compare
dariakp
left a comment
There was a problem hiding this comment.
just some wording clean up on the shuffle
Co-authored-by: Daria Pardue <daria.pardue@mongodb.com>
make use of timers and await IO
dariakp
left a comment
There was a problem hiding this comment.
Just capturing some thoughts before I move on to looking at more of this
dariakp
left a comment
There was a problem hiding this comment.
Thoughts on srvMaxHosts specifically
dariakp
left a comment
There was a problem hiding this comment.
Still have tests to review, but here's more feedback
dariakp
left a comment
There was a problem hiding this comment.
Some feedback on just the code, maybe hopefully the last round, still need to look at the tests
dariakp
left a comment
There was a problem hiding this comment.
URI spec test portion comments
test/unit/connection_string.test.js
Outdated
| // TODO(): srvMaxHost limiting happens in the callback given to resolveSRVRecord inside the driver | ||
| // How can we test this in unit test? | ||
|
|
||
| // if (options.srvHost && comment.includes('srvMaxHosts')) { |
There was a problem hiding this comment.
Just a note but it's potentially one way to add a check... Could be that we test that the list of hosts after the randomisation is equal to the list of server description host names in the created topology? Just thinking aloud.
There was a problem hiding this comment.
Moved these tests to initial_dns_seedlist_discovery.spec.test.ts to go along with our nice naming convention but also skipped them due to needing more concrete assertions around the error cases. And it is tracked here: NODE-3757
|
@dariakp I went through and made sure I addresses all your current comments. |
| const selectedHosts = | ||
| options.srvMaxHosts === 0 || options.srvMaxHosts >= seedlist.length | ||
| ? seedlist | ||
| : shuffle(seedlist, options.srvMaxHosts); |
There was a problem hiding this comment.
I moved the initial shuffling to here, in order to unit test since the callback to resolveSRVRecord is inaccessible to the tests.
dariakp
left a comment
There was a problem hiding this comment.
Some comments while I look at the tests
Co-authored-by: Daria Pardue <daria.pardue@mongodb.com>
dariakp
left a comment
There was a problem hiding this comment.
Just to summarize what we discussed - we want to pull in the spec changes associated with test 13, which involve NODE-3450 along with the changes that would have been done in NODE-3680; we also want to make the mock tests more closely resemble the prose tests as written, and we want to break out the seed discovery tests into their own file and see if they can run as integration tests.
Description
What is changing?
A new option
srvMaxHostsis now implemented that enables a user to limit the number of mongoses the driver will connect to. The driver will select from the list of hosts returned by a DNS lookup at random using the Fisher-Yates algorithm.The
srvServiceNameallows the srv address prefix to be changed from the default ofmongodbIs there new documentation needed for these changes?
There is new TSDoc, I don't think further documentation will be needed.
What is the motivation for this change?
The number of mongos hosts can be large and each gets its own connection pool, it allows for tuning of how many query routers a driver connects to, primarily in order to manage networking resources.
Double check the following
npm run check:lintscript<type>(NODE-xxxx)<!>: <description>