mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Remove Rails <5 code/patches/hacks, bump!
This commit is contained in:
parent
84d364ccd2
commit
4a0470de42
6 changed files with 5 additions and 86 deletions
|
@ -233,17 +233,8 @@ module Sidekiq
|
|||
|
||||
if File.directory?(options[:require])
|
||||
require 'rails'
|
||||
if ::Rails::VERSION::MAJOR < 4
|
||||
if ::Rails::VERSION::MAJOR < 5
|
||||
raise "Sidekiq no longer supports this version of Rails"
|
||||
elsif ::Rails::VERSION::MAJOR == 4
|
||||
# Painful contortions, see 1791 for discussion
|
||||
# No autoloading, we want to force eager load for everything.
|
||||
require File.expand_path("#{options[:require]}/config/application.rb")
|
||||
::Rails::Application.initializer "sidekiq.eager_load" do
|
||||
::Rails.application.config.eager_load = true
|
||||
end
|
||||
require 'sidekiq/rails'
|
||||
require File.expand_path("#{options[:require]}/config/environment.rb")
|
||||
else
|
||||
require 'sidekiq/rails'
|
||||
require File.expand_path("#{options[:require]}/config/environment.rb")
|
||||
|
|
|
@ -19,21 +19,9 @@ module Sidekiq
|
|||
# The email method can return nil, which causes ActionMailer to return
|
||||
# an undeliverable empty message.
|
||||
if msg
|
||||
deliver(msg)
|
||||
else
|
||||
raise "#{target.name}##{method_name} returned an undeliverable mail object"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def deliver(msg)
|
||||
if msg.respond_to?(:deliver_now)
|
||||
# Rails 4.2/5.0
|
||||
msg.deliver_now
|
||||
else
|
||||
# Rails 3.2/4.0/4.1
|
||||
msg.deliver
|
||||
raise "#{target.name}##{method_name} returned an undeliverable mail object"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
module Sidekiq
|
||||
module Middleware
|
||||
module Server
|
||||
class ActiveRecord
|
||||
|
||||
def initialize
|
||||
# With Rails 5+ we must use the Reloader **always**.
|
||||
# The reloader handles code loading and db connection management.
|
||||
if defined?(::Rails) && ::Rails::VERSION::MAJOR >= 5
|
||||
raise ArgumentError, "Rails 5 no longer needs or uses the ActiveRecord middleware."
|
||||
end
|
||||
end
|
||||
|
||||
def call(*args)
|
||||
yield
|
||||
ensure
|
||||
::ActiveRecord::Base.clear_active_connections!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,22 +2,6 @@
|
|||
|
||||
module Sidekiq
|
||||
class Rails < ::Rails::Engine
|
||||
# We need to setup this up before any application configuration which might
|
||||
# change Sidekiq middleware.
|
||||
#
|
||||
# This hook happens after `Rails::Application` is inherited within
|
||||
# config/application.rb and before config is touched, usually within the
|
||||
# class block. Definitely before config/environments/*.rb and
|
||||
# config/initializers/*.rb.
|
||||
config.before_configuration do
|
||||
if ::Rails::VERSION::MAJOR < 5 && defined?(::ActiveRecord)
|
||||
Sidekiq.server_middleware do |chain|
|
||||
require 'sidekiq/middleware/server/active_record'
|
||||
chain.add Sidekiq::Middleware::Server::ActiveRecord
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
config.after_initialize do
|
||||
# This hook happens after all initializers are run, just before returning
|
||||
# from config/environment.rb back to sidekiq/cli.rb.
|
||||
|
@ -27,9 +11,7 @@ module Sidekiq
|
|||
# None of this matters on the client-side, only within the Sidekiq process itself.
|
||||
#
|
||||
Sidekiq.configure_server do |_|
|
||||
if ::Rails::VERSION::MAJOR >= 5
|
||||
Sidekiq.options[:reloader] = Sidekiq::Rails::Reloader.new
|
||||
end
|
||||
Sidekiq.options[:reloader] = Sidekiq::Rails::Reloader.new
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -48,11 +30,5 @@ module Sidekiq
|
|||
"#<Sidekiq::Rails::Reloader @app=#{@app.class.name}>"
|
||||
end
|
||||
end
|
||||
end if defined?(::Rails)
|
||||
end
|
||||
|
||||
if defined?(::Rails) && ::Rails::VERSION::MAJOR < 4
|
||||
$stderr.puts("**************************************************")
|
||||
$stderr.puts("⛔️ WARNING: Sidekiq server is no longer supported by Rails 3.2 - please ensure your server/workers are updated")
|
||||
$stderr.puts("**************************************************")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# frozen_string_literal: true
|
||||
module Sidekiq
|
||||
VERSION = "5.2.3"
|
||||
VERSION = "6.0.0"
|
||||
end
|
||||
|
|
|
@ -198,16 +198,3 @@ module Sidekiq
|
|||
|
||||
Sidekiq::WebAction.class_eval "def _render\n#{ERB.new(File.read(Web::LAYOUT)).src}\nend"
|
||||
end
|
||||
|
||||
if defined?(::ActionDispatch::Request::Session) &&
|
||||
!::ActionDispatch::Request::Session.method_defined?(:each)
|
||||
# mperham/sidekiq#2460
|
||||
# Rack apps can't reuse the Rails session store without
|
||||
# this monkeypatch, fixed in Rails 5.
|
||||
class ActionDispatch::Request::Session
|
||||
def each(&block)
|
||||
hash = self.to_hash
|
||||
hash.each(&block)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue