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

Support out-of-process "group_add" and "group_discard" for PubSub channel layer #264

Closed
jalaziz opened this issue Jul 6, 2021 · 5 comments

Comments

@jalaziz
Copy link
Contributor

jalaziz commented Jul 6, 2021

In #247, this comment explain why the initial implementation of the PubSub channel layer does not support out-of-process group_add (and by extension, group_discard).

However, I believe this is a bigger limitation than it might seem at first. In our case, the issue is not so much a consumer subscribing a different consumer, but rather being able to dynamically subscribe and unsubscribe a consumer from normal HTTP activity.

In our case, this comes into play in a couple different scenarios:

  • When an admin disables a user, we clean up the existing group subscriptions. This is done from whatever HTTP server receives the request.
  • When a user's permission change, we subscribe or unsubscribe them from certain groups. This allows for a very dynamic, near real-time experience, without the need for the client refreshing or reconnecting.

I do realize that both these scenarios are possible by sending the Consumers a custom "command" message to have them call group_add and group_discard in-process, but it would be nice to not have to add the extra logic in our app layer for something this foundational.

@qeternity
Copy link
Contributor

I think this is going to be a fundamental limitation of pubsub as opposed to anything specific to the implementation.

@jalaziz
Copy link
Contributor Author

jalaziz commented Jul 8, 2021

Yeah, to be fair, I haven't given much thought to how it could work with pubsub. I also haven't yet tried the workaround I outlined above.

Hope to get to it this weekend to get a better idea of how big of a limitation this is.

@qeternity
Copy link
Contributor

The workaround you mention should be the proper way to handle it. It cleaner.

The method you're current using is possible through sheer accident of redis architecture at the time.

@acu192
Copy link
Collaborator

acu192 commented Jul 25, 2021

I do realize that both these scenarios are possible by sending the Consumers a custom "command" message to have them call group_add and group_discard in-process, but it would be nice to not have to add the extra logic in our app layer for something this foundational.

Yes, IMO this is how it should be done. If you know the channel name of a consumer (seems that you do), it is safe to call this.channel_layer.send(...) using the pubsub impl to send a message directly to that consumer. That will work fine. In turn, that consumer can do its own group_add and group_discard. (I know you have this in mind already, I'm just reiterating the idea for posterity.)

Definitely less convenient, but IMO it's the most robust way to solve it.

@jalaziz
Copy link
Contributor Author

jalaziz commented Mar 6, 2022

Closing this as the workaround of sending messages back to the original consumer to manage groups seems to work fine.

@jalaziz jalaziz closed this as completed Mar 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants