qdone 2.0.33-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
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);
|
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
|