Skip to content

Instantly share code, notes, and snippets.

@edsrzf
Forked from treeder/batching_queue.rb
Created June 13, 2012 02:40
Show Gist options
  • Save edsrzf/2921493 to your computer and use it in GitHub Desktop.
Save edsrzf/2921493 to your computer and use it in GitHub Desktop.
Example of queuing up 100 workloads per task
users = User.all
users.each_slice(100) do |users_slice|
puts "Queueing worker..."
worker = NotificationWorker.new
worker.users = users_slice
# set other attributes that your worker needs to run
worker.queue
end
@frommww
Copy link

frommww commented Jun 13, 2012

With the _NG syntax it'd be something like this, no?

users = User.all
users.each_slice(100) do |users_slice|
puts "Queueing worker..."
client = IronWorkerNG::Client.new
params = {:users => users_slice,
# include other params the worker needs
}
client.tasks.create("notification_worker", params)
end

@edsrzf
Copy link
Author

edsrzf commented Jun 13, 2012

That looks about right to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment