diff --git a/lib/sidekiq/redis_connection.rb b/lib/sidekiq/redis_connection.rb index 3d3299db..f21c3d15 100644 --- a/lib/sidekiq/redis_connection.rb +++ b/lib/sidekiq/redis_connection.rb @@ -8,6 +8,8 @@ module Sidekiq class << self def create(options={}) + options = options.symbolize_keys + options[:url] ||= determine_redis_provider size = options[:size] || (Sidekiq.server? ? (Sidekiq.options[:concurrency] + 5) : 5) @@ -33,7 +35,7 @@ module Sidekiq # - enterprise's leader election # - enterprise's cron support def verify_sizing(size, concurrency) - raise ArgumentError, "Your Redis connection pool is too small for Sidekiq to work, your pool has #{size} connections but really needs to have at least #{concurrency + 2}" if size <= concurrency + raise ArgumentError, "Your Redis connection pool is too small for Sidekiq to work. Your pool has #{size} connections but really needs to have at least #{concurrency + 2}" if size <= concurrency end def build_client(options) @@ -45,8 +47,8 @@ module Sidekiq require 'redis/namespace' Redis::Namespace.new(namespace, :redis => client) rescue LoadError - Sidekiq.logger.error("Your Redis configuration use the namespace '#{namespace}' but the redis-namespace gem not included in Gemfile." \ - "Add the gem to your Gemfile in case you would like to keep using a namespace, otherwise remove the namespace parameter.") + Sidekiq.logger.error("Your Redis configuration uses the namespace '#{namespace}' but the redis-namespace gem is not included in the Gemfile." \ + "Add the gem to your Gemfile to continue using a namespace. Otherwise, remove the namespace parameter.") exit(-127) end else diff --git a/test/test_redis_connection.rb b/test/test_redis_connection.rb index 8ecd2b39..a7c9c79a 100644 --- a/test/test_redis_connection.rb +++ b/test/test_redis_connection.rb @@ -27,11 +27,16 @@ class TestRedisConnection < Sidekiq::Test end describe "namespace" do - it "uses a given :namespace" do + it "uses a given :namespace set by a symbol key" do pool = Sidekiq::RedisConnection.create(:namespace => "xxx") assert_equal "xxx", pool.checkout.namespace end + it "uses a given :namespace set by a string key" do + pool = Sidekiq::RedisConnection.create("namespace" => "xxx") + assert_equal "xxx", pool.checkout.namespace + end + it "uses given :namespace over :namespace from Sidekiq.options" do Sidekiq.options[:namespace] = "xxx" pool = Sidekiq::RedisConnection.create(:namespace => "yyy")