qdone 2.0.32-alpha → 2.0.34-alpha
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/commonjs/src/consumer.js +8 -6
- package/commonjs/src/scheduler/jobExecutor.js +13 -16
- package/commonjs/src/scheduler/queueManager.js +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/src/consumer.js +7 -5
- package/src/scheduler/jobExecutor.js +8 -8
- package/src/scheduler/queueManager.js +1 -0
package/commonjs/src/consumer.js
CHANGED
|
@@ -61,7 +61,7 @@ async function processMessages(queues, callback, options) {
|
|
|
61
61
|
lastLatency = latency;
|
|
62
62
|
});
|
|
63
63
|
const jobExecutor = new jobExecutor_js_1.JobExecutor(opt);
|
|
64
|
-
const queueManager = new queueManager_js_1.QueueManager(opt, queues,
|
|
64
|
+
const queueManager = new queueManager_js_1.QueueManager(opt, queues, 10);
|
|
65
65
|
const cores = (0, os_1.cpus)().length;
|
|
66
66
|
// debug({ systemMonitor, jobExecutor, queueManager })
|
|
67
67
|
// This delay function keeps a timeout reference around so it can be
|
|
@@ -101,8 +101,7 @@ async function processMessages(queues, callback, options) {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
// Max job accounting
|
|
104
|
-
|
|
105
|
-
maxReturnCount -= messages.length;
|
|
104
|
+
maxReturnCount -= maxMessages;
|
|
106
105
|
activeQrls.delete(qrl);
|
|
107
106
|
}
|
|
108
107
|
catch (e) {
|
|
@@ -117,7 +116,8 @@ async function processMessages(queues, callback, options) {
|
|
|
117
116
|
};
|
|
118
117
|
while (!shutdownRequested) { // eslint-disable-line
|
|
119
118
|
// Figure out how we are running
|
|
120
|
-
const
|
|
119
|
+
const runningJobs = jobExecutor.runningJobCount();
|
|
120
|
+
const allowedJobs = Math.max(0, opt.maxConcurrentJobs - maxReturnCount - runningJobs);
|
|
121
121
|
// Latency
|
|
122
122
|
const maxLatency = 100;
|
|
123
123
|
const latency = systemMonitor.getLatency() || 10;
|
|
@@ -137,12 +137,14 @@ async function processMessages(queues, callback, options) {
|
|
|
137
137
|
const targetJobs = Math.round(allowedJobs * overallFactor);
|
|
138
138
|
let jobsLeft = targetJobs;
|
|
139
139
|
if (opt.verbose) {
|
|
140
|
-
|
|
140
|
+
console.error({ maxConcurrentJobs: opt.maxConcurrentJobs, maxReturnCount, runningJobs, allowedJobs, maxLatency, latencyFactor, freememFactor, loadFactor, overallFactor, targetJobs, activeQrls });
|
|
141
141
|
}
|
|
142
142
|
for (const { qname, qrl } of queueManager.getPairs()) {
|
|
143
143
|
// const qcount = jobExecutor.runningJobCountForQueue(qname)
|
|
144
144
|
// console.log({ evaluating: { qname, qrl, qcount, jobsLeft, activeQrlsHasQrl: activeQrls.has(qrl) } })
|
|
145
|
-
if (jobsLeft <= 0
|
|
145
|
+
if (jobsLeft <= 0)
|
|
146
|
+
break;
|
|
147
|
+
if (activeQrls.has(qrl))
|
|
146
148
|
continue;
|
|
147
149
|
const maxMessages = Math.min(10, jobsLeft);
|
|
148
150
|
listen(qname, qrl, maxMessages);
|
|
@@ -40,10 +40,8 @@ class JobExecutor {
|
|
|
40
40
|
if (this.opt.verbose) {
|
|
41
41
|
console.error(chalk_1.default.blue('Shutting down jobExecutor'));
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
await this.maintainVisibility();
|
|
46
|
-
}
|
|
43
|
+
await this.maintainPromise;
|
|
44
|
+
await this.maintainVisibility();
|
|
47
45
|
}
|
|
48
46
|
activeJobCount() {
|
|
49
47
|
return this.stats.activeJobs;
|
|
@@ -122,19 +120,18 @@ class JobExecutor {
|
|
|
122
120
|
console.error(chalk_1.default.blue('Jobs: '));
|
|
123
121
|
for (const [qname, jobs] of this.jobsByQueue.entries()) {
|
|
124
122
|
if (jobs.size) {
|
|
125
|
-
|
|
126
|
-
for (const job of jobs)
|
|
127
|
-
if (job.status === 'running')
|
|
128
|
-
console.error(chalk_1.default.green(' running: '), job.payload);
|
|
123
|
+
const stats = {};
|
|
129
124
|
for (const job of jobs)
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
125
|
+
stats[job.status] = (stats[job.status] || 0) + 1;
|
|
126
|
+
console.error(chalk_1.default.blue(' queue:'), qname);
|
|
127
|
+
if (stats.running)
|
|
128
|
+
console.error(chalk_1.default.green(' running: '), stats.running);
|
|
129
|
+
if (stats.waiting)
|
|
130
|
+
console.error(chalk_1.default.yellow(' waiting: '), stats.waiting);
|
|
131
|
+
if (stats.deleting)
|
|
132
|
+
console.error(chalk_1.default.blue(' complete: '), stats.deleting);
|
|
133
|
+
if (stats.failed)
|
|
134
|
+
console.error(chalk_1.default.red(' failed: '), stats.failed);
|
|
138
135
|
}
|
|
139
136
|
}
|
|
140
137
|
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qdone",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.34-alpha",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "qdone",
|
|
9
|
-
"version": "2.0.
|
|
9
|
+
"version": "2.0.34-alpha",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cloudwatch": "3.465.0",
|
package/package.json
CHANGED
package/src/consumer.js
CHANGED
|
@@ -61,7 +61,7 @@ export async function processMessages (queues, callback, options) {
|
|
|
61
61
|
lastLatency = latency
|
|
62
62
|
})
|
|
63
63
|
const jobExecutor = new JobExecutor(opt)
|
|
64
|
-
const queueManager = new QueueManager(opt, queues,
|
|
64
|
+
const queueManager = new QueueManager(opt, queues, 10)
|
|
65
65
|
const cores = cpus().length
|
|
66
66
|
// debug({ systemMonitor, jobExecutor, queueManager })
|
|
67
67
|
|
|
@@ -105,7 +105,7 @@ export async function processMessages (queues, callback, options) {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
// Max job accounting
|
|
108
|
-
|
|
108
|
+
maxReturnCount -= maxMessages
|
|
109
109
|
activeQrls.delete(qrl)
|
|
110
110
|
} catch (e) {
|
|
111
111
|
// If the queue has been cleaned up, we should back off anyway
|
|
@@ -119,7 +119,8 @@ export async function processMessages (queues, callback, options) {
|
|
|
119
119
|
|
|
120
120
|
while (!shutdownRequested) { // eslint-disable-line
|
|
121
121
|
// Figure out how we are running
|
|
122
|
-
const
|
|
122
|
+
const runningJobs = jobExecutor.runningJobCount()
|
|
123
|
+
const allowedJobs = Math.max(0, opt.maxConcurrentJobs - maxReturnCount - runningJobs)
|
|
123
124
|
|
|
124
125
|
// Latency
|
|
125
126
|
const maxLatency = 100
|
|
@@ -144,12 +145,13 @@ export async function processMessages (queues, callback, options) {
|
|
|
144
145
|
let jobsLeft = targetJobs
|
|
145
146
|
|
|
146
147
|
if (opt.verbose) {
|
|
147
|
-
|
|
148
|
+
console.error({ maxConcurrentJobs: opt.maxConcurrentJobs, maxReturnCount, runningJobs, allowedJobs, maxLatency, latencyFactor, freememFactor, loadFactor, overallFactor, targetJobs, activeQrls })
|
|
148
149
|
}
|
|
149
150
|
for (const { qname, qrl } of queueManager.getPairs()) {
|
|
150
151
|
// const qcount = jobExecutor.runningJobCountForQueue(qname)
|
|
151
152
|
// console.log({ evaluating: { qname, qrl, qcount, jobsLeft, activeQrlsHasQrl: activeQrls.has(qrl) } })
|
|
152
|
-
if (jobsLeft <= 0
|
|
153
|
+
if (jobsLeft <= 0) break
|
|
154
|
+
if (activeQrls.has(qrl)) continue
|
|
153
155
|
const maxMessages = Math.min(10, jobsLeft)
|
|
154
156
|
listen(qname, qrl, maxMessages)
|
|
155
157
|
jobsLeft -= maxMessages
|
|
@@ -41,10 +41,8 @@ export class JobExecutor {
|
|
|
41
41
|
if (this.opt.verbose) {
|
|
42
42
|
console.error(chalk.blue('Shutting down jobExecutor'))
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
await this.maintainVisibility()
|
|
47
|
-
}
|
|
44
|
+
await this.maintainPromise
|
|
45
|
+
await this.maintainVisibility()
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
activeJobCount () {
|
|
@@ -129,11 +127,13 @@ export class JobExecutor {
|
|
|
129
127
|
console.error(chalk.blue('Jobs: '))
|
|
130
128
|
for (const [qname, jobs] of this.jobsByQueue.entries()) {
|
|
131
129
|
if (jobs.size) {
|
|
130
|
+
const stats = {}
|
|
131
|
+
for (const job of jobs) stats[job.status] = (stats[job.status] || 0) + 1
|
|
132
132
|
console.error(chalk.blue(' queue:'), qname)
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
133
|
+
if (stats.running) console.error(chalk.green(' running: '), stats.running)
|
|
134
|
+
if (stats.waiting) console.error(chalk.yellow(' waiting: '), stats.waiting)
|
|
135
|
+
if (stats.deleting) console.error(chalk.blue(' complete: '), stats.deleting)
|
|
136
|
+
if (stats.failed) console.error(chalk.red(' failed: '), stats.failed)
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
}
|