2015-07-05 16:34:23 -04:00
|
|
|
module ActionCable
|
|
|
|
module Server
|
2015-07-07 17:13:00 -04:00
|
|
|
# An instance of this configuration object is available via ActionCable.server.config, which allows you to tweak the configuration points
|
|
|
|
# in a Rails config initializer.
|
2015-07-05 16:34:23 -04:00
|
|
|
class Configuration
|
|
|
|
attr_accessor :logger, :log_tags
|
|
|
|
attr_accessor :connection_class, :worker_pool_size
|
2016-01-06 17:16:02 -05:00
|
|
|
attr_accessor :channels_path
|
2015-10-07 12:24:20 -04:00
|
|
|
attr_accessor :disable_request_forgery_protection, :allowed_request_origins
|
2016-01-06 17:16:02 -05:00
|
|
|
attr_accessor :config_opts, :url
|
2015-07-05 16:34:23 -04:00
|
|
|
|
|
|
|
def initialize
|
|
|
|
@log_tags = []
|
|
|
|
|
|
|
|
@connection_class = ApplicationCable::Connection
|
|
|
|
@worker_pool_size = 100
|
|
|
|
|
|
|
|
@channels_path = Rails.root.join('app/channels')
|
2015-10-07 12:24:20 -04:00
|
|
|
|
|
|
|
@disable_request_forgery_protection = false
|
2015-07-05 16:34:23 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def channel_paths
|
|
|
|
@channels ||= Dir["#{channels_path}/**/*_channel.rb"]
|
|
|
|
end
|
|
|
|
|
|
|
|
def channel_class_names
|
|
|
|
@channel_class_names ||= channel_paths.collect do |channel_path|
|
|
|
|
Pathname.new(channel_path).basename.to_s.split('.').first.camelize
|
|
|
|
end
|
|
|
|
end
|
2016-01-06 17:16:02 -05:00
|
|
|
|
|
|
|
ADAPTER = ActionCable::StorageAdapter
|
|
|
|
|
|
|
|
# Returns constant of storage adapter specified in config/cable.yml
|
|
|
|
# If the adapter cannot be found, this will default to the Redis adapter
|
|
|
|
def storage_adapter
|
|
|
|
# "ActionCable::StorageAdapter::#{adapter.capitalize}"
|
|
|
|
adapter = config_opts['adapter']
|
|
|
|
adapter_const = "ActionCable::StorageAdapter::#{adapter.capitalize}"
|
|
|
|
|
|
|
|
if Object.const_defined?(adapter_const)
|
|
|
|
adapter_const.constantize
|
|
|
|
else
|
|
|
|
ADAPTER_BASE::Redis
|
|
|
|
end
|
|
|
|
end
|
2015-07-05 16:34:23 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|