Kue: JSON API Method to update the job's progress

Created on 13 Jul 2013  Â·  6Comments  Â·  Source: Automattic/kue

Hello all,

Thank for this awesome tool. I have patched the code in order to modify with JSON API the jobs's progress

Sorry i feel unconfortable with git so I copy/paste my code here.

In ./lib/http/routes/json.js

/**
 * Update job :id :frames :totalFrames.
 */

exports.updateProgress = function(req, res){
  var id = req.params.id
    , frames = req.params.frames , totalFrames = req.params.totalFrames;

  Job.get(id, function(err, job){
    if (err) return res.send({ error: err.message });
    job.progress(frames, totalFrames);
    job.save(function(err){
      if (err) return res.send({ error: err.message });
      res.send({ message: 'updated Progress' });
    });
  });


};

And in ./lib/http/index.js

app.put('/job/:id/progress/:frames..:totalFrames', provides('json'), json.updateProgress);

Here an example:

curl -X PUT "http://domain:port/job/163/progress/1200..3000"

Sorry for my english.

Question

Most helpful comment

@behrad I don't agree with you. It's very useful feature.

Right now JSON API is completely unuseful and it's sad. Kue as a stand-alone (micro-)service is much more preferable than just a nodejs module. And it's simple to move Kue this way - just make JSON API more powerful.

All 6 comments

Hi! Is there any reason you want to update a server job's progress from an HTTP request? This seems highly unusual to me.

Brandon Carl
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Saturday, July 13, 2013 at 8:17 AM, jibay wrote:

Hello all,
Thank for this awesome tool. I have patched the code in order to modify with JSON API the jobs's progress
Sorry i feel unconfortable with git so I copy/paste my code here.
In ./lib/http/routes/json.js
/** * Update job :id :frames :totalFrames. */ exports.updateProgress = function(req, res){ var id = req.params.id , frames = req.params.frames , totalFrames = req.params.totalFrames; Job.get(id, function(err, job){ if (err) return res.send({ error: err.message }); job.progress(frames, totalFrames); job.save(function(err){ if (err) return res.send({ error: err.message }); res.send({ message: 'updated Progress' }); }); }); };
And in ./lib/http/index.js
app.put('/job/:id/progress/:frames..:totalFrames', provides('json'), json.updateProgress);
Here an example:
curl -X PUT "http://domain:port/job/163/progress/1200..3000"
Sorry for my english.

—
Reply to this email directly or view it on GitHub (https://github.com/LearnBoost/kue/issues/219).

I want to update a job's progress from PHP, using CURL (the job itself is a PHP script).

I see...makes sense from the perspective of the JSON API. I suppose that to process a job you'll need to make an HTTP request to your PHP server, which would then respond with updates.

Hello,

I dont understand why this issue is closed ? I have not seen updateProgress method.

This is unusual feature, since kue job processors are in nodejs, and worker is the one how can change job's progress. If you are using a bridged PHP/Java/XYZ handler, you can also define a bridge between your nodejs processor and your PHP script to update the job's progress within the your nodejs code.

@behrad I don't agree with you. It's very useful feature.

Right now JSON API is completely unuseful and it's sad. Kue as a stand-alone (micro-)service is much more preferable than just a nodejs module. And it's simple to move Kue this way - just make JSON API more powerful.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RodH257 picture RodH257  Â·  3Comments

JacksonGariety picture JacksonGariety  Â·  10Comments

jbrooksuk picture jbrooksuk  Â·  3Comments

mogadanez picture mogadanez  Â·  3Comments

JperF picture JperF  Â·  8Comments