From 092ae858af79e10e30f0680ca09cf6f49c176aa6 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Tue, 16 Jun 2020 10:51:21 +0800 Subject: [PATCH] DEV: Bump rails_failover. Avoid configuring AR stuff if `replica_host` and `replica_port` hasn't been provided. --- Gemfile.lock | 2 +- config/initializers/002-rails_failover.rb | 2 ++ config/initializers/200-first_middlewares.rb | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7dc6cdc95cd..7e5e5eeebd7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -280,7 +280,7 @@ GEM nokogiri (>= 1.6) rails-html-sanitizer (1.3.0) loofah (~> 2.3) - rails_failover (0.5.0) + rails_failover (0.5.1) activerecord (~> 6.0) railties (~> 6.0) rails_multisite (2.3.0) diff --git a/config/initializers/002-rails_failover.rb b/config/initializers/002-rails_failover.rb index d414a86119e..16c5dc4bdaa 100644 --- a/config/initializers/002-rails_failover.rb +++ b/config/initializers/002-rails_failover.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +return unless Rails.configuration.active_record_rails_failover + if defined?(RailsFailover::Redis) message_bus_keepalive_interval = nil diff --git a/config/initializers/200-first_middlewares.rb b/config/initializers/200-first_middlewares.rb index e326e524bf3..3f2bce1458a 100644 --- a/config/initializers/200-first_middlewares.rb +++ b/config/initializers/200-first_middlewares.rb @@ -25,9 +25,9 @@ if Rails.configuration.multisite Rails.configuration.middleware.unshift RailsMultisite::Middleware, RailsMultisite::DiscoursePatches.config Rails.configuration.middleware.delete ActionDispatch::Executor - if defined?(RailsFailover) + if defined?(RailsFailover) && Rails.configuration.active_record_rails_failover Rails.configuration.middleware.insert_after(RailsMultisite::Middleware, RailsFailover::ActiveRecord::Middleware) end -elsif defined?(RailsFailover) +elsif defined?(RailsFailover) && Rails.configuration.active_record_rails_failover Rails.configuration.middleware.insert_before(MessageBus::Rack::Middleware, RailsFailover::ActiveRecord::Middleware) end