agenda
Advanced tools
Comparing version 3.1.0 to 4.0.0
@@ -6,2 +6,72 @@ Next | ||
4.0.0 / 2021-01-16 | ||
================== | ||
* Add `agenda.close()` ([#450](https://github.com/agenda/agenda/pull/450)) thanks @simison | ||
* Add ability to schedule jobs with startDate, endDate, and skipping ([#361](https://github.com/agenda/agenda/pull/361)) thanks @suryanaik | ||
* Fix issue with concurrent locking beyond locklimit ([#1086](https://github.com/agenda/agenda/pull/1086)) thanks @leonardlin | ||
* Fix issue with too many locks being set asynchronously ([#1119](https://github.com/agenda/agenda/pull/1119)) thanks @GimpMaster | ||
* Upgrade `mongodb` dependency ~3.5.0 -> ~3.6.2 (security) ([#1122](https://github.com/agenda/agenda/pull/1122)) thanks @Elisa23 | ||
* Upgrade to [Human Interval v2](https://github.com/agenda/human-interval/blob/master/History.md#200--2020-10-16), a refactor using [numbered](https://www.npmjs.com/package/numbered) package: | ||
- Supports all the formats as previously, and more! | ||
- Supports numbers written as English words (one, two hundred) | ||
- Supports time expressions in singular and plural (minute and minutes) | ||
- Supports negative numbers (-2) | ||
- Supports hyphenated words (twenty-five) | ||
* Upgrade various dependencies | ||
BREAKING | ||
-------- | ||
* Switch from [ncb000gt/node-cron](https://www.npmjs.com/package/cron) to [harrisiirak/cron-parser](https://www.npmjs.com/package/cron-parser) for cron-pattern parsing. See issue ([#475](https://github.com/kelektiv/node-cron/issues/475)) | ||
Previously month was 0-based (0=January). Going forward standard Unix pattern is used, which is 1-based (1=January). | ||
Please update existing cron-patterns that specify a month (4th position of a pattern). The month is now 1 - 12 | ||
1 = January | ||
2 = February | ||
3... | ||
| Example | Execute on 1st of January | | ||
|---------|---------------------------| | ||
| Old | 0 0 1 **0** * | | ||
| New | 0 0 1 **1** * | | ||
([#1150](https://github.com/agenda/agenda/pull/1150)) | ||
old Cron patterns | ||
``` | ||
* * * * * * | ||
| | | | | | | ||
| | | | | +-- Year (range: 1900-3000) | ||
| | | | +---- Day of the Week (range: 1-7, 1 standing for Monday) | ||
| | | +------ Month of the Year (range: 0-11) NOTE: Difference here | ||
| | +-------- Day of the Month (range: 1-31) | ||
| +---------- Hour (range: 0-23) | ||
+------------ Minute (range: 0-59) | ||
``` | ||
new cron patterns | ||
``` | ||
* * * * * * | ||
| | | | | | | ||
| | | | | +-- Year (range: 1900-3000) | ||
| | | | +---- Day of the Week (range: 1-7, 1 standing for Monday) | ||
| | | +------ Month of the Year (range: 1-12) NOTE: Difference here | ||
| | +-------- Day of the Month (range: 1-31) | ||
| +---------- Hour (range: 0-23) | ||
+------------ Minute (range: 0-59) | ||
``` | ||
3.1.0 / 2020-04-07 | ||
@@ -8,0 +78,0 @@ ================== |
{ | ||
"name": "agenda", | ||
"version": "3.1.0", | ||
"version": "4.0.0", | ||
"description": "Light weight job scheduler for Node.js", | ||
@@ -13,3 +13,5 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "npm run lint && npm run mocha", | ||
"build": "tsc", | ||
"pretest": "npm run build", | ||
"test": "npm run mocha", | ||
"lint": "xo --verbose", | ||
@@ -46,28 +48,35 @@ "mocha": "mocha --reporter spec --timeout 8000 -b", | ||
"dependencies": { | ||
"cron": "~1.8.0", | ||
"cron-parser": "^2.18.0", | ||
"date.js": "~0.3.3", | ||
"debug": "~4.1.1", | ||
"human-interval": "~1.0.0", | ||
"debug": "~4.3.0", | ||
"human-interval": "~2.0.0", | ||
"moment-timezone": "~0.5.27", | ||
"mongodb": "~3.5.0" | ||
"mongodb": "~3.6.2" | ||
}, | ||
"devDependencies": { | ||
"@types/debug": "^4.1.5", | ||
"@types/human-interval": "^1.0.0", | ||
"@types/mongodb": "^3.5.27", | ||
"@typescript-eslint/eslint-plugin": "4.11.0", | ||
"@typescript-eslint/parser": "4.11.0", | ||
"blanket": "1.2.3", | ||
"coveralls": "3.0.11", | ||
"delay": "4.3.0", | ||
"eslint": "6.8.0", | ||
"eslint-config-xo": "0.27.2", | ||
"eslint-plugin-ava": "10.2.0", | ||
"eslint-plugin-eslint-comments": "3.1.2", | ||
"eslint-plugin-import": "2.20.2", | ||
"coveralls": "3.1.0", | ||
"delay": "4.4.0", | ||
"eslint": "7.16.0", | ||
"eslint-config-xo": "0.33.1", | ||
"eslint-config-xo-typescript": "0.37.0", | ||
"eslint-plugin-ava": "11.0.0", | ||
"eslint-plugin-eslint-comments": "3.2.0", | ||
"eslint-plugin-import": "2.22.1", | ||
"eslint-plugin-node": "11.1.0", | ||
"eslint-plugin-unicorn": "16.1.1", | ||
"eslint-plugin-unicorn": "24.0.0", | ||
"expect.js": "0.3.1", | ||
"jsdoc": "3.6.4", | ||
"jsdoc": "3.6.6", | ||
"jsdoc-template": "https://github.com/braintree/jsdoc-template", | ||
"mocha": "7.1.1", | ||
"mocha": "8.2.1", | ||
"mocha-lcov-reporter": "1.3.0", | ||
"q": "1.5.1", | ||
"sinon": "9.0.1", | ||
"xo": "0.27.2" | ||
"sinon": "9.2.2", | ||
"typescript": "4.1.3", | ||
"xo": "0.36.1" | ||
}, | ||
@@ -80,6 +89,3 @@ "xo": { | ||
"rules": { | ||
"space-before-function-paren": [ | ||
"error", | ||
"never" | ||
], | ||
"prefer-const": "error", | ||
"max-params": [ | ||
@@ -92,2 +98,10 @@ "error", | ||
5 | ||
], | ||
"object-curly-spacing": [ | ||
"error", | ||
"always", | ||
{ | ||
"objectsInObjects": false, | ||
"arraysInObjects": false | ||
} | ||
] | ||
@@ -97,4 +111,24 @@ }, | ||
"node" | ||
], | ||
"overrides": [ | ||
{ | ||
"files": "**/*.ts", | ||
"rules": { | ||
"@typescript-eslint/space-before-function-paren": [ | ||
"error", | ||
"never" | ||
] | ||
} | ||
}, | ||
{ | ||
"files": "**/*.js", | ||
"rules": { | ||
"space-before-function-paren": [ | ||
"error", | ||
"never" | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} |
@@ -26,5 +26,6 @@ <p align="center"> | ||
- Event backed job queue that you can hook into. | ||
- [Agendash](https://github.com/agenda/agendash): optional standalone web-interface. | ||
- [Agendash2](https://github.com/agenda/agendash-v2): optional standalone web-interface. | ||
- [Agenda-rest](https://github.com/agenda/agenda-rest): optional standalone REST API. | ||
- [inversify-agenda](https://github.com/lautarobock/inversify-agenda) - Some utilities for the development of agenda workers with Inversify | ||
- [Inversify-agenda](https://github.com/lautarobock/inversify-agenda) - Some utilities for the development of agenda workers with Inversify. | ||
- [Agendash](https://github.com/agenda/agendash): optional standalone web-interface (legacy, not maintained anymore). | ||
@@ -36,3 +37,3 @@ ### Feature Comparison | ||
Agenda is great if you need something that is simple and backed by MongoDB. | ||
Agenda is great if you need a MongoDB job scheduler, but try **[Bree](https://jobscheduler.net)** if you need something simpler (built by a previous maintainer). | ||
@@ -201,4 +202,4 @@ | Feature | Bull | Bee | Agenda | | ||
Takes a string `name` and sets `lastModifiedBy` to it in the job database. | ||
Useful for if you have multiple job processors (agendas) and want to see which | ||
Sets the `lastModifiedBy` field to `name` in the jobs collection. | ||
Useful if you have multiple job processors (agendas) and want to see which | ||
job queue last ran the job. | ||
@@ -343,8 +344,8 @@ | ||
### define(jobName, [options], fn) | ||
### define(jobName, [options], handler) | ||
Defines a job with the name of `jobName`. When a job of `jobName` gets run, it | ||
will be passed to `fn(job, done)`. To maintain asynchronous behavior, you may | ||
either provide a Promise-returning function in `fn` *or* provide `done` as a | ||
second parameter to `fn`. If `done` is specified in the function signature, you | ||
will be passed to `handler(job, done)`. To maintain asynchronous behavior, you may | ||
either provide a Promise-returning function in `handler` *or* provide `done` as a | ||
second parameter to `handler`. If `done` is specified in the function signature, you | ||
must call `done()` when you are processing the job. If your function is | ||
@@ -552,3 +553,15 @@ synchronous or returns a Promise, you may omit `done` from the signature. | ||
### close(force) | ||
Closes database connection. You don't normally have to do this, but it might be useful for testing purposes. | ||
Using `force` boolean you can force close connection. | ||
Read more from [Node.js MongoDB Driver API](https://mongodb.github.io/node-mongodb-native/2.0/api/Db.html#close) | ||
```js | ||
await agenda.close({ force: true }); | ||
``` | ||
## Multiple job processors | ||
@@ -597,2 +610,8 @@ | ||
`options.startDate`: `Date` the first time the job runs, should be equal or after the start date. | ||
`options.endDate`: `Date` the job should not repeat after the endDate. The job can run on the end-date itself, but not after that. | ||
`options.skipDays`: `humand readable string` ('2 days'). After each run, it will skip the duration of 'skipDays' | ||
```js | ||
@@ -655,7 +674,7 @@ job.repeatEvery('10 minutes'); | ||
```js | ||
job.unique({'data.type': 'active', 'data.userId': '123', nextRunAt(date)}); | ||
job.unique({'data.type': 'active', 'data.userId': '123', nextRunAt: date}); | ||
await job.save(); | ||
``` | ||
*IMPORTANT:* To avoid high CPU usage by MongoDB, make sure to create an index on the used fields, like `data.type` and `data.userId` for the example above. | ||
*IMPORTANT:* To [guarantee uniqueness](https://docs.mongodb.com/manual/reference/method/db.collection.update/#use-unique-indexes) as well as avoid high CPU usage by MongoDB make sure to create a unique index on the used fields, like `name`, `data.type` and `data.userId` for the example above. | ||
@@ -694,3 +713,3 @@ ### fail(reason) | ||
await job.save(); | ||
cosole.log('Successfully saved job to collection'); | ||
console.log('Successfully saved job to collection'); | ||
} catch (e) { | ||
@@ -697,0 +716,0 @@ console.error('Error saving job to collection'); |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
125042
53
1756
1064
25
1
+ Addedcron-parser@^2.18.0
+ Addedcall-bind@1.0.7(transitive)
+ Addedcron-parser@2.18.0(transitive)
+ Addeddebug@4.3.4(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddefine-properties@1.2.1(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedhuman-interval@2.0.1(transitive)
+ Addedis-nan@1.3.2(transitive)
+ Addedmongodb@3.6.12(transitive)
+ Addedms@2.1.2(transitive)
+ Addednumbered@1.1.0(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedoptional-require@1.1.8(transitive)
+ Addedrequire-at@1.0.6(transitive)
+ Addedset-function-length@1.2.2(transitive)
- Removedcron@~1.8.0
- Removedcron@1.8.3(transitive)
- Removeddebug@4.1.1(transitive)
- Removedhuman-interval@1.0.0(transitive)
- Removedluxon@1.28.1(transitive)
- Removedmongodb@3.5.11(transitive)
- Removedms@2.1.3(transitive)
- Removedrequire_optional@1.0.1(transitive)
- Removedresolve-from@2.0.0(transitive)
- Removedsemver@5.7.2(transitive)
Updateddebug@~4.3.0
Updatedhuman-interval@~2.0.0
Updatedmongodb@~3.6.2