contribsys / faktory_worker_ruby

Faktory worker for Ruby
GNU Lesser General Public License v3.0
214 stars 31 forks source link

Only load this when it's rails 5 and above #26

Closed nathanpalmer closed 6 years ago

nathanpalmer commented 6 years ago

I pulled Faktory into a project that was using Rails 4.2.10 and it started failing with this message

2018-10-23T19:25:05.898Z 15469 TID-ouik8horw WARN: NoMethodError: undefined method `reloader' for #<App::Application:0x00007f81e2c2d510>
Did you mean?  reloaders
2018-10-23T19:25:05.898Z 15469 TID-ouik8horw WARN: /Users/nathan/.rvm/gems/ruby-2.3.7/gems/faktory_worker_ruby-0.7.1/lib/faktory/rails.rb:33:in `call'
/Users/nathan/.rvm/gems/ruby-2.3.7/gems/faktory_worker_ruby-0.7.1/lib/faktory/processor.rb:132:in `block (2 levels) in dispatch'
/Users/nathan/.rvm/gems/ruby-2.3.7/gems/faktory_worker_ruby-0.7.1/lib/faktory/job_logger.rb:7:in `call'
/Users/nathan/.rvm/gems/ruby-2.3.7/gems/faktory_worker_ruby-0.7.1/lib/faktory/processor.rb:127:in `block in dispatch'
/Users/nathan/.rvm/gems/ruby-2.3.7/gems/faktory_worker_ruby-0.7.1/lib/faktory/logging.rb:43:in `with_context'
/Users/nathan/.rvm/gems/ruby-2.3.7/gems/faktory_worker_ruby-0.7.1/lib/faktory/logging.rb:37:in `with_job_hash_context'
/Users/nathan/.rvm/gems/ruby-2.3.7/gems/faktory_worker_ruby-0.7.1/lib/faktory/processor.rb:126:in `dispatch'
/Users/nathan/.rvm/gems/ruby-2.3.7/gems/faktory_worker_ruby-0.7.1/lib/faktory/processor.rb:145:in `process'
/Users/nathan/.rvm/gems/ruby-2.3.7/gems/faktory_worker_ruby-0.7.1/lib/faktory/processor.rb:91:in `process_one'
/Users/nathan/.rvm/gems/ruby-2.3.7/gems/faktory_worker_ruby-0.7.1/lib/faktory/processor.rb:74:in `run'
/Users/nathan/.rvm/gems/ruby-2.3.7/gems/faktory_worker_ruby-0.7.1/lib/faktory/util.rb:16:in `watchdog'
/Users/nathan/.rvm/gems/ruby-2.3.7/gems/faktory_worker_ruby-0.7.1/lib/faktory/util.rb:25:in `block in safe_thread'

When researching both Rails APIs I noticed that Rails 4 has reloaders but not reloader (singular.) I also noticed that Sidekiq was only setting up the reloader on Rails 5, so I added this to match.

Let me know what you think.

mperham commented 6 years ago

FWR really only supports Rails 5+. Rails 4 is several years old and newer infrastructure like Faktory can't support older releases like that. I would prefer to see a patch which simply disallows use on Rails <5.

nathanpalmer commented 6 years ago

Fair enough. I've modified it so it'll block the startup and show a warning.

**************************************************
🚫 ERROR: Faktory Worker does not support Rails versions under 5.x - please ensure your workers are updated
**************************************************

Your current version of Rails, 4.2.10, is not supported
/Users/nathan/Source/OpenSource/faktory_worker_ruby/lib/faktory/rails.rb:24:in `block (2 levels) in <class:Rails>'
/Users/nathan/Source/OpenSource/faktory_worker_ruby/lib/faktory.rb:57:in `configure_worker'
/Users/nathan/Source/OpenSource/faktory_worker_ruby/lib/faktory/rails.rb:22:in `block in <class:Rails>'
mperham commented 6 years ago

Thanks Nathan!