Add property & setter: Client.create_socket - #945
JamesParrott wants to merge 1 commit into
Conversation
Add property & setter: Client.create_socket Update client.py Update client.py
|
The issue I see with adding API to simply replacing
So we need to carefully pick the API we use. I believe we shouldn't replace the full
But maybe the right level would be to be a "proxy" level:
This way most feature of I think think to a Does this sound good to you ? |
|
Thanks for your thoughts, Pierre. I fully understand where you're coming from - _create_socket can call to three sub methods (and _WebsocketWrapper), giving 6 possible combinations (unix, tcp & websockets, all three both with and without ssl). Plus possibly handling a proxy. But, as far as I can tell (please correct me if I'm wrong), that method is essentially a factory that returns one of 10 possible combinations. None of those methods alter the client's state. Given a few extra args for the client's attrs, they could all be refactored into functions that return some socket (I'm not suggesting this). My idea is, that instead of in future adding even more config and custom logic, to implement an 11th, a 12th, or even a 20th socket, lets just let those users that want those sockets, create them and supply them themselves. All they need to do it implement the SocketLike. I completely agree that any "user provided version must implement all of this". The intended user base for this feature would be required to handle all that for themselves, whilst creating their custom socket. And LibraryRaven for one, is telling us that they're not only willing to do so, they have already done this. And perhaps other third party libraries, as well as Paramiko even provide socket instances out of the box already, that with a few tweaks, Paho.mqtt.Python should happily work with. I'll bow to your experience though, if you think officially supporting this would create even more issues and headaches from such power users in future. |
|
The issue I see with replacing
My initial idea is that the provided user-function should be able to replace a existing function that don't access private fields, hence my suggestion to connect to "proxy-level". On the other hand, I agree that being at "SocketLike" interface is better then being a "TCP proxy opened" as it avoid to assume TCP. It opens to more possibility. But I think a good interface should allow to re-implement the internal paho socket creation with a user-provided implementation. For example to reimplement My idea could be a signature like Going this way, I would probably include two other point:
Obviously with this interface, the user create_socket have access to all details (host, port, ssl settings) and could use them. If they don't, it's up to the user. But they have everything in their hand to handle / validate them (e.g. apply the settings, silently ignore them even if it might cause unexpected result, or maybe raise error for unsupported settings). |
Implements #873
I'm raising this as a draft PR now to gather feedback. I'll add tests in due course.