Skip to content

Instantly share code, notes, and snippets.

@1gor
Forked from jgaskins/worker.rb
Created February 16, 2019 13:27
Show Gist options
  • Save 1gor/40ecd0baf5f08458cd5e8d4313da57b1 to your computer and use it in GitHub Desktop.
Save 1gor/40ecd0baf5f08458cd5e8d4313da57b1 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