Add support for more providers (Ably, Channels, SocketIO) #26
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.
WIP for #25
This doesn't seem like it will be all that bad.
The "PusherBackend" class is used to register that events from Model X will be serialized using Serializer Y with Provider Z. Providers are our implementation of Pusher, Ably, Django Channels, etc.
The "Provider" classes, formerly the "PusherProxy", implement
__init__(self)
,configure(self)
, andtrigger(self, channels: List[str], event_name: str, data: Dict, socket_id=None)
. I had to remove the actual type annotations in the code for python 3.5 compatibility.The signal receiver no longer touches the settings, the Provider class uses the
configure(self)
method to access the settings for credentials and whatnot for that specific provider. The signals now act as a controller of push rather than the initiator of the push; it doesn't implement any provider specific logic, it just parses the event data and provider and executes that.I've added a
packet_adapter
class to the PusherBackend that is used to potentially transform the packet data (channels, event_name, data) before it is sent to the signal, incase a provider expects some extra data in the future.