aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/lib/action_cable/server/broadcasting.rb
diff options
context:
space:
mode:
authorJon Moss <me@jonathanmoss.me>2016-01-06 17:16:02 -0500
committerJon Moss <me@jonathanmoss.me>2016-01-18 18:58:57 -0500
commit0016e0410b11d40a1d730a1232c40f428d67abeb (patch)
tree172b2fe1e0e2424a2eab33c95ec38487d5b5996d /actioncable/lib/action_cable/server/broadcasting.rb
parent75f1b229fdb340b2cdaf632bb6a223213f05dc75 (diff)
downloadrails-0016e0410b11d40a1d730a1232c40f428d67abeb.tar.gz
rails-0016e0410b11d40a1d730a1232c40f428d67abeb.tar.bz2
rails-0016e0410b11d40a1d730a1232c40f428d67abeb.zip
Adapterize ActionCable storage and extract behavior
Diffstat (limited to 'actioncable/lib/action_cable/server/broadcasting.rb')
-rw-r--r--actioncable/lib/action_cable/server/broadcasting.rb10
1 files changed, 2 insertions, 8 deletions
diff --git a/actioncable/lib/action_cable/server/broadcasting.rb b/actioncable/lib/action_cable/server/broadcasting.rb
index c759239a0e..847ef50971 100644
--- a/actioncable/lib/action_cable/server/broadcasting.rb
+++ b/actioncable/lib/action_cable/server/broadcasting.rb
@@ -1,5 +1,3 @@
-require 'redis'
-
module ActionCable
module Server
# Broadcasting is how other parts of your application can send messages to the channel subscribers. As explained in Channel, most of the time, these
@@ -31,11 +29,6 @@ module ActionCable
Broadcaster.new(self, broadcasting)
end
- # The redis instance used for broadcasting. Not intended for direct user use.
- def broadcasting_redis
- @broadcasting_redis ||= Redis.new(config.redis)
- end
-
private
class Broadcaster
attr_reader :server, :broadcasting
@@ -46,7 +39,8 @@ module ActionCable
def broadcast(message)
server.logger.info "[ActionCable] Broadcasting to #{broadcasting}: #{message}"
- server.broadcasting_redis.publish broadcasting, ActiveSupport::JSON.encode(message)
+ broadcast_storage_adapter = server.config.storage_adapter.new(server).broadcast
+ broadcast_storage_adapter.publish broadcasting, ActiveSupport::JSON.encode(message)
end
end
end