mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 09:26:54 -06:00
Extract valid connection types into a constant.
This commit is contained in:
parent
48e118a054
commit
60c21a3393
@ -7,6 +7,7 @@ class DiscourseRedis
|
|||||||
include Singleton
|
include Singleton
|
||||||
|
|
||||||
MASTER_LINK_STATUS = "master_link_status:up".freeze
|
MASTER_LINK_STATUS = "master_link_status:up".freeze
|
||||||
|
CONNECTION_TYPES = %w{normal pubsub}.each(&:freeze)
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@master = true
|
@master = true
|
||||||
@ -31,8 +32,11 @@ class DiscourseRedis
|
|||||||
|
|
||||||
if slave_client.call([:info]).split("\r\n").include?(MASTER_LINK_STATUS)
|
if slave_client.call([:info]).split("\r\n").include?(MASTER_LINK_STATUS)
|
||||||
logger.warn "#{log_prefix}: Master server is active, killing all connections to slave..."
|
logger.warn "#{log_prefix}: Master server is active, killing all connections to slave..."
|
||||||
slave_client.call([:client, [:kill, 'type', 'normal']])
|
|
||||||
slave_client.call([:client, [:kill, 'type', 'pubsub']])
|
CONNECTION_TYPES.each do |connection_type|
|
||||||
|
slave_client.call([:client, [:kill, 'type', connection_type]])
|
||||||
|
end
|
||||||
|
|
||||||
Discourse.clear_readonly!
|
Discourse.clear_readonly!
|
||||||
Discourse.request_refresh!
|
Discourse.request_refresh!
|
||||||
@master = true
|
@master = true
|
||||||
|
@ -84,7 +84,7 @@ describe DiscourseRedis do
|
|||||||
fallback_handler.master = false
|
fallback_handler.master = false
|
||||||
Redis::Client.any_instance.expects(:call).with([:info]).returns(DiscourseRedis::FallbackHandler::MASTER_LINK_STATUS)
|
Redis::Client.any_instance.expects(:call).with([:info]).returns(DiscourseRedis::FallbackHandler::MASTER_LINK_STATUS)
|
||||||
|
|
||||||
%w{normal pubsub}.each do |connection_type|
|
DiscourseRedis::FallbackHandler::CONNECTION_TYPES.each do |connection_type|
|
||||||
Redis::Client.any_instance.expects(:call).with([:client, [:kill, 'type', connection_type]])
|
Redis::Client.any_instance.expects(:call).with([:client, [:kill, 'type', connection_type]])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user