Skip to content
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

Add support for more providers (Ably, Channels, SocketIO) #26

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

aljp
Copy link
Owner

@aljp aljp commented Sep 9, 2018

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), and trigger(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.

@aljp aljp requested a review from mattjegan September 9, 2018 00:24
channel = super().get_channel(instance=instance)
return "private-{channel}".format(channel=channel)
channel = super().get_channels(instance=instance)
return ["private-{channel}".format(channel=channel)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are multiple channels returned from get_channels then the return result is an array of 1 string "private-[a, b, c]" rather than a array ["private-a", "private-b", "private-c"]

@@ -18,7 +18,7 @@
EMAIL = "[email protected]"
AUTHOR = "Adam Jacquier-Parr"
REQUIRES_PYTHON = ">=3.6.0"
VERSION = "0.1.0"
VERSION = "0.2.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to bump this to 1.0.0 in this PR since we are probably introducing breaking changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants