aboutsummaryrefslogtreecommitdiffstats
path: root/lib/action_cable/server/base.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2015-07-07 23:13:00 +0200
committerDavid Heinemeier Hansson <david@loudthinking.com>2015-07-07 23:13:00 +0200
commit0103432a9adc32ea007eadf6209c44d6653e58c2 (patch)
tree87622c154355551b5987d0695a59a7737ae1fe08 /lib/action_cable/server/base.rb
parent410b504e85d248308a81c2def545e401769aaa81 (diff)
downloadrails-0103432a9adc32ea007eadf6209c44d6653e58c2.tar.gz
rails-0103432a9adc32ea007eadf6209c44d6653e58c2.tar.bz2
rails-0103432a9adc32ea007eadf6209c44d6653e58c2.zip
Finished class documentation
Diffstat (limited to 'lib/action_cable/server/base.rb')
-rw-r--r--lib/action_cable/server/base.rb19
1 files changed, 15 insertions, 4 deletions
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