Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use kue replace 'settimeout'? #355

Closed
feifeiiiiiiiiiii opened this issue Jul 2, 2014 · 2 comments
Closed

use kue replace 'settimeout'? #355

feifeiiiiiiiiiii opened this issue Jul 2, 2014 · 2 comments

Comments

@feifeiiiiiiiiiii
Copy link

I want try use kue to replace 'setTimeout' function
code as follow:

var jobs = kue.createQueue();

var task = {
      title: 'welcome email for tj'
     , to: 'tj@learnboost.com'
     , template: 'welcome-email'
};

var job = jobs.create('email', task).delay(1000).save();
jobs.promote();

jobs.process('email', function(job, done) {

  # retry add task to queue
  jobs.create('email', task).delay(1000).save();
  done();
})

the code is right ??

@behrad
Copy link
Collaborator

behrad commented Jul 2, 2014

Since you are re-creating jobs, this is actually a setInterval not setTimeout, Yes! this is right, but be aware that those two are low-level built-in node.js timers, however Kue may not be that accurate (up-to-millisecond or event seconds). if your delays are around one second, and you have a small set of delayed jobs, you'd better call promote(500);

@feifeiiiiiiiiiii
Copy link
Author

Yeah, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants