简体   繁体   中英

Using Node.js and Kue, is there a way to specify a date I want a task to execute?

Obviously I can set the delay to the number of miliseconds until the date I want, but that's not really going to work well in some cases, max int values are going to be a problem. If Kue can't do it, I can store date-specific jobs that are too far away in the main database that the client facing app uses, or maybe a third store, I'm just trying to avoid using more than one store for this process.

UPDATE: This is a silly question, I did some math in my head quickly and failed horribly, I guess, then asked, I should have calculated exactly before I asked.

Kue doesn't have any other way to scheduling a job, unfortunately. I do wonder what jobs you have that are need to be scheduled so far out as to overflow an integer. Considering Kue is backed by Redis I probably wouldn't want to rely on it to schedule jobs many years into the future.

If you really have to do it, then you could store the execute date with the job, and have the delay set as high as possible. When it comes time to execute, check if that date has passed, and if not then just requeue the job with the remaining ms, or with the max if the remaining is still too high.

I wouldn't worry about it due to the size of the max integer in JavaScript .

The documentation states that the dates are relative to now , so you can schedule jobs to start up to 285,427.017 years (9,007,199,254,740,992 milliseconds) into the future. Even though it says that it most likely converts the date to an absolute date which has a smaller but still rather large limit of just under: 243,090.534 years 97,671,189,983,570,992 milliseconds).

Time wise I'd be more considered about the 32-bit second overflow in 2038.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM