aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable
diff options
context:
space:
mode:
authorVladimir Dementyev <dementiev.vm@gmail.com>2019-02-14 13:59:10 -0500
committerJeremy Daer <jeremydaer@gmail.com>2019-02-14 16:22:03 -0800
commitc43c83984792ac546e7610c898cf9099cc1a2ee6 (patch)
treebac5a0974cde406e72fe6ee8e2bcb76827599da5 /actioncable
parent6183483fa13bb1cac7e32f64df568fc2f9fb9a6b (diff)
downloadrails-c43c83984792ac546e7610c898cf9099cc1a2ee6.tar.gz
rails-c43c83984792ac546e7610c898cf9099cc1a2ee6.tar.bz2
rails-c43c83984792ac546e7610c898cf9099cc1a2ee6.zip
feat: support channel_prefix in pg subscription adapter
Diffstat (limited to 'actioncable')
-rw-r--r--actioncable/CHANGELOG.md6
-rw-r--r--actioncable/lib/action_cable/subscription_adapter/postgresql.rb2
-rw-r--r--actioncable/test/subscription_adapter/postgresql_test.rb1
3 files changed, 9 insertions, 0 deletions
diff --git a/actioncable/CHANGELOG.md b/actioncable/CHANGELOG.md
index 3ce35edbb8..600d4e130f 100644
--- a/actioncable/CHANGELOG.md
+++ b/actioncable/CHANGELOG.md
@@ -1,3 +1,9 @@
+* PostgreSQL subscription adapters now support `channel_prefix` option in cable.yml
+
+ Avoids channel name collisions when multiple apps use the same database for Action Cable.
+
+ *Vladimir Dementyev*
+
* Allow passing custom configuration to `ActionCable::Server::Base`.
You can now create a standalone Action Cable server with a custom configuration
diff --git a/actioncable/lib/action_cable/subscription_adapter/postgresql.rb b/actioncable/lib/action_cable/subscription_adapter/postgresql.rb
index 50ec438c3a..1d60bed4af 100644
--- a/actioncable/lib/action_cable/subscription_adapter/postgresql.rb
+++ b/actioncable/lib/action_cable/subscription_adapter/postgresql.rb
@@ -8,6 +8,8 @@ require "digest/sha1"
module ActionCable
module SubscriptionAdapter
class PostgreSQL < Base # :nodoc:
+ prepend ChannelPrefix
+
def initialize(*)
super
@listener = nil
diff --git a/actioncable/test/subscription_adapter/postgresql_test.rb b/actioncable/test/subscription_adapter/postgresql_test.rb
index 5fb26a8896..d262536d61 100644
--- a/actioncable/test/subscription_adapter/postgresql_test.rb
+++ b/actioncable/test/subscription_adapter/postgresql_test.rb
@@ -7,6 +7,7 @@ require "active_record"
class PostgresqlAdapterTest < ActionCable::TestCase
include CommonSubscriptionAdapterTest
+ include ChannelPrefixTest
def setup
database_config = { "adapter" => "postgresql", "database" => "activerecord_unittest" }