Conversation
Yeah, that should be fine. Previously I was thinking we might split it out into an additional adapter class that could be configurable in the handler definition, but it's much more convenient and follows the existing convention to detect this from the event context.
Should be something like this: https://github.com/jordaneremieff/mangum/blob/broadcast/mangum/adapter.py#L195.
Let's not try support this for now.
Correct, this will not support subprotocols as the application will be unaware of the actual handshake performed in the connect event. |
|
Ok, I think it's already good enough to be reviewed. All tests should pass from now on. The git history is a mess (because I did and undid some things), but we can rebase it later to clean up. I've tested this in AWS with a simple echo server using FastAPI, and a DynamoDB backend. It worked as expected. Some changes were made, comparing with the implementation present in the broadcast branch:
I've tried not to change too much the structure of the code, but unfortunately, because of the differences between WebSocket and HTTP connections, some modifications were necessary. |
|
Thanks @eduardovra! I've only had a chance to go through this at a glance, but it's looking really good - well done. I don't have a lot of capacity at the moment, but I'll try to give this a more detailed review when I can. @koxudaxi if you could give this a review as well it would be very appreciated. |
|
@eduardovra I could not work tests in my local environment, because Redis-server and PostgreSQL are not installed in my machine.
I guess if many users will use the WebSocket then they will request some new feature. |
| - uses: actions/checkout@v2 | ||
| - name: Install OS package dependencies | ||
| run: | | ||
| sudo apt-get -y install redis-server postgresql-12 |
There was a problem hiding this comment.
I recommend use docker-compose for these servers.
…ker-compose to run Redis and PostgreSQL servers
|
@koxudaxi I moved the backend tests to a subfolder and changed the implementation to use docker-compose as you suggested, but I didn't separate the launch script for the tests as you did on your project. I was afraid it might cause problems in the coverage report. Let me know if you think this is important, and I can take a better look into it. The way it is right now, the whole suite is taking about 12s to run on my machine, and if I skip the integration tests it takes less than 1 second: |
|
@eduardovra @jordaneremieff |
jordaneremieff
left a comment
There was a problem hiding this comment.
Looks great! I just have some comments for the docs, but otherwise I think this is good to merge.
Probably the main thing is to make sure the minimal example in the docs that works with the new implementation.
|
I've made the changes and added some sections detailing the extra packages that will be required depending on what backend is being used. |
|
@eduardovra great, thank you! I'll try the example out either tomorrow or the weekend then merge and push a release. Well done. :) |
|
I'm coming back to this project after a long time and stumbled across this. This is really legit! Great work! |
Reintroduce WebSocket support.
Issue #132
This is an attempt to re-introduce WebSockets support in the project. It's still just a draft, but I wanted to put something together as soon as possible to discuss and shape the solution. The implementation is basically the same as the one present in this branch.
The PR was getting way too big, and I decided to drop the support to broadcast for now. Maybe we can handle this in another PR/issue.
I've left a few TODO comments in the code on points where we should keep an eye, but overall my main questions would be these: