aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2021-03-02 21:11:54 +0300
committerEvgeny Zinoviev <me@ch1p.io>2021-03-02 21:11:54 +0300
commit6d8d95ae3f99a471d22dfc1535917002794a9fa8 (patch)
tree3f565d195979df0e22f93dbd6a2ad38dbcbbee6e
parent2a62f0fc03d6fad6292e37a2f83c1923a514cd2a (diff)
remove obsolete code
-rw-r--r--src/lib/worker.js21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/lib/worker.js b/src/lib/worker.js
index 3713202..a271a31 100644
--- a/src/lib/worker.js
+++ b/src/lib/worker.js
@@ -26,7 +26,7 @@ class Worker extends EventEmitter {
super()
/**
- * @type {object.<string, {slots: object.<string, {limit: number, queue: Queue}>}>}
+ * @type {object.<string, {slots: object.<string, Queue>}>}
*/
this.targets = {}
@@ -70,7 +70,7 @@ class Worker extends EventEmitter {
queue.on('error', this.onJobFinished.bind(this, target, slot))
queue.start()
- this.targets[target].slots[slot] = {limit, queue}
+ this.targets[target].slots[slot] = queue
}
/**
@@ -94,10 +94,9 @@ class Worker extends EventEmitter {
let target = this.targets[targetName]
status.targets[targetName] = {}
for (const slotName in target.slots) {
- const {queue, limit} = target.slots[slotName]
+ const queue = target.slots[slotName]
status.targets[targetName][slotName] = {
concurrency: queue.concurrency,
- limit,
length: queue.length,
}
}
@@ -363,7 +362,7 @@ class Worker extends EventEmitter {
* @param {string} slot
*/
enqueueJob(id, target, slot) {
- const queue = this.targets[target].slots[slot].queue
+ const queue = this.targets[target].slots[slot]
queue.push(async (cb) => {
let data = {
code: null,
@@ -511,9 +510,9 @@ class Worker extends EventEmitter {
continue
for (const slot in this.targets[target].slots) {
- const {limit, queue} = this.targets[target].slots[slot]
- this.logger.debug(LOGPREFIX, limit, queue.length)
- if (queue.length < limit)
+ const queue = this.targets[target].slots[slot]
+ this.logger.debug(LOGPREFIX, queue.concurrency, queue.length)
+ if (queue.length < queue.concurrency)
return true
}
}
@@ -528,9 +527,9 @@ class Worker extends EventEmitter {
onJobFinished = (target, slot) => {
this.logger.debug(`onJobFinished: target=${target}, slot=${slot}`)
- const {queue, limit} = this.targets[target].slots[slot]
- if (queue.length < limit && this.hasPollTarget(target)) {
- this.logger.debug(`onJobFinished: ${queue.length} < ${limit}, calling poll(${target})`)
+ const queue = this.targets[target].slots[slot]
+ if (queue.length < queue.concurrency && this.hasPollTarget(target)) {
+ this.logger.debug(`onJobFinished: ${queue.length} < ${queue.concurrency}, calling poll(${target})`)
this.poll()
}
}