-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Drivers: expose client port and address #4796
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
Conversation
|
Thanks @marshall007! I think the API looks good. @deontologician and @Tryneus could you review the JS and Python implementations respectively when you have a chance please? One thing we should test is if these methods still work with SSL connections. They wouldn't be very useful at the moment, since whatever acts as an SSL proxy between the clients and the server is going to have a different port for its own outgoing connection to the server (this will change when we integrate SSL directly into the server). However we should make sure that they still return something reasonable and don't throw an error. |
|
JS looks good 👍 |
drivers/python/rethinkdb/net.py
Outdated
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 it would be slightly better to have this be a properly. We can get a read-only property by just putting @Property on the line before the def. client_address should probably get this as well. I am ambivalent about those on SocketWrapper since that is not deliberately exposed.
Additionally I am slightly concerned about what happens if self._instance or self._instance._socket are None when this is called (say when a Connection is closed()).
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 it would be slightly better to have this be a property.
I was thinking this too, actually. @deontologician should we make these read-only properties in the JS driver as well?
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.
Eh... we don't use properties anywhere currently in the js driver, and I don't think this is important enough to warrant it. Generally I think properties are useful if you need to be backwards compatible with something that was previously an attribute. I think it being a function works fine in js. (Incidentally, I think making it a read-only property is overkill in python too, given python's "we're all adults here" ethos)
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.
@larkost latest commit addresses the possible null reference you pointed out. All the tests now ensure that these two methods return None when called on a closed connection.
|
Looks good, although it won't work for the Python async backends (asyncio, Tornado, and Twisted). In the default
Because these behaviors are so different on each @marshall007, I understand if you don't want to spend the resources to implement and test this on the other Python backends, and if you prefer I can open an issue and add the other implementations myself once this PR has been merged. |
|
@Tryneus thanks, that seems pretty straightforward. I'll update this PR to include as much of that as I can and let you know if I don't get around to some of it. Also, can someone point me to the Ruby connection tests if they exist? I don't see any under |
|
There currently isn't a direct Ruby equivalent of the connection tests for the other drivers. There are however a few tests for the EventMachine interface in test/rql_test |
…pes in Python driver
|
@Tryneus wasn't too bad after all. I added support for this to the remaining connection types with tests for each. It's ready for another look whenever you get the chance. |
|
Awesome, looks good, @marshall007! |
|
@danielmewes I added support for the Ruby driver with a test under Aside from setting up explicit tests over SSL connections, I think that wraps it up. |
|
Nice, I'll try to get the SSL testing done today or tomorrow. |
|
@marshall007 the test is about what I had in mind. Your Ruby changes don't seem to be in this PR yet btw. |
|
Oh wait, never mind. They're there. I must have been looking at an old version of the page. |
|
@danielmewes haha, I just saw the same thing and was also confused. |
drivers/ruby/lib/net.rb
Outdated
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.
This returns "AF_INET" or "AF_INET6" for me, not the actual address.
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.
Good catch, I misread the docs. I think it should be @socket.addr[2].
|
Just tested all drivers with an SSL connection, and the |
|
@danielmewes by the way, is it possible that the hostname we get back from all these different socket implementations could differ from the |
|
@marshall007 The server will always show numeric addresses I believe. It looks like the driver implementations (at least JS and Python) do the same, don't they? However any NAT router or other higher-level proxy will of course cause mismatches in those addresses. That's one of the reasons for why an explicit |
|
@danielmewes I think in Node and Ruby we'll always get a numeric address back. The Python docs, however, seem to imply we could get back a hostname or address:
I don't think we need to worry about this right now, do you? You only really need |
|
@marshall007 I agree that we shouldn't worry about it too much, since as you say the In my brief test the Python driver actually did give me a numeric address though. I'm not sure under which circumstances it will report a hostname instead. |
|
@danielmewes oh yea, I wasn't thinking about connecting to remote instances. After looking into it more I think you only get back a hostname in Python if you construct the socket instance with a hostname and DNS resolution fails. If that is indeed true then I think we're fine not doing anything. |
|
Self-assigning for making a final check, so we can merge this on time before 2.3. |
Also a couple of changes to fix tests.
|
Merged |
|
This was before the Java driver, so there should probably be a corresponding change there |
|
@deontologician Good call. Opened #5571 |
Fixes #4620. The original use-case was to filter the
jobstable to only include jobs initiated by the current client (see #544 comment).I will also update the Ruby driver if the API looks ok to everyone.