qdone 2.0.14-alpha → 2.0.15-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.
@@ -134,7 +134,7 @@ function processMessages(queues, callback, options) {
134
134
  lastLatency = latency;
135
135
  });
136
136
  jobExecutor = new jobExecutor_js_1.JobExecutor(opt);
137
- queueManager = new queueManager_js_1.QueueManager(opt, queues);
137
+ queueManager = new queueManager_js_1.QueueManager(opt, queues, 60);
138
138
  delay = function (ms) { return new Promise(function (resolve) {
139
139
  delayTimeout = setTimeout(resolve, ms);
140
140
  }); };
@@ -206,15 +206,17 @@ function processMessages(queues, callback, options) {
206
206
  _c.label = 1;
207
207
  case 1:
208
208
  if (!!shutdownRequested) return [3 /*break*/, 3];
209
- allowedJobs = opt.maxConcurrentJobs - jobExecutor.activeJobCount() - maxReturnCount;
209
+ allowedJobs = Math.max(0, opt.maxConcurrentJobs - jobExecutor.activeJobCount() - maxReturnCount);
210
210
  maxLatency = 100;
211
- latency = systemMonitor.getLatency().setTimeout;
211
+ latency = systemMonitor.getLatency() || 10;
212
212
  latencyFactor = 1 - Math.abs(Math.min(latency / maxLatency, 1)) // 0 if latency is at max, 1 if latency 0
213
213
  ;
214
214
  targetJobs = Math.round(allowedJobs * latencyFactor);
215
215
  jobsLeft = targetJobs;
216
+ debug({ jobCount: jobExecutor.activeJobCount(), maxReturnCount: maxReturnCount, allowedJobs: allowedJobs, maxLatency: maxLatency, latency: latency, latencyFactor: latencyFactor, targetJobs: targetJobs, activeQrls: activeQrls });
216
217
  for (_i = 0, _a = queueManager.getPairs(); _i < _a.length; _i++) {
217
218
  _b = _a[_i], qname = _b.qname, qrl = _b.qrl;
219
+ debug({ evaluating: { qname: qname, qrl: qrl, jobsLeft: jobsLeft, activeQrlsHasQrl: activeQrls.has(qrl) } });
218
220
  if (jobsLeft <= 0 || activeQrls.has(qrl))
219
221
  continue;
220
222
  maxMessages = Math.min(10, jobsLeft);
@@ -223,7 +225,7 @@ function processMessages(queues, callback, options) {
223
225
  if (opt.verbose) {
224
226
  console.error(chalk_1.default.blue('Listening on: '), qname);
225
227
  }
226
- // debug({ listenedTo: { qname, maxMessages, jobsLeft } })
228
+ debug({ listenedTo: { qname: qname, maxMessages: maxMessages, jobsLeft: jobsLeft } });
227
229
  }
228
230
  return [4 /*yield*/, delay(1000)];
229
231
  case 2:
@@ -204,7 +204,12 @@ var QueueManager = /** @class */ (function () {
204
204
  return pair;
205
205
  };
206
206
  QueueManager.prototype.getPairs = function () {
207
- return this.selectedPairs;
207
+ var _this = this;
208
+ var now = new Date();
209
+ return this.selectedPairs.filter(function (_a) {
210
+ var qname = _a.qname, qrl = _a.qrl;
211
+ return !_this.keepInIcehouse(qrl, now);
212
+ });
208
213
  };
209
214
  QueueManager.prototype.shutdown = function () {
210
215
  return __awaiter(this, void 0, void 0, function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qdone",
3
- "version": "2.0.14-alpha",
3
+ "version": "2.0.15-alpha",
4
4
  "description": "Language agnostic job queue for SQS",
5
5
  "type": "module",
6
6
  "main": "./index.js",
package/src/consumer.js CHANGED
@@ -60,7 +60,7 @@ export async function processMessages (queues, callback, options) {
60
60
  lastLatency = latency
61
61
  })
62
62
  const jobExecutor = new JobExecutor(opt)
63
- const queueManager = new QueueManager(opt, queues)
63
+ const queueManager = new QueueManager(opt, queues, 60)
64
64
  // debug({ systemMonitor, jobExecutor, queueManager })
65
65
 
66
66
  // This delay function keeps a timeout reference around so it can be
@@ -113,15 +113,15 @@ export async function processMessages (queues, callback, options) {
113
113
 
114
114
  while (!shutdownRequested) { // eslint-disable-line
115
115
  // Figure out how we are running
116
- const allowedJobs = opt.maxConcurrentJobs - jobExecutor.activeJobCount() - maxReturnCount
116
+ const allowedJobs = Math.max(0, opt.maxConcurrentJobs - jobExecutor.activeJobCount() - maxReturnCount)
117
117
  const maxLatency = 100
118
- const latency = systemMonitor.getLatency().setTimeout
118
+ const latency = systemMonitor.getLatency() || 10
119
119
  const latencyFactor = 1 - Math.abs(Math.min(latency / maxLatency, 1)) // 0 if latency is at max, 1 if latency 0
120
120
  const targetJobs = Math.round(allowedJobs * latencyFactor)
121
- // debug({ allowedJobs, maxLatency, latency, latencyFactor, targetJobs, activeQrls })
122
-
123
121
  let jobsLeft = targetJobs
122
+ debug({ jobCount: jobExecutor.activeJobCount(), maxReturnCount, allowedJobs, maxLatency, latency, latencyFactor, targetJobs, activeQrls })
124
123
  for (const { qname, qrl } of queueManager.getPairs()) {
124
+ debug({ evaluating: { qname, qrl, jobsLeft, activeQrlsHasQrl: activeQrls.has(qrl) } })
125
125
  if (jobsLeft <= 0 || activeQrls.has(qrl)) continue
126
126
  const maxMessages = Math.min(10, jobsLeft)
127
127
  listen(qname, qrl, maxMessages)
@@ -129,7 +129,7 @@ export async function processMessages (queues, callback, options) {
129
129
  if (opt.verbose) {
130
130
  console.error(chalk.blue('Listening on: '), qname)
131
131
  }
132
- // debug({ listenedTo: { qname, maxMessages, jobsLeft } })
132
+ debug({ listenedTo: { qname, maxMessages, jobsLeft } })
133
133
  }
134
134
  await delay(1000)
135
135
  }
@@ -140,7 +140,8 @@ export class QueueManager {
140
140
  }
141
141
 
142
142
  getPairs () {
143
- return this.selectedPairs
143
+ const now = new Date()
144
+ return this.selectedPairs.filter(({ qname, qrl }) => !this.keepInIcehouse(qrl, now))
144
145
  }
145
146
 
146
147
  async shutdown () {