-
Notifications
You must be signed in to change notification settings - Fork 62
[WIP] Channels v2 Support #42
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Inspired by DRF Views
e1263b3
to
ace569f
Compare
e781e08
to
82a1338
Compare
1bfd490
to
91fecd4
Compare
0a97f69
to
2454d5a
Compare
0be68b7
to
f1d1ac0
Compare
f1d1ac0
to
aa90024
Compare
This PR feels premature. I'd like to wait and see how channels 2.0 stabilizes before jumping into a entirely new pattern. Also you are making unrequired infrastructure to the project that I disagree with. If migrating to channels 2.0 requires rewriting the whole package then maybe it's time for a new package. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a very much work in progress
I'm opening it so we can discuss our implementation. #41
It might be good if there is a channelsv2 branch that we can do pull-requests to so the multiple people can contribute to this big upgrade without making master dirty and then just replace master once we are ready for a full release.
Testing
GenericAsyncAPIConsumer
Transactions
the
@action
decorator that must be added to all action methods now includes anatomic
option.this value will default to the Django settings
ATOMIC_REQUESTS
option if not set.Observers
this is not quite like bindings. It lets you subscribe to a given Django signal so that this signal will be sent to all instances of the consumer.
Model Observers
like signal observers @decorate a method on your consumer.
TODO
Bindings
For now, it might be best if the first implementation of this just handles actions fired through the channels-API.
I need to do some testing on were the pre-save post-save etc triggers are fired in Django when using twisted core-routines as channels v2 does for the entire app, are they triggered on all core-routines of this prosses or just in the routines that creates them?
but if we want to go with the full observation of Django signals... then:
Channels v2 does not include the Bindings module so my suggestion would be:
Pull the code from v1 into channels-API and adapt it to work with channels v2. But this could result in a license conflict (I'm not an expert)
django-channels is
BSD 3-Clause "New" or "Revised" License
.Channels-API is either BSD (as listed in settup.py) or MIT as listed in
LICENSE
alternatively, we can try to bring over the binding functions without a direct code copy just by being inspired by the same concepts.... (no idea if this is would hold up in court but those features be nice)
Django View As Consumer
I believe a nice feature to have is the ability to set up a consumer that will route
actions
to HTTP verbs and trigger a dedicated Django/DRF view.DjangoViewAsConsumer
andview_as_consumer
convenience method are examples of how this might be used.how should we handle errors in DRF, if we do nothing they will be returned in the
data
key rather than theerrors
key as they would normally return from other endpoints?GenericAsyncAPIConsumer
like DFR GenericAPIView this is the base class for all the model action view mixins.
yes a shameless copy of DRF.
Just like DRF there are a set of mixins that can be used here:
CreateModelMixin
ListModelMixin
RetrieveModelMixin
UpdateModelMixin
PatchModelMixin
DeleteModelMixin
Pagination
at the moment I have removed this we need to add it back:
there are a few different ways we could do this
a) like it was before
b) Add the support to stream data out in chunks.
eg you send 1 request and you will get back many responses each with N items, with a configurable delay between them. (this might be nice for
Pagination
of binding updates)Async Vs Sync
channels v2 supports the
async await
from Python 3.5.so the new
@action()
decorator will detect if the method isasync
if not it will wrap it inside the neededdatabase_sync_to_async
wrapper so that the consumer can call it.Other changes?
please list other changes we should make as we do this since this will require a large re-write of a lot of the code to work within the new channels v2 apis/ASGI application framework.