1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

config_opts => cable, per @kaspth

This commit is contained in:
Jon Moss 2016-01-15 17:26:17 -05:00
parent 78ff63ee41
commit 75489642c8
3 changed files with 7 additions and 6 deletions

View file

@ -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) }

View file

@ -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

View file

@ -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