1

Right now, the iron_worker_ruby_ng gem allows one to create tasks one at a time:

iron-worker client.tasks.create('MyWorker', {:client => 'Joe'})

Some scenarios require the creation of thousands of tasks. In this instance, it would be faster and more efficient if one could create many jobs at once:

client.tasks.create('MyWorker', [{:client => 'Joe'}, {:client => 'Bob'}, ..]) # batch of 100

--

I've forked the gem and made the changes but unfortunately the service endpoint returns 400. Is there any way to do this? If not, any chance this could be a feature?

def tasks_create_bulk(code_name, payloads, options = {})
  payloads_arg = payloads.map do |payload|
    {:code_name => code_name, :payload => payload}.merge(options)
  end

  parse_response(post("projects/#{@project_id}/tasks", {:tasks => payloads_arg}))
end

Thanks,

Dimitri

dimroc
  • 1,172
  • 1
  • 16
  • 26
  • 1
    POST /projects/{Project ID}/tasks The api endpoint for tasks creation does indeed allow you to create more than one task at a time. currently it's recommended that you create no more than100 task in one request. I think your error is happening due to the way you are mapping your payload arguments. Can you send what the request body looks like when you receive your 400? – Stephen Nguyen Oct 21 '13 at 23:21
  • I've tested the limits of this and was able to technically queue up thousands of tasks in one call. however our internal team has told me that it will likely be limited at 100 very soon. – Stephen Nguyen Oct 21 '13 at 23:22
  • 1
    You are right, it does work. It was user error. Forgot to convert the params hash to string with to_json. The returned payload was {"msg"=>"Queued up", "tasks"=> [{"id"=>"52669a791e18b57d31009914"}, {"id"=>"52669a791e18b57d31009915"}]} which is great. Thanks. – dimroc Oct 22 '13 at 15:33

0 Answers0