-
Notifications
You must be signed in to change notification settings - Fork 3
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
Remove default port from grpc ChannelOptions #81
Conversation
Draft because this is based on #79 |
0ffbe17
to
8f652a9
Compare
8f652a9
to
fffb5f8
Compare
URIs should always specify a port. If they don't, a `ValueError` will be raised. Signed-off-by: Sahas Subramanian <[email protected]>
Signed-off-by: Sahas Subramanian <[email protected]>
fffb5f8
to
43f9a81
Compare
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.
Mmm, I'm not convinced about completely removing the possibility to set a default port. I agree that for the base client it doesn't make sense, as we don ´t know anything about the API. But for subclasses, where we will probably have well defined service locations, it might make sense to have a default port and only leave a floating address (I can see the case for that if you want to change between staging and production for example).
At least I think @Marenz made a point about this.
I don ´t know, for now I would make the port int | None = None
and only raise if the default_port is None
.
People can type the ports themselves. We are only introducing opportunities to fail, by providing defaults.
This example sounds particularly dangerous to me, relying on defaults for switching between staging and production is a definite way to mess things up. Saving a few keystrokes to type the ports is not worth the risks/complications having a default would introduce. |
It's not about saving keystrokes, it's about making the usage easier. For staging, of course a different domain would be better |
Yeah, I'm even thinking about what if we want to have different versions of an API running in different ports. A service (client) could known which port uses each version, and try to find first the latest version and only connect to older versions if unavailable. I can really see use cases for letting the client chose the port (i.e. using a default). I agree is not about saving keystrokes, is about abstraction. |
How is it dangerous? Is not relying on defaults, is using different host names, user-provided host names, is using the DNS to look for a particular instance. |
There is a reason why port numbers are standarized, the whole IANA thing. Ports do have meaning, even if you could use a non-standard one. https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml |
Fine, let me get out of the way then. |
I still see value in part of the PR, I don't think the base client should set a default port, it should just allow clients to set one. If some concrete client think it is best not to provide a default port, they can do so, and that will actually be the default. I don't know why the door slam 😟 |
This is what I mean: |
To me it is always better to be explicit, users are going to copy-paste the urls anyway, I don't see how this is useful, and but I think it could mess things up if multiple services are running on the same domain name, like for different users, etc., which we already have examples for. But just opinions, and not really strong ones.
No, of course not, more like a door opening. It looks like the majority thinks it is nice to have, so I won't block you, but I'd rather not do it myself. |
I agree with all of this, but still in general URLs allow omitting the port, and this is still a general purpose library (even when it might be a bit specific to our use case). With the PR I'm proposing, the default is still to require an explicit port, but if some client thinks a default port makes sense, they can do so. So unless some downstream project explicitly defines a default port, it will be required. If a downstream project goes to the trouble of setting a default, I would trust they know what they are doing. For sure it exist cases for using default ports, they are used everywhere (most services we use on a daily basis have a default port) and they are not required by the URL/URI standard. So I think it makes sense to leave the door open in this library, but go with a safe default.
👍 |
URIs should always specify a port. If they don't, a
ValueError
will be raised.Closes #80