-
-
Save 1gor/40ecd0baf5f08458cd5e8d4313da57b1 to your computer and use it in GitHub Desktop.
Distribute a large Sidekiq job across many smaller ones
This file contains hidden or 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