Comparing version 5.0.0-pre2 to 5.0.0
@@ -10,3 +10,6 @@ # 5.0.0 | ||
A scheduled job's time-to-live is equal to its interval. This better matches | ||
expectations on transient error conditions. | ||
# 4.1.3 | ||
@@ -13,0 +16,0 @@ |
@@ -174,3 +174,3 @@ // Essentially cron for scheduling tasks in Node. | ||
// If true, every new job is started automatically. Necessary in case you | ||
// call schedule() after calling start(). | ||
// call scheduleJob() after calling start(). | ||
this.started = false; | ||
@@ -262,6 +262,7 @@ | ||
const schedule = this._schedules.get(jobName); | ||
if (schedule) | ||
if (shouldRunJob(schedule, job)) | ||
return schedule._runJob(jobName, time); | ||
else { | ||
debug('No schedule %s, ignoring', jobName); | ||
debug('Ignoring this occurrence of %s', jobName); | ||
return Promise.resolve(); | ||
@@ -298,1 +299,20 @@ } | ||
// A scheduled job may be returned to the queue when it fails or times out. | ||
// For recurring jobs, we don't want to run duplicate jobs once the error | ||
// condition is resolved. | ||
// Returns true if the job should be run. | ||
function shouldRunJob(schedule, job) { | ||
if (schedule) { | ||
if (schedule.every) { | ||
const jobTime = +new Date(job.time); | ||
const expiredBy = jobTime + schedule.every; | ||
const isExpired = Date.now() > expiredBy; | ||
return !isExpired; | ||
} else { | ||
// One-offs never expire (i.e. they must be retried until successful). | ||
return true; | ||
} | ||
} else | ||
return false; | ||
} |
{ | ||
"name": "ironium", | ||
"version": "5.0.0-pre2", | ||
"version": "5.0.0", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "lint": "eslint .", |
@@ -409,2 +409,6 @@ # [Ironium](https://www.npmjs.com/package/ironium) | ||
Both scheduled and delayed jobs can be tested by mocking `Date`, also known as | ||
time traveling by tools like [TimeKeeper](https://github.com/vesln/timekeeper#timekeeper). | ||
### purgeQueues() | ||
@@ -519,7 +523,7 @@ | ||
If you're running in production against an [Iron.io](https://hud.iron.io/), you | ||
If you're running in production against [Iron.io](https://hud.iron.io/), you | ||
need to set `host`, `project_id` and `token` based on your project credentials. | ||
This is the same format as `iron.json`. | ||
By default, Ironium will process 10 jobs concurrently. You can change this value | ||
By default, Ironium will process 50 jobs concurrently. You can change this value | ||
using the `concurrency` option. | ||
@@ -526,0 +530,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
128322
44
2770
0
549