Skip to content

Instantly share code, notes, and snippets.

@jgaskins
Created September 4, 2018 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jgaskins/e0386ab5ac1022b349bc38138008ee7f to your computer and use it in GitHub Desktop.
Save jgaskins/e0386ab5ac1022b349bc38138008ee7f to your computer and use it in GitHub Desktop.
Distribute a large Sidekiq job across many smaller ones
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