diff options
Diffstat (limited to 'actioncable')
-rw-r--r-- | actioncable/lib/action_cable/engine.rb | 2 | ||||
-rw-r--r-- | actioncable/lib/action_cable/server/configuration.rb | 4 | ||||
-rw-r--r-- | actioncable/lib/action_cable/storage_adapter/redis.rb | 7 |
3 files changed, 7 insertions, 6 deletions
diff --git a/actioncable/lib/action_cable/engine.rb b/actioncable/lib/action_cable/engine.rb index 193f54333e..f5e233e091 100644 --- a/actioncable/lib/action_cable/engine.rb +++ b/actioncable/lib/action_cable/engine.rb @@ -28,7 +28,7 @@ module ActionCable ActiveSupport.on_load(:action_cable) do if (config_path = Pathname.new(app.config.paths["config/cable"].first)).exist? - self.config_opts = Rails.application.config_for(config_path).with_indifferent_access + self.cable = Rails.application.config_for(config_path).with_indifferent_access end options.each { |k,v| send("#{k}=", v) } diff --git a/actioncable/lib/action_cable/server/configuration.rb b/actioncable/lib/action_cable/server/configuration.rb index 2349f36198..c43928d898 100644 --- a/actioncable/lib/action_cable/server/configuration.rb +++ b/actioncable/lib/action_cable/server/configuration.rb @@ -7,7 +7,7 @@ module ActionCable attr_accessor :connection_class, :worker_pool_size attr_accessor :channels_path attr_accessor :disable_request_forgery_protection, :allowed_request_origins - attr_accessor :config_opts, :url + attr_accessor :cable, :url def initialize @log_tags = [] @@ -34,7 +34,7 @@ module ActionCable # If the adapter cannot be found, this will default to the Redis adapter def storage_adapter # Defaults to redis if no adapter is set - adapter = config_opts.fetch('adapter') { 'redis' } + adapter = cable.fetch('adapter') { 'redis' } "ActionCable::StorageAdapter::#{adapter.camelize}".constantize end end diff --git a/actioncable/lib/action_cable/storage_adapter/redis.rb b/actioncable/lib/action_cable/storage_adapter/redis.rb index 3f0f6c4172..3e0ede057a 100644 --- a/actioncable/lib/action_cable/storage_adapter/redis.rb +++ b/actioncable/lib/action_cable/storage_adapter/redis.rb @@ -27,14 +27,15 @@ module ActionCable # The EventMachine Redis instance used by the pubsub adapter. def hi_redis_conn - @redis ||= EM::Hiredis.connect(@server.config.config_opts[:url]).tap do |redis| + @hi_redis_conn ||= EM::Hiredis.connect(@server.config.cable[:url]).tap do |redis| 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 end end + def redis_conn + @redis_conn ||= ::Redis.new(@server.config.cable) + end end end end |