I have a Rails 5 app where I'm starting to move various jobs to the background using Sidekiq, Heroku and Redis.
So far I have ResetFinanceDataWorker which has a Class of the same name.
//reset_finance_data_worker.rb
class ResetFinanceDataWorker
include Sidekiq::Worker
sidekiq_options retry: false
def perform()
end
end
I can call this by calling ResetFinanceDataWorker.perform_in(10.seconds)
. Ideally, I would like to have several workers in one file, like this:
//finance_worker.rb
class AnotherWorker
include Sidekiq::Worker
sidekiq_options retry: false
def perform()
end
end
class ResetFinanceDataWorker
include Sidekiq::Worker
sidekiq_options retry: false
def perform()
end
end
And being able to call FinanceWorker.AnotherWorker.perform_in(10.seconds). However, this is not possible.
Can someone explain me 1) How would I make that work? and 2) Best practices around organising worker files.
Thanks.