Skip to content

Conversation

@estolfo
Copy link
Contributor

@estolfo estolfo commented Jun 27, 2017

No description provided.

@estolfo estolfo changed the title RUBY-1222 Use connect_timeout when determining address family [WIP] RUBY-1222 Use connect_timeout when determining address family Jun 27, 2017
@estolfo estolfo force-pushed the RUBY-1222-conn-timeout-2 branch from 4665c0a to 6d9c94c Compare June 27, 2017 10:13
# @since 2.0.0
def timeout
@timeout ||= options[:connect_timeout] || CONNECT_TIMEOUT
@timeout ||= options[:connect_timeout]
Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand well this timeout is still used but not for connexion, does it make sense to keep it connect_timeout then? Especially if there's no default any more, it'll be infinite for most people, and even if they think about setting the socket_timeout to avoid any trouble, there'll still be an infinite timeout in the code, because the default specified in the doc is not applied.

I think this should either be socket_timeout or keep the default, WDYT @estolfo ?

Copy link
Contributor Author

@estolfo estolfo Jun 28, 2017

Choose a reason for hiding this comment

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

Hi @jarthod

See the description here in our Server Discovery and Monitoring specification.

This timeout is applied only to the monitor thread's connection. It will be used both when connecting and for when regularly executing the ismaster command. I've put the default value of CONNECT_TIMEOUT back in, as you're right that if there is no connect_timeout option set, it would be infinite when sending the command on the socket.

The server connection will use the connect_timeout from the options (or the default) when connecting but then the socket_timeout when sending the operation, if one is specified. If one is not specified, it will be infinite.

Does that make sense?
Emily

Copy link
Contributor

Choose a reason for hiding this comment

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

Totally makes sense, then it should have the default value as you did.
Maybe there should be just one constant though? to make sure nobody changes one and not the other?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I agree we should have one constant but I thought it was awkward/bad design for the address to reference the Server::Monitor::Connection's constants or vice-versa. I'll do some more thinking and see if I can do use a connect timeout default constant better.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes indeed, If it's used in multiple places I would probably move it up to the Mongo module or Configuration one, but that's a matter of taste and conventions you can do what you want ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I put the constant in Server so that Address and Server::Monitor::Connection could reference it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good to me ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks so much @jarthod

def timeout
@timeout ||= options[:socket_timeout]
end
alias :socket_timeout :timeout
Copy link
Contributor

Choose a reason for hiding this comment

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

why alias instead of rename the method? is it used somewhere else? or just safety in case someone calls it from outside?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even though this is all private api, in general, I'd rather not remove or rename methods unless I'm planning to do a major release. And in that case, I'd mark it as deprecated leading up to the release.
Ideally, I would just rename it but I need to stick with semantic versioning rules.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah ok, so you'll mark it as deprecated then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've marked timeout as deprecated in Server::Monitor::Connection and Server::Connection to favor the more explicit socket_timeout method name.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perfect

@estolfo estolfo changed the title [WIP] RUBY-1222 Use connect_timeout when determining address family RUBY-1222 Use connect_timeout when determining address family Jun 28, 2017
@estolfo estolfo force-pushed the RUBY-1222-conn-timeout-2 branch from dcc4870 to e0d4e78 Compare July 4, 2017 13:56
@estolfo estolfo merged commit fa24f62 into mongodb:master Jul 5, 2017
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