diff options
Diffstat (limited to 'actioncable/lib')
3 files changed, 8 insertions, 10 deletions
diff --git a/actioncable/lib/action_cable/server/configuration.rb b/actioncable/lib/action_cable/server/configuration.rb index 7bd67110a5..ebbf60c6e2 100644 --- a/actioncable/lib/action_cable/server/configuration.rb +++ b/actioncable/lib/action_cable/server/configuration.rb @@ -43,8 +43,8 @@ module ActionCable rescue LoadError => e raise LoadError, "Could not load '#{path_to_adapter}'. Make sure that the adapter in config/cable.yml is valid. If you use an adapter other than 'postgresql' or 'redis' add the necessary adapter gem to the Gemfile.", e.backtrace end - ### - adapter.camelize + + adapter = adapter.camelize adapter = 'PostgreSQL' if adapter == 'Postgresql' "ActionCable::SubscriptionAdapter::#{adapter}".constantize end diff --git a/actioncable/lib/action_cable/subscription_adapter/postgresql.rb b/actioncable/lib/action_cable/subscription_adapter/postgresql.rb index 64c519beed..6465663c97 100644 --- a/actioncable/lib/action_cable/subscription_adapter/postgresql.rb +++ b/actioncable/lib/action_cable/subscription_adapter/postgresql.rb @@ -5,7 +5,6 @@ require 'thread' module ActionCable module SubscriptionAdapter class PostgreSQL < Base # :nodoc: - # The storage instance used for broadcasting. Not intended for direct user use. def broadcast(channel, payload) with_connection do |pg_conn| pg_conn.exec("NOTIFY #{pg_conn.escape_identifier(channel)}, '#{pg_conn.escape_string(payload)}'") diff --git a/actioncable/lib/action_cable/subscription_adapter/redis.rb b/actioncable/lib/action_cable/subscription_adapter/redis.rb index 9615430be4..d149f28b1f 100644 --- a/actioncable/lib/action_cable/subscription_adapter/redis.rb +++ b/actioncable/lib/action_cable/subscription_adapter/redis.rb @@ -6,13 +6,12 @@ require 'redis' module ActionCable module SubscriptionAdapter class Redis < Base # :nodoc: - # The redis instance used for broadcasting. Not intended for direct user use. def broadcast(channel, payload) - broadcast_redis_connection.publish(channel, payload) + redis_connection_for_broadcasts.publish(channel, payload) end def subscribe(channel, message_callback, success_callback = nil) - subscription_redis_connection.pubsub.subscribe(channel, &message_callback).tap do |result| + redis_connection_for_subscriptions.pubsub.subscribe(channel, &message_callback).tap do |result| result.callback(&success_callback) if success_callback end end @@ -22,16 +21,16 @@ module ActionCable end private - def subscription_redis_connection - @subscription_redis_connection ||= EM::Hiredis.connect(@server.config.cable[:url]).tap do |redis| + def redis_connection_for_subscriptions + @redis_connection_for_subscriptions ||= EM::Hiredis.connect(@server.config.cable[:url]).tap do |redis| redis.on(:reconnect_failed) do @logger.info "[ActionCable] Redis reconnect failed." end end end - def broadcast_redis_connection - @broadcast_redis_connection ||= ::Redis.new(@server.config.cable) + def redis_connection_for_broadcasts + @redis_connection_for_broadcasts ||= ::Redis.new(@server.config.cable) end end end |