vsivsi / meteor-job-collection

A persistent and reactive job queue for Meteor, supporting distributed workers that can run anywhere.
https://atmospherejs.com/vsivsi/job-collection
Other
385 stars 68 forks source link

Run a recurring job now #220

Closed damienrobson closed 7 years ago

damienrobson commented 7 years ago

I have a job that runs every 10 minutes. If I want to override a single instance of it and run it now (i.e. via a button press), how should I do it? I figured the following should work, but to no avail:

    const job = Jobs.findOne({ 'data.name': name, status: 'waiting' });
    if (job) {
      const j = Jobs.getJob(job._id);
      j.ready({ time: new Date(), force: true });
    }
vsivsi commented 7 years ago

The playground app implements exactly the functionality you describe.

https://github.com/vsivsi/meteor-job-collection-playground/blob/master/play.coffee#L187

damienrobson commented 7 years ago

Thanks, @vsivsi - that works a treat :)