async-queue-runner 0.16.0 → 0.18.0
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/_cjs/index.js +2 -1
- package/_cjs/queue.js +4 -3
- package/_esm/index.js +1 -1
- package/_esm/queue.js +4 -3
- package/_types/index.d.ts +1 -1
- package/package.json +1 -1
package/_cjs/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.util = exports.Action = exports.AsyncQueue = exports.QueueRunner = void 0;
|
|
3
|
+
exports.util = exports.lockingClassFactory = exports.Action = exports.AsyncQueue = exports.QueueRunner = void 0;
|
|
4
4
|
var runner_js_1 = require("./runner.js");
|
|
5
5
|
Object.defineProperty(exports, "QueueRunner", { enumerable: true, get: function () { return runner_js_1.QueueRunner; } });
|
|
6
6
|
var queue_js_1 = require("./queue.js");
|
|
7
7
|
Object.defineProperty(exports, "AsyncQueue", { enumerable: true, get: function () { return queue_js_1.AsyncQueue; } });
|
|
8
8
|
var action_js_1 = require("./action.js");
|
|
9
9
|
Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return action_js_1.Action; } });
|
|
10
|
+
Object.defineProperty(exports, "lockingClassFactory", { enumerable: true, get: function () { return action_js_1.lockingClassFactory; } });
|
|
10
11
|
var utils_js_1 = require("./utils.js");
|
|
11
12
|
Object.defineProperty(exports, "util", { enumerable: true, get: function () { return utils_js_1.util; } });
|
package/_cjs/queue.js
CHANGED
|
@@ -49,14 +49,18 @@ class AsyncQueue {
|
|
|
49
49
|
}
|
|
50
50
|
const item = this.queue.shift();
|
|
51
51
|
const action = this.processQueueItem(item);
|
|
52
|
+
const actionName = action.constructor.name || 'some undefined';
|
|
53
|
+
this.logger.setContext(actionName);
|
|
52
54
|
const isLocking = action.locking;
|
|
53
55
|
const scope = action.scope;
|
|
54
56
|
if (isLocking) {
|
|
55
57
|
if (this.locker.isLocked(scope)) {
|
|
58
|
+
this.logger.info(`Queue(${this.name}): waiting for scope to unlock`);
|
|
56
59
|
await this.locker.wait(scope);
|
|
57
60
|
}
|
|
58
61
|
this.locker.lock(scope);
|
|
59
62
|
}
|
|
63
|
+
this.logger.info(`Queue(${this.name}): running action`);
|
|
60
64
|
await this.iterate(action);
|
|
61
65
|
if (isLocking) {
|
|
62
66
|
this.locker.unlock(scope);
|
|
@@ -70,9 +74,6 @@ class AsyncQueue {
|
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
76
|
async iterate(action) {
|
|
73
|
-
const actionName = action.constructor.name || 'some undefined';
|
|
74
|
-
this.logger.setContext(actionName);
|
|
75
|
-
this.logger.info(`Queue(${this.name}): running action`);
|
|
76
77
|
await action.execute(this.context);
|
|
77
78
|
await this.delay(action.delay);
|
|
78
79
|
}
|
package/_esm/index.js
CHANGED
package/_esm/queue.js
CHANGED
|
@@ -46,14 +46,18 @@ export class AsyncQueue {
|
|
|
46
46
|
}
|
|
47
47
|
const item = this.queue.shift();
|
|
48
48
|
const action = this.processQueueItem(item);
|
|
49
|
+
const actionName = action.constructor.name || 'some undefined';
|
|
50
|
+
this.logger.setContext(actionName);
|
|
49
51
|
const isLocking = action.locking;
|
|
50
52
|
const scope = action.scope;
|
|
51
53
|
if (isLocking) {
|
|
52
54
|
if (this.locker.isLocked(scope)) {
|
|
55
|
+
this.logger.info(`Queue(${this.name}): waiting for scope to unlock`);
|
|
53
56
|
await this.locker.wait(scope);
|
|
54
57
|
}
|
|
55
58
|
this.locker.lock(scope);
|
|
56
59
|
}
|
|
60
|
+
this.logger.info(`Queue(${this.name}): running action`);
|
|
57
61
|
await this.iterate(action);
|
|
58
62
|
if (isLocking) {
|
|
59
63
|
this.locker.unlock(scope);
|
|
@@ -67,9 +71,6 @@ export class AsyncQueue {
|
|
|
67
71
|
}
|
|
68
72
|
}
|
|
69
73
|
async iterate(action) {
|
|
70
|
-
const actionName = action.constructor.name || 'some undefined';
|
|
71
|
-
this.logger.setContext(actionName);
|
|
72
|
-
this.logger.info(`Queue(${this.name}): running action`);
|
|
73
74
|
await action.execute(this.context);
|
|
74
75
|
await this.delay(action.delay);
|
|
75
76
|
}
|
package/_types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { IAction, ActionClass, QueueAction, Branches, QueueContext } from './types.js';
|
|
2
2
|
export { QueueRunner, EndListener } from './runner.js';
|
|
3
3
|
export { AsyncQueue, QueueOpts } from './queue.js';
|
|
4
|
-
export { Action, Options } from './action.js';
|
|
4
|
+
export { Action, Options, lockingClassFactory } from './action.js';
|
|
5
5
|
export { util } from './utils.js';
|