better-lock 2.0.1-beta → 2.0.2-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/markdown.xml +9 -0
- package/README.md +41 -49
- package/package.json +6 -5
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="MarkdownSettings">
|
|
4
|
+
<enabledExtensions>
|
|
5
|
+
<entry key="MermaidLanguageExtension" value="false" />
|
|
6
|
+
<entry key="PlantUMLLanguageExtension" value="false" />
|
|
7
|
+
</enabledExtensions>
|
|
8
|
+
</component>
|
|
9
|
+
</project>
|
package/README.md
CHANGED
|
@@ -22,6 +22,8 @@ A (better) node.js lock library.
|
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
24
|
npm install --save better-lock
|
|
25
|
+
# or
|
|
26
|
+
yarn add better-lock
|
|
25
27
|
```
|
|
26
28
|
|
|
27
29
|
### Usage examples
|
|
@@ -186,8 +188,6 @@ Most commonly used options are:
|
|
|
186
188
|
- `queue_size`
|
|
187
189
|
Max queue size for waiting jobs.
|
|
188
190
|
|
|
189
|
-
Options are presented using `snake_case`, but you can also provide them using `camelCase` keys, if that better suits your code style (eg. `extend_stack_traces` becomes `extendStackTraces`).
|
|
190
|
-
|
|
191
191
|
Default options are a static member `DEFAULT_OPTIONS` on the `BetterLock` class. That can be seen [here](src/better_lock.ts). During runtime, you can change the defaults like this:
|
|
192
192
|
|
|
193
193
|
```javascript
|
|
@@ -196,53 +196,53 @@ import BetterLock from 'better-lock';
|
|
|
196
196
|
BetterLock.DEFAULT_OPTIONS.wait_timeout = 1000;
|
|
197
197
|
```
|
|
198
198
|
|
|
199
|
-
###
|
|
199
|
+
### When to use
|
|
200
200
|
|
|
201
|
-
|
|
201
|
+
This library is a good fit if:
|
|
202
202
|
|
|
203
|
-
|
|
203
|
+
- You need a local lock in your node.js application.
|
|
204
|
+
- You have some advanced needs, like multiple keys per lock, timeouts, aborting...
|
|
205
|
+
- You like good error messages, with full stack traces.
|
|
206
|
+
- You like good types, either through typescript or JSDoc comments
|
|
204
207
|
|
|
205
|
-
|
|
206
|
-
- Added features (execution timeout, abort jobs...)
|
|
207
|
-
- Extended stack traces (so when you get an error, you have a full stack trace of the original calling code)
|
|
208
|
-
- JSDoc comments (helps if you're using an IDE)
|
|
208
|
+
The library is not a good fit if:
|
|
209
209
|
|
|
210
|
-
|
|
210
|
+
- **You need lock reentrancy.**
|
|
211
|
+
There is no good solution for this in node.js that I know of. And this library doesn't offer any.
|
|
211
212
|
|
|
212
|
-
-
|
|
213
|
-
|
|
214
|
-
- Interface, with executor and the callback function
|
|
215
|
-
- Promises
|
|
216
|
-
- Timeout and queue limit
|
|
213
|
+
- **You need a shared lock between different nodes**
|
|
214
|
+
This library is a single process only. If you need to coordinate multiple apps or services, you need a different library.
|
|
217
215
|
|
|
218
|
-
|
|
216
|
+
### Change log
|
|
219
217
|
|
|
220
|
-
|
|
218
|
+
#### **2.0.0** (_2021/05/30_)
|
|
221
219
|
|
|
222
|
-
|
|
220
|
+
Major update. The entire library was rewritten in typescript, so you should now get typings in most editors. We also had to switch tests from mocha + chai to jest (easier ts integration).
|
|
223
221
|
|
|
224
|
-
|
|
222
|
+
The API and features have remained largely the same, just a bit of a refresh.
|
|
225
223
|
|
|
226
|
-
|
|
224
|
+
Non-breaking and internal changes:
|
|
227
225
|
|
|
228
|
-
|
|
226
|
+
- We now export all error names as a type script type. A few other types as well.
|
|
227
|
+
- Errors now have `name` parameter, which matches these names.
|
|
229
228
|
|
|
230
|
-
|
|
229
|
+
Breaking changes:
|
|
231
230
|
|
|
232
|
-
|
|
231
|
+
- You can no longer use camel case versions of external-facing objects. Eg. you can no longer pass `waitTimeout` instead of `wait_timeout`. In retrospect, this was a pretty flaky API to maintain.
|
|
233
232
|
|
|
234
|
-
|
|
233
|
+
- Internal `LockJob` class is no longer exported.
|
|
235
234
|
|
|
236
|
-
-
|
|
237
|
-
- Restored DEFAULT_OPTIONS.
|
|
235
|
+
- Also, errors no longer expose internal `LockJob` instances (`err.job`). We now instead provide the most important fields from the job (`id` and `keys`).
|
|
238
236
|
|
|
239
|
-
|
|
237
|
+
- Error names have been renamed to have `BetterLock` prefix. Eg. `WaitTimeoutError` -> `BetterLockWaitTimeoutError`. This will influence `err.name` and `err.message` parameters. The idea here is, if you see `BetterLock` error in the wild, you will know what generated it.
|
|
240
238
|
|
|
241
|
-
|
|
239
|
+
- We have renamed `BetterLock.BetterLockError` to `BetterLock.BaseError` and `BetterLock.BetterLockInternalError` to `BetterLock.InternalError` to better match the naming scheme.
|
|
242
240
|
|
|
243
|
-
|
|
241
|
+
- Since Options are no longer a class but interface, we are no longer exporting them under `BetterLock.Options`. You can do `import {BetterLockOptions} from 'better-lock';` to get the typescript type.
|
|
244
242
|
|
|
245
|
-
|
|
243
|
+
#### **1.0.1** (_2019/01/28_)
|
|
244
|
+
|
|
245
|
+
Handle empty key list
|
|
246
246
|
|
|
247
247
|
#### **1.0.0** (_2019/01/28_)
|
|
248
248
|
|
|
@@ -251,34 +251,26 @@ Major version bump.
|
|
|
251
251
|
- Added multi-key locks and refactored a bunch of internals.
|
|
252
252
|
- Removed `OVERFLOW_STRATEGIES` and related options, which is mostly the reason for the major version bump. The library should otherwise work the same.
|
|
253
253
|
|
|
254
|
-
#### **
|
|
255
|
-
|
|
256
|
-
Handle empty key list
|
|
257
|
-
|
|
258
|
-
#### **2.0.0** (_2021/05/30_)
|
|
259
|
-
|
|
260
|
-
Major update. The entire library was rewritten in typescript, so you should now get typings in most editors. We also had to switch tests from mocha + chai to jest (easier ts integration).
|
|
261
|
-
|
|
262
|
-
The API and features have remained largely the same, just a bit of a refresh.
|
|
254
|
+
#### **0.3.1** (_2018/10/01_)
|
|
263
255
|
|
|
264
|
-
|
|
256
|
+
Updated CI to use the current node versions (0.8 & 0.10). Older node versions should continue to work, but are no longer tested. Also, README updates.
|
|
265
257
|
|
|
266
|
-
|
|
267
|
-
- Errors now have `name` parameter, which matches these names.
|
|
258
|
+
#### **0.3.0** (_2018/10/01_)
|
|
268
259
|
|
|
269
|
-
|
|
260
|
+
Can abort jobs waiting in queue.
|
|
270
261
|
|
|
271
|
-
|
|
262
|
+
#### **0.2.1** (_2018/09/27_)
|
|
272
263
|
|
|
273
|
-
-
|
|
264
|
+
- Better and customizable Promise detection.
|
|
265
|
+
- Restored DEFAULT_OPTIONS.
|
|
274
266
|
|
|
275
|
-
|
|
267
|
+
#### **0.2.0** (_2018/09/27_)
|
|
276
268
|
|
|
277
|
-
|
|
269
|
+
Code reformat, better pattern for loading options. No feature upgrades.
|
|
278
270
|
|
|
279
|
-
|
|
271
|
+
#### **0.1.1** (_2018/06/04_)
|
|
280
272
|
|
|
281
|
-
|
|
273
|
+
You can now use a Number as job name
|
|
282
274
|
|
|
283
275
|
### Development
|
|
284
276
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-lock",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2-beta",
|
|
4
4
|
"description": "A (better) node.js lock library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
"sync"
|
|
27
27
|
],
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@types/jest": "^
|
|
29
|
+
"@types/jest": "^27.5.1",
|
|
30
30
|
"@typescript-eslint/eslint-plugin": "^4.25.0",
|
|
31
31
|
"@typescript-eslint/parser": "^4.25.0",
|
|
32
32
|
"eslint": "^7.27.0",
|
|
33
33
|
"eslint-config-prettier": "^8.3.0",
|
|
34
34
|
"import-sort-style-module": "^6.0.0",
|
|
35
|
-
"jest": "^
|
|
35
|
+
"jest": "^28.1.0",
|
|
36
36
|
"prettier": "latest",
|
|
37
37
|
"prettier-plugin-import-sort": "0.0.7",
|
|
38
|
-
"ts-jest": "^
|
|
38
|
+
"ts-jest": "^28.0.3",
|
|
39
39
|
"typescript": "^4.3.2"
|
|
40
40
|
},
|
|
41
41
|
"author": "Ivan Pantic",
|
|
@@ -52,5 +52,6 @@
|
|
|
52
52
|
".js, .jsx": {
|
|
53
53
|
"style": "module"
|
|
54
54
|
}
|
|
55
|
-
}
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {}
|
|
56
57
|
}
|