Revert "FIX: use Redis replica host and port (#11543)" (#11552)

This reverts commit b0e1210b0c.
This commit is contained in:
Krzysztof Kotlarek 2020-12-22 16:16:50 +11:00 committed by GitHub
parent b0e1210b0c
commit 07bf7a91f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 54 deletions

View File

@ -163,26 +163,6 @@ class GlobalSetting
@message_bus_config = nil @message_bus_config = nil
end end
def self.get_redis_replica_host
return redis_replica_host if redis_replica_host.present?
redis_slave_host if respond_to?(:redis_slave_host) && redis_slave_host.present?
end
def self.get_redis_replica_port
return redis_replica_port if redis_replica_port.present?
redis_slave_port if respond_to?(:redis_slave_port) && redis_slave_port.present?
end
def self.get_message_bus_redis_replica_host
return message_bus_redis_replica_host if message_bus_redis_replica_host.present?
message_bus_redis_slave_host if respond_to?(:message_bus_redis_slave_host) && message_bus_redis_slave_host.present?
end
def self.get_message_bus_redis_replica_port
return message_bus_redis_replica_port if message_bus_redis_replica_port.present?
message_bus_redis_slave_port if respond_to?(:message_bus_redis_slave_port) && message_bus_redis_slave_port.present?
end
def self.redis_config def self.redis_config
@config ||= @config ||=
begin begin
@ -190,9 +170,9 @@ class GlobalSetting
c[:host] = redis_host if redis_host c[:host] = redis_host if redis_host
c[:port] = redis_port if redis_port c[:port] = redis_port if redis_port
if get_redis_replica_host && get_redis_replica_port && defined?(RailsFailover) if redis_slave_host && redis_slave_port && defined?(RailsFailover)
c[:replica_host] = get_redis_replica_host c[:replica_host] = redis_slave_host
c[:replica_port] = get_redis_replica_port c[:replica_port] = redis_slave_port
c[:connector] = RailsFailover::Redis::Connector c[:connector] = RailsFailover::Redis::Connector
end end
@ -214,9 +194,9 @@ class GlobalSetting
c[:host] = message_bus_redis_host if message_bus_redis_host c[:host] = message_bus_redis_host if message_bus_redis_host
c[:port] = message_bus_redis_port if message_bus_redis_port c[:port] = message_bus_redis_port if message_bus_redis_port
if get_message_bus_redis_replica_host && get_message_bus_redis_replica_port if message_bus_redis_slave_host && message_bus_redis_slave_port
c[:replica_host] = get_message_bus_redis_replica_host c[:replica_host] = message_bus_redis_slave_host
c[:replica_port] = get_message_bus_redis_replica_port c[:replica_port] = message_bus_redis_slave_port
c[:connector] = RailsFailover::Redis::Connector c[:connector] = RailsFailover::Redis::Connector
end end

View File

@ -124,11 +124,11 @@ redis_host = localhost
# redis server port # redis server port
redis_port = 6379 redis_port = 6379
# redis replica server address # redis slave server address
redis_replica_host = redis_slave_host =
# redis replica server port # redis slave server port
redis_replica_port = 6379 redis_slave_port = 6379
# redis database # redis database
redis_db = 0 redis_db = 0
@ -151,11 +151,11 @@ message_bus_redis_host = localhost
# message bus redis server port # message bus redis server port
message_bus_redis_port = 6379 message_bus_redis_port = 6379
# message bus redis replica server address # message bus redis slave server address
message_bus_redis_replica_host = message_bus_redis_slave_host =
# message bus redis slave server port # message bus redis slave server port
message_bus_redis_replica_port = 6379 message_bus_redis_slave_port = 6379
# message bus redis database # message bus redis database
message_bus_redis_db = 0 message_bus_redis_db = 0

View File

@ -1,17 +0,0 @@
# frozen_string_literal: true
if GlobalSetting.respond_to?(:redis_slave_host) && GlobalSetting.redis_slave_host.present?
Discourse.deprecate("redis_slave_host is deprecated, use redis_replica_host instead", drop_from: "2.8")
end
if GlobalSetting.respond_to?(:redis_slave_port) && GlobalSetting.redis_slave_port.present?
Discourse.deprecate("redis_slave_port is deprecated, use redis_replica_port instead", drop_from: "2.8")
end
if GlobalSetting.respond_to?(:message_bus_redis_slave_host) && GlobalSetting.message_bus_redis_slave_host.present?
Discourse.deprecate("message_bus_redis_slave_host is deprecated, use message_bus_redis_replica_host", drop_from: "2.8")
end
if GlobalSetting.respond_to?(:message_bus_redis_slave_port) && GlobalSetting.message_bus_redis_slave_port.present?
Discourse.deprecate("message_bus_redis_slave_port is deprecated, use message_bus_redis_replica_port", drop_from: "2.8")
end

View File

@ -67,13 +67,13 @@ describe GlobalSetting do
end end
describe '.redis_config' do describe '.redis_config' do
describe 'when replica config is not present' do describe 'when slave config is not present' do
it "should not set any connector" do it "should not set any connector" do
expect(GlobalSetting.redis_config[:connector]).to eq(nil) expect(GlobalSetting.redis_config[:connector]).to eq(nil)
end end
end end
describe 'when replica config is present' do describe 'when slave config is present' do
before do before do
GlobalSetting.reset_redis_config! GlobalSetting.reset_redis_config!
end end
@ -83,8 +83,8 @@ describe GlobalSetting do
end end
it "should set the right connector" do it "should set the right connector" do
GlobalSetting.expects(:redis_replica_port).returns(6379).at_least_once GlobalSetting.expects(:redis_slave_port).returns(6379).at_least_once
GlobalSetting.expects(:redis_replica_host).returns('0.0.0.0').at_least_once GlobalSetting.expects(:redis_slave_host).returns('0.0.0.0').at_least_once
expect(GlobalSetting.redis_config[:connector]).to eq(RailsFailover::Redis::Connector) expect(GlobalSetting.redis_config[:connector]).to eq(RailsFailover::Redis::Connector)
end end