From 125a8445f304348d3e530e85b30991c2346155fd Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 21 Jun 2015 21:44:22 +0200 Subject: Don't namespace methods with the class we are already in --- lib/action_cable/server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/action_cable/server.rb') diff --git a/lib/action_cable/server.rb b/lib/action_cable/server.rb index 322fc85519..3a16f51757 100644 --- a/lib/action_cable/server.rb +++ b/lib/action_cable/server.rb @@ -34,7 +34,7 @@ module ActionCable redis.on(:reconnect_failed) do logger.info "[ActionCable] Redis reconnect failed." # logger.info "[ActionCable] Redis reconnected. Closing all the open connections." - # @connections.map &:close_connection + # @connections.map &:close end redis end -- cgit v1.2.3 From 321d04ff56e2f17ef7285141252dba8ff5cdecca Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 27 Jun 2015 16:50:05 +0200 Subject: Add WebSocket decorator --- lib/action_cable/server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/action_cable/server.rb') diff --git a/lib/action_cable/server.rb b/lib/action_cable/server.rb index 3a16f51757..dbfadaa34c 100644 --- a/lib/action_cable/server.rb +++ b/lib/action_cable/server.rb @@ -17,7 +17,7 @@ module ActionCable end def call(env) - @connection_class.new(self, env).process + @connection_class.new(self, env).response end def worker_pool -- cgit v1.2.3 From 3c333f1a22c1b4f0ae42161df1ce9b4c4730999d Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 27 Jun 2015 16:54:08 +0200 Subject: Change back, more is happening than just response --- lib/action_cable/server.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/action_cable/server.rb') diff --git a/lib/action_cable/server.rb b/lib/action_cable/server.rb index dbfadaa34c..3a16f51757 100644 --- a/lib/action_cable/server.rb +++ b/lib/action_cable/server.rb @@ -17,7 +17,7 @@ module ActionCable end def call(env) - @connection_class.new(self, env).response + @connection_class.new(self, env).process end def worker_pool -- cgit v1.2.3 From f61467ec5b90ebb75987a13f763b6a19548d84b3 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 28 Jun 2015 20:16:54 +0200 Subject: Move server classes to its own namespace --- lib/action_cable/server.rb | 75 ++-------------------------------------------- 1 file changed, 3 insertions(+), 72 deletions(-) (limited to 'lib/action_cable/server.rb') diff --git a/lib/action_cable/server.rb b/lib/action_cable/server.rb index 3a16f51757..e17cf872e0 100644 --- a/lib/action_cable/server.rb +++ b/lib/action_cable/server.rb @@ -1,75 +1,6 @@ module ActionCable - class Server - cattr_accessor(:logger, instance_reader: true) { Rails.logger } - - attr_accessor :registered_channels, :redis_config, :log_tags - - def initialize(redis_config:, channels:, worker_pool_size: 100, connection: Connection, log_tags: [ 'ActionCable' ]) - @redis_config = redis_config.with_indifferent_access - @registered_channels = Set.new(channels) - @worker_pool_size = worker_pool_size - @connection_class = connection - @log_tags = log_tags - - @connections = [] - - logger.info "[ActionCable] Initialized server (redis_config: #{@redis_config.inspect}, worker_pool_size: #{@worker_pool_size})" - end - - def call(env) - @connection_class.new(self, env).process - end - - def worker_pool - @worker_pool ||= ActionCable::Worker.pool(size: @worker_pool_size) - end - - def pubsub - @pubsub ||= redis.pubsub - end - - def redis - @redis ||= begin - redis = EM::Hiredis.connect(@redis_config[:url]) - redis.on(:reconnect_failed) do - logger.info "[ActionCable] Redis reconnect failed." - # logger.info "[ActionCable] Redis reconnected. Closing all the open connections." - # @connections.map &:close - end - redis - end - end - - def threaded_redis - @threaded_redis ||= Redis.new(redis_config) - end - - def remote_connections - @remote_connections ||= RemoteConnections.new(self) - end - - def broadcaster_for(channel) - Broadcaster.new(self, channel) - end - - def broadcast(channel, message) - broadcaster_for(channel).broadcast(message) - end - - def connection_identifiers - @connection_class.identifiers - end - - def add_connection(connection) - @connections << connection - end - - def remove_connection(connection) - @connections.delete connection - end - - def open_connections_statistics - @connections.map(&:statistics) - end + module Server + autoload :Base, 'action_cable/server/base' + autoload :Worker, 'action_cable/server/worker' end end -- cgit v1.2.3 From e1a99a83ca135523ff8513be756f156500999cb8 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 28 Jun 2015 20:24:50 +0200 Subject: Make broadcasting a concern --- lib/action_cable/server.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/action_cable/server.rb') diff --git a/lib/action_cable/server.rb b/lib/action_cable/server.rb index e17cf872e0..fa7bad4e32 100644 --- a/lib/action_cable/server.rb +++ b/lib/action_cable/server.rb @@ -1,6 +1,7 @@ module ActionCable module Server autoload :Base, 'action_cable/server/base' + autoload :Broadcasting, 'action_cable/server/broadcasting' autoload :Worker, 'action_cable/server/worker' end end -- cgit v1.2.3