-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added flexible eager load configuration for Resque when used in Rails application #1818
base: master
Are you sure you want to change the base?
Conversation
6f4d338
to
4f3b12e
Compare
@georgiybykov Is there a reason you don't do something like:
Pretty sure this would force rails to load before the resque app? |
The file # frozen_string_literal: true
require 'resque/tasks'
namespace :resque do
task :setup => :environment
...
end The code above is not a solution (does not force preload all classes for the application). @iloveitaly As an alternative, do you suggest to override the # frozen_string_literal: true
require 'resque/tasks'
namespace :resque do
task :setup => :environment
task :preload => :setup do
ActiveSupport.run_load_hooks(:before_eager_load, Rails.application)
Rails.application.config.eager_load_namespaces.each(&:eager_load!)
end
end Since Rake tasks ignore the Rails application
Only if you use Rails That is why in this pull request I suggest to add flexible eager load configuration for Resque when used in Rails application without actions to override the code in Rake tasks in order to setup correctly. |
4f3b12e
to
a1fbf6b
Compare
Hi @iloveitaly! Could you look at this comment as an answer to your question please? |
@georgiybykov your explanation makes sense. Tricky problem! I need to set aside some more time to review your PR. Will hopefully get back to you soon. |
Hi @iloveitaly! Thank you again! I would be very grateful for your feedback and I hope you get a chance to review the code soon! Please let me know if I can provide anything else in the meantime. |
a1fbf6b
to
037bc9d
Compare
c39042f
to
5b97aad
Compare
I suspect there's a bit of confusion here:
However:
I believe this task should be deleted, though I might be missing something. Let Rails eager load, and let users control this via Rails. I opened #1867 with this proposal. |
5b97aad
to
67c8097
Compare
67c8097
to
ca9a356
Compare
@fxn Thank you very much for your comment! My opinion and the main points of the current pull request are:
Based on the above, you are correct, however the users with Rails version task :preload => :setup do
ActiveSupport.run_load_hooks(:before_eager_load, Rails.application)
Rails.application.config.eager_load_namespaces.each(&:eager_load!)
end because they cannot control this via the Rails configuration. |
Hi!
We faced a problem when upgraded from Resque
1.27.4
to> 2.0.0
version (using Resque gem as a dependency in Rails 6.0.4 application with Ruby 2.7.5) and lost many important events silently. The eager load for Resque task did not work was the reason.Our production configuration for
eager_load
is set totrue
:Changes documentation between versions says the following:
However, the
eager_load
will never betrue
. SinceResque
starts from Rake task, theeager_load
option configuration is set tofalse
permanently by default starting from this commit at Rails.Only if your Rails application is
6.1.0
version or above, you are able to configure eager loading for Rake tasks environment by usingrake_eager_load
option that was added in this commit to provide the ability to override the defaultfalse
value for every rake task of the environment.Based on the above, I propose to add flexible configuration for
eager_load
:To configure
eager_load
option usingResque
interface you are able to add inconfig/initializers/resque.rb
the following:
Or if you would like to configure the
eager_load
option depends on your Rails application environment, for example: