aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2017-06-27 13:21:02 -0400
committerGitHub <noreply@github.com>2017-06-27 13:21:02 -0400
commit1eaed91b122f3c525fa51c955f409038e2804b91 (patch)
tree8a20604ea3fd11e2b349e9bc8e7296b4683bd63e
parent200b01ca413a43b0f874c81bc02024c1b6f0d7fc (diff)
parentd7252786f4e133304b3d05966497272a2da9e098 (diff)
downloadrails-1eaed91b122f3c525fa51c955f409038e2804b91.tar.gz
rails-1eaed91b122f3c525fa51c955f409038e2804b91.tar.bz2
rails-1eaed91b122f3c525fa51c955f409038e2804b91.zip
Merge pull request #29528 from padi/actioncable_redis_alt_config_with_password
Allows for other common redis options to be in cable.yml, by default
-rw-r--r--.travis.yml6
-rw-r--r--actioncable/CHANGELOG.md9
-rw-r--r--actioncable/lib/action_cable/subscription_adapter/redis.rb4
-rw-r--r--actioncable/test/subscription_adapter/evented_redis_test.rb2
-rw-r--r--actioncable/test/subscription_adapter/redis_test.rb10
5 files changed, 23 insertions, 8 deletions
diff --git a/.travis.yml b/.travis.yml
index 847e11900a..91ac7e8e5e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,7 +11,6 @@ cache:
services:
- memcached
- - redis
addons:
postgresql: "9.4"
@@ -34,6 +33,7 @@ before_script:
# Decodes to e.g. `export VARIABLE=VALUE`
- $(base64 --decode <<< "ZXhwb3J0IFNBVUNFX0FDQ0VTU19LRVk9YTAzNTM0M2YtZTkyMi00MGIzLWFhM2MtMDZiM2VhNjM1YzQ4")
- $(base64 --decode <<< "ZXhwb3J0IFNBVUNFX1VTRVJOQU1FPXJ1YnlvbnJhaWxz")
+ - redis-server --bind 127.0.0.1 --port 6379 --requirepass 'password' --daemonize yes
script: 'ci/travis.rb'
@@ -65,25 +65,21 @@ matrix:
env: "GEM=aj:integration"
services:
- memcached
- - redis
- rabbitmq
- rvm: 2.3.4
env: "GEM=aj:integration"
services:
- memcached
- - redis
- rabbitmq
- rvm: 2.4.1
env: "GEM=aj:integration"
services:
- memcached
- - redis
- rabbitmq
- rvm: ruby-head
env: "GEM=aj:integration"
services:
- memcached
- - redis
- rabbitmq
- rvm: 2.3.4
env:
diff --git a/actioncable/CHANGELOG.md b/actioncable/CHANGELOG.md
index 2bf11da463..b1408496a0 100644
--- a/actioncable/CHANGELOG.md
+++ b/actioncable/CHANGELOG.md
@@ -1,3 +1,12 @@
+* ActionCable's `redis` adapter allows for other common redis-rb options (`host`, `port`, `db`, `password`) in cable.yml.
+
+ Previously, it accepts only a [redis:// url](https://www.iana.org/assignments/uri-schemes/prov/redis) as an option.
+ While we can add all of these options to the `url` itself, it is not explicitly documented. This alternative setup
+ is shown as the first example in the [Redis rubygem](https://github.com/redis/redis-rb#getting-started), which
+ makes this set of options as sensible as using just the `url`.
+
+ *Marc Rendl Ignacio*
+
* ActionCable socket errors are now logged to the console
Previously any socket errors were ignored and this made it hard to diagnose socket issues (e.g. as discussed in #28362).
diff --git a/actioncable/lib/action_cable/subscription_adapter/redis.rb b/actioncable/lib/action_cable/subscription_adapter/redis.rb
index a31ed33bdb..225609c236 100644
--- a/actioncable/lib/action_cable/subscription_adapter/redis.rb
+++ b/actioncable/lib/action_cable/subscription_adapter/redis.rb
@@ -10,7 +10,9 @@ module ActionCable
# Overwrite this factory method for redis connections if you want to use a different Redis library than Redis.
# This is needed, for example, when using Makara proxies for distributed Redis.
- cattr_accessor :redis_connector, default: ->(config) { ::Redis.new(url: config[:url]) }
+ cattr_accessor :redis_connector, default: ->(config) do
+ ::Redis.new(config.slice(:url, :host, :port, :db, :password))
+ end
def initialize(*)
super
diff --git a/actioncable/test/subscription_adapter/evented_redis_test.rb b/actioncable/test/subscription_adapter/evented_redis_test.rb
index 5453511549..1c99031ab0 100644
--- a/actioncable/test/subscription_adapter/evented_redis_test.rb
+++ b/actioncable/test/subscription_adapter/evented_redis_test.rb
@@ -54,6 +54,6 @@ class EventedRedisAdapterTest < ActionCable::TestCase
end
def cable_config
- { adapter: "evented_redis", url: "redis://127.0.0.1:6379/12" }
+ { adapter: "evented_redis", url: "redis://:password@127.0.0.1:6379/12" }
end
end
diff --git a/actioncable/test/subscription_adapter/redis_test.rb b/actioncable/test/subscription_adapter/redis_test.rb
index 11120b3f85..60596dd205 100644
--- a/actioncable/test/subscription_adapter/redis_test.rb
+++ b/actioncable/test/subscription_adapter/redis_test.rb
@@ -7,7 +7,7 @@ class RedisAdapterTest < ActionCable::TestCase
include ChannelPrefixTest
def cable_config
- { adapter: "redis", driver: "ruby", url: "redis://127.0.0.1:6379/12" }
+ { adapter: "redis", driver: "ruby", url: "redis://:password@127.0.0.1:6379/12" }
end
end
@@ -16,3 +16,11 @@ class RedisAdapterTest::Hiredis < RedisAdapterTest
super.merge(driver: "hiredis")
end
end
+
+class RedisAdapterTest::AlternateConfiguration < RedisAdapterTest
+ def cable_config
+ alt_cable_config = super.dup
+ alt_cable_config.delete(:url)
+ alt_cable_config.merge(host: "127.0.0.1", port: 6379, db: 12, password: "password")
+ end
+end