mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
DEV: Update rails_failover to avoid monkey patching Rails config.
This commit is contained in:
parent
36841210fb
commit
e82d4d8a75
@ -1,6 +1,6 @@
|
||||
GIT
|
||||
remote: https://github.com/discourse/rails_failover
|
||||
revision: 19a40ef42cb051c56d2679940ec5f00a436e670b
|
||||
revision: 850d04f4b1c4178862d9674ec0b2a46a2f1c20d9
|
||||
specs:
|
||||
rails_failover (0.4.0)
|
||||
activerecord (~> 6.0)
|
||||
@ -155,7 +155,7 @@ GEM
|
||||
hkdf (0.3.0)
|
||||
htmlentities (4.3.4)
|
||||
http_accept_language (2.1.1)
|
||||
i18n (1.8.2)
|
||||
i18n (1.8.3)
|
||||
concurrent-ruby (~> 1.0)
|
||||
image_size (1.5.0)
|
||||
in_threads (1.5.4)
|
||||
|
@ -103,6 +103,7 @@ module Discourse
|
||||
# wrong position
|
||||
config.skip_message_bus_middleware = true
|
||||
config.skip_multisite_middleware = true
|
||||
config.skip_rails_failover_active_record_middleware = true
|
||||
|
||||
# Disable so this is only run manually
|
||||
# we may want to change this later on
|
||||
|
@ -28,8 +28,8 @@ end
|
||||
|
||||
if ENV["ACTIVE_RECORD_RAILS_FAILOVER"]
|
||||
if Rails.configuration.multisite
|
||||
Rails.configuration.middleware.move_after(RailsMultisite::Middleware, RailsFailover::ActiveRecord::Middleware)
|
||||
Rails.configuration.middleware.insert_after(RailsMultisite::Middleware, RailsFailover::ActiveRecord::Middleware)
|
||||
else
|
||||
Rails.configuration.middleware.move_before(MessageBus::Rack::Middleware, RailsFailover::ActiveRecord::Middleware)
|
||||
Rails.configuration.middleware.insert_before(MessageBus::Rack::Middleware, RailsFailover::ActiveRecord::Middleware)
|
||||
end
|
||||
end
|
||||
|
@ -1,40 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# TODO: Remove once we upgrade to Rails 6.1
|
||||
# Copied implementation from https://github.com/rails/rails/pull/38169
|
||||
module ActionDispatch
|
||||
class MiddlewareStack
|
||||
def move(target, source)
|
||||
source_index = assert_index(source, :before)
|
||||
source_middleware = middlewares.delete_at(source_index)
|
||||
|
||||
target_index = assert_index(target, :before)
|
||||
middlewares.insert(target_index, source_middleware)
|
||||
end
|
||||
alias_method :move_before, :move
|
||||
|
||||
def move_after(target, source)
|
||||
source_index = assert_index(source, :after)
|
||||
source_middleware = middlewares.delete_at(source_index)
|
||||
|
||||
target_index = assert_index(target, :after)
|
||||
middlewares.insert(target_index + 1, source_middleware)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module Rails
|
||||
module Configuration
|
||||
class MiddlewareStackProxy
|
||||
def move_before(*args, &block)
|
||||
@delete_operations << -> middleware { middleware.send(__method__, *args, &block) }
|
||||
end
|
||||
|
||||
alias :move :move_before
|
||||
|
||||
def move_after(*args, &block)
|
||||
@delete_operations << -> middleware { middleware.send(__method__, *args, &block) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user