Created
September 4, 2018 19:39
-
-
Save jgaskins/e0386ab5ac1022b349bc38138008ee7f to your computer and use it in GitHub Desktop.
Distribute a large Sidekiq job across many smaller ones
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProcessThings | |
include Sidekiq::Worker | |
def perform(ids: Thing.ids) | |
ids.each(&Individual.method(:perform_async)) | |
end | |
class Individual | |
include Sidekiq::Worker | |
def perform id | |
thing = Thing.find(id) | |
# process the individual thing | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment