From 0103432a9adc32ea007eadf6209c44d6653e58c2 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 7 Jul 2015 23:13:00 +0200 Subject: Finished class documentation --- lib/action_cable/server/base.rb | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'lib/action_cable/server/base.rb') diff --git a/lib/action_cable/server/base.rb b/lib/action_cable/server/base.rb index 3d1d9e71ff..23cd8388bd 100644 --- a/lib/action_cable/server/base.rb +++ b/lib/action_cable/server/base.rb @@ -1,5 +1,9 @@ module ActionCable module Server + # A singleton ActionCable::Server instance is available via ActionCable.server. It's used by the rack process that starts the cable server, but + # also by the user to reach the RemoteConnections instead for finding and disconnecting connections across all servers. + # + # Also, this is the server instance used for broadcasting. See Broadcasting for details. class Base include ActionCable::Server::Broadcasting include ActionCable::Server::Connections @@ -12,14 +16,22 @@ module ActionCable def initialize end + # Called by rack to setup the server. def call(env) config.connection_class.new(self, env).process end + # Gateway to RemoteConnections. See that class for details. + def remote_connections + @remote_connections ||= RemoteConnections.new(self) + end + + # The thread worker pool for handling all the connection work on this server. Default size is set by config.worker_pool_size. def worker_pool @worker_pool ||= ActionCable::Server::Worker.pool(size: config.worker_pool_size) end + # Requires and returns an array of all the channel class constants in this application. def channel_classes @channel_classes ||= begin config.channel_paths.each { |channel_path| require channel_path } @@ -27,14 +39,12 @@ module ActionCable end end - def remote_connections - @remote_connections ||= RemoteConnections.new(self) - end - + # The redis pubsub adapter used for all streams/broadcasting. def pubsub @pubsub ||= redis.pubsub end + # The EventMachine Redis instance used by the pubsub adapter. def redis @redis ||= EM::Hiredis.connect(config.redis[:url]).tap do |redis| redis.on(:reconnect_failed) do @@ -45,6 +55,7 @@ module ActionCable end end + # All the identifiers applied to the connection class associated with this server. def connection_identifiers config.connection_class.identifiers end -- cgit v1.2.3