Skip to content

GODRIVER-2092 Add srvMaxHosts URI option #764

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 10 commits into from
Oct 8, 2021
Merged

GODRIVER-2092 Add srvMaxHosts URI option #764

merged 10 commits into from
Oct 8, 2021

Conversation

benjirewis
Copy link
Contributor

@benjirewis benjirewis commented Oct 5, 2021

GODRIVER-2092

Adds support for a new URI option srvMaxHosts that limits the number of hosts returned in initial DNS seedlist discovery and intermittent SRV polling. Syncs initial-dns-seedlist-discovery spec tests and implements new SRV polling prose tests.

@benjirewis benjirewis requested a review from divjotarora October 5, 2021 19:07
@benjirewis benjirewis marked this pull request as ready for review October 5, 2021 19:08
Copy link
Contributor

@divjotarora divjotarora left a comment

Choose a reason for hiding this comment

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

Something feels off about including this option and SRVServiceName in the ClientOptions struct. Because SRV resolution is done in the ConnString code, a Client constructed with an SRV URI but SRVMaxHosts set in code options rather than the URI would not actually get the max hosts behavior. Thoughts on this?

@@ -121,6 +121,7 @@ type ClientOptions struct {
ServerAPIOptions *ServerAPIOptions
ServerSelectionTimeout *time.Duration
SocketTimeout *time.Duration
SRVMaxHosts *int
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to add code to ClientOptions#ApplyURI for this option?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep! Added.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add a test for this in clientoptions_test.go - we didn't catch this in the SRV polling tests because they construct a Topology directly, which is unfortunate. I'm hoping GODRIVER-1760 will help us clean up these abstractions and catch such issues quicker.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good; done.

Copy link
Contributor Author

@benjirewis benjirewis left a comment

Choose a reason for hiding this comment

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

If a user calls ClientOptions#ApplyURI after calling ClientOptions#SetSRVServiceName or ClientOptions#SetSRVMaxHosts, the SRV lookup for the initial DNS seedlist will take into account those options. I did document that caveat on the setters.

I think we need SRVServiceName and SRVMaxHosts on the ClientOptions struct to be able to pass them down to the Topology for SRV polling in client#configure(). I could remove the setters, but it seems odd to have an option and no setter on ClientOptions.

@@ -121,6 +121,7 @@ type ClientOptions struct {
ServerAPIOptions *ServerAPIOptions
ServerSelectionTimeout *time.Duration
SocketTimeout *time.Duration
SRVMaxHosts *int
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep! Added.

@divjotarora divjotarora self-requested a review October 6, 2021 19:51
Copy link
Contributor

@divjotarora divjotarora left a comment

Choose a reason for hiding this comment

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

The documentation is sufficient for now. I don't love the limitation, but I also suspect that most people will be fine putting this in the URI. Maybe it's worth filing a ticket to move the SRV resolution logic into the Client so it's done after all of the ClientOptions stuff has been configured?

Regardless, LGTM mod the suggestion about adding unit tests for ClientOptions. No need to request another review, though.

@@ -121,6 +121,7 @@ type ClientOptions struct {
ServerAPIOptions *ServerAPIOptions
ServerSelectionTimeout *time.Duration
SocketTimeout *time.Duration
SRVMaxHosts *int
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add a test for this in clientoptions_test.go - we didn't catch this in the SRV polling tests because they construct a Topology directly, which is unfortunate. I'm hoping GODRIVER-1760 will help us clean up these abstractions and catch such issues quicker.

@benjirewis
Copy link
Contributor Author

Filed GODRIVER-2178 to move SRV resolution logic.

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