Add channel_prefix support to AC redis/evented_redis adapters #27425
Conversation
|
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @rafaelfranca (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review. Please see the contribution instructions for more information. |
|
cc @matthewd |
rafaelfranca
left a comment
There was a problem hiding this comment.
Thank you for the pull request. It makes sense to me. I made some minor comments in the files.
There was a problem hiding this comment.
It don't need to be a concern.
There was a problem hiding this comment.
Put a blank line after this one
There was a problem hiding this comment.
Put a blank line after this one
There was a problem hiding this comment.
I'm pretty sure this test would pass if it was added without any of the above implementation.
"It still works" is a good baseline, but we'll also need to prove we're achieving our aim: that two differently-configured adapters don't interfere with each other. (Ideally, we can make that a generic test for all adapters -- some will pass naturally, and others will be able to pull in the namespacing module.)
There was a problem hiding this comment.
I'm having trouble writing tests with two differently configured adapters as ActionCable::Server::Base's config is defined as a cattr_accessor, so when I make a second one & give it a new config, it shares config with the first.
There was a problem hiding this comment.
I worked around my issue by subclassing ActionCable::Server::Base and making config an instance var. I made the tests an included module in the tests as I wasn't sure how to generalize it as the pg adapter is scoped by database. To generalize it, we could have all adapters support channel prefix, as while it's not needed by all adapters, it shouldn't hurt anything either.
There was a problem hiding this comment.
This info probably better lives in the "how to configure the adapter" documentation. Do we have any of that at the moment? 😅
There was a problem hiding this comment.
I think docs around ac adapter configuration needs some work. Don't think it even mentions the existence of a Postgres adapter for example. :)
There was a problem hiding this comment.
Instead of making the adapter call channel_name, if we prepend the module, it could define broadcast/subscribe/unsubscribe methods that mangle the name then super.
There was a problem hiding this comment.
:nodoc:
How about we call this ChannelPrefix or similar? SubscriptionAdapter::Naming feels a bit too vague to me.
|
Github didn't send me any notices about the comments here. Will make the requested changes. |
|
I believe I addressed everything here except documentation updates, but I'm not sure where those would go as documentation on configuring actioncable is rather sparse at the moment. |
|
Added some documentation on SubscriptionAdapter configuration to the ActionCable Overview guide. Not sure if it's in-scope for this PR or not. |
rafaelfranca
left a comment
There was a problem hiding this comment.
Could you squash your first 6 commits in one?
|
Sure
…On Tue, Jan 17, 2017, 11:11 PM Rafael França ***@***.***> wrote:
***@***.**** requested changes on this pull request.
Could you squash your first 6 commits in one?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#27425 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AWGp59TchMiZHaiYdLlYuW3ha5YrbyTFks5rTZECgaJpZM4LTLjs>
.
|
|
Rebased & squashed. Shall I open a separate PR for the documentation updates? |
|
It was fine in a separated commit here but since you pulled it off a separate PR would be better |
|
#27719 has the docs updates |
|
Noticed the build failed on 2.3.3. Transient error? Couldn't reproduce it locally. |
|
It should be fine now |
Add changelog entry for #27425 [ci skip]
Summary
#27224
In Redis, Pub/Sub has no relation to the key space. It was made to not interfere with it on any level, including database numbers.
Publishing on db 10, will be heard by a subscriber on db 1.
(https://redis.io/topics/pubsub#database-amp-scoping)
To avoid problems when multiple Rails applications use the same Redis instance, the redis/evented_redis subscription adapters now support a channel_prefix option (specified in cable.yml)
Other backends do not appear to have this issue.
The generated cable.yml has also been updated to reflect this change.