[Twisted-Python] Some thoughts hacking with AMP (was: something about multiplexing and accessing protocols)

Hi, Some thoughts while hacking: - The argument having access to the responder locator and then eventually it going to a responder function is kind of useless, usually. The responder function already has a reference to the locator, usually called "self" :) - The locator object can be shared between different connections, so a hack using the current status quo where you get the proto using the responder locator is... well, hacky. Also, I do really really want the protocol and not the transport. This is because I want to pass a reference to the protocol around so that later I can call callRemote on it. That I can also get the transport is mostly just gravy so that I can return nice things for my fake transport's getHost/getPeer. So, to reiterate: - I think all the docstrings should reflect the real situation. I guess I need to file a ticket for that. - Maybe there should be a new API that passes the proto (and actually means "proto" ;)) I think I have some code up (or will have some code up soon, depending on when you read this email) that does have sort-of working multiplexed transports: https://github.com/lvh/txampext When done, this will be available from pypi as txampext==0.0.6. If anyone is interested in this, the next big feature mark will be integrating _habnabit's AMP producer stuff, so that it's not just transports, but IConsumer/IProducer transports as well. cheers lvh

On Nov 22, 2013, at 4:10 AM, Laurens Van Houtven <_@lvh.io> wrote:
Also, I do really really want the protocol and not the transport. This is because I want to pass a reference to the protocol around so that later I can call callRemote on it. That I can also get the transport is mostly just gravy so that I can return nice things for my fake transport's getHost/getPeer.
Except that maybe your protocol is just a BinaryBoxProtocol, and has no callRemote method. Or maybe it's actually HTTP and feeding things to AMP after some deserialization pass, like via JSON (aren't you even doing this already in some other code?). Is there even a "protocol" visible to this code in that case? If your contract is that you accept an IProtocol, then what you can do is pretty much just call dataReceived and connectionLost ;-) unless you have some other reason to believe it provides some other interfaces.
So, to reiterate:
- I think all the docstrings should reflect the real situation. I guess I need to file a ticket for that.
Well, that's definitely true.
- Maybe there should be a new API that passes the proto (and actually means "proto" ;))
I still think that before providing this new mechanism we need *some* way of declaring that we expect more from "the protocol".
I think I have some code up (or will have some code up soon, depending on when you read this email) that does have sort-of working multiplexed transports:
Cool. -glyph

On Fri, Nov 22, 2013 at 8:00 PM, Glyph <glyph@twistedmatrix.com> wrote:
On Nov 22, 2013, at 4:10 AM, Laurens Van Houtven <_@lvh.io> wrote:
Also, I do really really want the protocol and not the transport. This is because I want to pass a reference to the protocol around so that later I can call callRemote on it. That I can also get the transport is mostly just gravy so that I can return nice things for my fake transport's getHost/getPeer.
Except that maybe your protocol is just a BinaryBoxProtocol, and has no callRemote method. Or maybe it's actually HTTP and feeding things to AMP after some deserialization pass, like via JSON (aren't you even doing this already in some other code?). Is there even a "protocol" visible to this code in that case?
Yep and yep: - I guess I mean IBoxReceiver? The thing with callRemote on it ;) - I'm doing that, and that's what I hope to do again here :)
- Maybe there should be a new API that passes the proto (and actually means "proto" ;))
I still think that before providing this new mechanism we need *some* way of declaring that we expect more from "the protocol".
Yep!
I think I have some code up (or will have some code up soon, depending on when you read this email) that does have sort-of working multiplexed transports:
Cool.
For what it's worth, I hacked together something in docs/examples that works. I'll see what I have to do to get it to work over a browser, and see what I can expose as API :)
-glyph
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
participants (2)
-
Glyph
-
Laurens Van Houtven