repositories
/
poolifier.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
5efc2a9
)
Change killBehaviorEnumeration to killBehaviorTypes
author
aardizio
<alessandroardizio94@gmail.com>
Tue, 16 Feb 2021 13:05:48 +0000
(14:05 +0100)
committer
aardizio
<alessandroardizio94@gmail.com>
Tue, 16 Feb 2021 13:05:48 +0000
(14:05 +0100)
18 files changed:
src/index.ts
patch
|
blob
|
blame
|
history
src/pools/cluster/dynamic.ts
patch
|
blob
|
blame
|
history
src/pools/thread/dynamic.ts
patch
|
blob
|
blame
|
history
src/worker/abstract-worker.ts
patch
|
blob
|
blame
|
history
src/worker/worker-options.ts
patch
|
blob
|
blame
|
history
tests/worker/cluster/asyncErrorWorker.js
patch
|
blob
|
blame
|
history
tests/worker/cluster/asyncWorker.js
patch
|
blob
|
blame
|
history
tests/worker/cluster/echoWorker.js
patch
|
blob
|
blame
|
history
tests/worker/cluster/emptyWorker.js
patch
|
blob
|
blame
|
history
tests/worker/cluster/errorWorker.js
patch
|
blob
|
blame
|
history
tests/worker/cluster/longRunningWorkerHardBehavior.js
patch
|
blob
|
blame
|
history
tests/worker/cluster/testWorker.js
patch
|
blob
|
blame
|
history
tests/worker/thread/asyncWorker.js
patch
|
blob
|
blame
|
history
tests/worker/thread/echoWorker.js
patch
|
blob
|
blame
|
history
tests/worker/thread/emptyWorker.js
patch
|
blob
|
blame
|
history
tests/worker/thread/errorWorker.js
patch
|
blob
|
blame
|
history
tests/worker/thread/longRunningWorkerHardBehavior.js
patch
|
blob
|
blame
|
history
tests/worker/thread/testWorker.js
patch
|
blob
|
blame
|
history
diff --git
a/src/index.ts
b/src/index.ts
index 60536f99603b114c94df518f121bf30c1395f005..b64a274b87c662d65249ca52ac82250c2bad3dd0 100644
(file)
--- a/
src/index.ts
+++ b/
src/index.ts
@@
-16,4
+16,4
@@
export { AbstractWorker } from './worker/abstract-worker'
export { ClusterWorker } from './worker/cluster-worker'
export { ThreadWorker } from './worker/thread-worker'
export type { WorkerOptions } from './worker/worker-options'
export { ClusterWorker } from './worker/cluster-worker'
export { ThreadWorker } from './worker/thread-worker'
export type { WorkerOptions } from './worker/worker-options'
-export { killBehavior
Enumeration
} from './worker/worker-options'
+export { killBehavior
Types
} from './worker/worker-options'
diff --git
a/src/pools/cluster/dynamic.ts
b/src/pools/cluster/dynamic.ts
index 58e2b7124d749717ff90df9ad14a387f988a8c53..eb93c0c8c6d5ac00908e4311f13b1b4392bc4d64 100644
(file)
--- a/
src/pools/cluster/dynamic.ts
+++ b/
src/pools/cluster/dynamic.ts
@@
-2,7
+2,7
@@
import type { Worker } from 'cluster'
import type { JSONValue } from '../../utility-types'
import type { ClusterPoolOptions } from './fixed'
import { FixedClusterPool } from './fixed'
import type { JSONValue } from '../../utility-types'
import type { ClusterPoolOptions } from './fixed'
import { FixedClusterPool } from './fixed'
-import { killBehavior
Enumeration
} from '../../worker/worker-options'
+import { killBehavior
Types
} from '../../worker/worker-options'
/**
* A cluster pool with a dynamic number of workers, but a guaranteed minimum number of workers.
/**
* A cluster pool with a dynamic number of workers, but a guaranteed minimum number of workers.
@@
-64,7
+64,7
@@
export class DynamicClusterPool<
this.registerWorkerMessageListener<Data>(worker, message => {
const tasksInProgress = this.tasks.get(worker)
const isKillBehaviorOptionHard =
this.registerWorkerMessageListener<Data>(worker, message => {
const tasksInProgress = this.tasks.get(worker)
const isKillBehaviorOptionHard =
- message.kill === killBehavior
Enumeration
.HARD
+ message.kill === killBehavior
Types
.HARD
if (isKillBehaviorOptionHard || tasksInProgress === 0) {
// Kill received from the worker, means that no new tasks are submitted to that worker for a while ( > maxInactiveTime)
this.sendToWorker(worker, { kill: 1 })
if (isKillBehaviorOptionHard || tasksInProgress === 0) {
// Kill received from the worker, means that no new tasks are submitted to that worker for a while ( > maxInactiveTime)
this.sendToWorker(worker, { kill: 1 })
diff --git
a/src/pools/thread/dynamic.ts
b/src/pools/thread/dynamic.ts
index 7a0d4ffd8c0513bac3a4ffaf983182f109d23b3d..f068b4a2951d5ad126ba29324958f865fa247a7e 100644
(file)
--- a/
src/pools/thread/dynamic.ts
+++ b/
src/pools/thread/dynamic.ts
@@
-2,7
+2,7
@@
import type { JSONValue } from '../../utility-types'
import type { PoolOptions } from '../abstract-pool'
import type { ThreadWorkerWithMessageChannel } from './fixed'
import { FixedThreadPool } from './fixed'
import type { PoolOptions } from '../abstract-pool'
import type { ThreadWorkerWithMessageChannel } from './fixed'
import { FixedThreadPool } from './fixed'
-import { killBehavior
Enumeration
} from '../../worker/worker-options'
+import { killBehavior
Types
} from '../../worker/worker-options'
/**
* A thread pool with a dynamic number of threads, but a guaranteed minimum number of threads.
/**
* A thread pool with a dynamic number of threads, but a guaranteed minimum number of threads.
@@
-64,7
+64,7
@@
export class DynamicThreadPool<
this.registerWorkerMessageListener<Data>(worker, message => {
const tasksInProgress = this.tasks.get(worker)
const isKillBehaviorOptionHard =
this.registerWorkerMessageListener<Data>(worker, message => {
const tasksInProgress = this.tasks.get(worker)
const isKillBehaviorOptionHard =
- message.kill === killBehavior
Enumeration
.HARD
+ message.kill === killBehavior
Types
.HARD
if (isKillBehaviorOptionHard || tasksInProgress === 0) {
// Kill received from the worker, means that no new tasks are submitted to that worker for a while ( > maxInactiveTime)
this.sendToWorker(worker, { kill: 1 })
if (isKillBehaviorOptionHard || tasksInProgress === 0) {
// Kill received from the worker, means that no new tasks are submitted to that worker for a while ( > maxInactiveTime)
this.sendToWorker(worker, { kill: 1 })
diff --git
a/src/worker/abstract-worker.ts
b/src/worker/abstract-worker.ts
index cb33188e5778a3c9a31cc30f6ae93cb46b33567c..b65ed5901c3fe8d76b5868cb4e78273af9ee209d 100644
(file)
--- a/
src/worker/abstract-worker.ts
+++ b/
src/worker/abstract-worker.ts
@@
-3,7
+3,7
@@
import type { Worker } from 'cluster'
import type { MessagePort } from 'worker_threads'
import type { MessageValue, KillBehavior } from '../utility-types'
import type { WorkerOptions } from './worker-options'
import type { MessagePort } from 'worker_threads'
import type { MessageValue, KillBehavior } from '../utility-types'
import type { WorkerOptions } from './worker-options'
-// import { killBehavior
Enumeration
} from './worker-options'
+// import { killBehavior
Types
} from './worker-options'
const defaultMaxInactiveTime = 1000 * 60
// TODO fix this and avoid that SOFT/HARD words are replicated so much times into the project
const defaultMaxInactiveTime = 1000 * 60
// TODO fix this and avoid that SOFT/HARD words are replicated so much times into the project
diff --git
a/src/worker/worker-options.ts
b/src/worker/worker-options.ts
index b1d13d0cd37fd4471a3d882ed98e191a9e626a76..bdad1a8d68ad59b67a202e20a00603a4f6192719 100644
(file)
--- a/
src/worker/worker-options.ts
+++ b/
src/worker/worker-options.ts
@@
-3,7
+3,7
@@
import type { KillBehavior } from '../utility-types'
/**
* Kill behavior enumeration
*/
/**
* Kill behavior enumeration
*/
-export const killBehavior
Enumeration
= Object.freeze({
+export const killBehavior
Types
= Object.freeze({
SOFT: 'SOFT',
HARD: 'HARD'
})
SOFT: 'SOFT',
HARD: 'HARD'
})
diff --git
a/tests/worker/cluster/asyncErrorWorker.js
b/tests/worker/cluster/asyncErrorWorker.js
index be675e110e96bb8d6bc6ae5c232b3f8a3e6de132..f3e0e7c8eb49c77007eafe0c7a68877f4e22df56 100644
(file)
--- a/
tests/worker/cluster/asyncErrorWorker.js
+++ b/
tests/worker/cluster/asyncErrorWorker.js
@@
-1,5
+1,5
@@
'use strict'
'use strict'
-const { ClusterWorker, killBehavior
Enumeration
} = require('../../../lib/index')
+const { ClusterWorker, killBehavior
Types
} = require('../../../lib/index')
async function error (data) {
return new Promise((resolve, reject) => {
async function error (data) {
return new Promise((resolve, reject) => {
@@
-13,5
+13,5
@@
async function error (data) {
module.exports = new ClusterWorker(error, {
maxInactiveTime: 500,
async: true,
module.exports = new ClusterWorker(error, {
maxInactiveTime: 500,
async: true,
- killBehavior: killBehavior
Enumeration
+ killBehavior: killBehavior
Types
})
})
diff --git
a/tests/worker/cluster/asyncWorker.js
b/tests/worker/cluster/asyncWorker.js
index b47adc916affe53ad7e12a7fe447aac1c7f85a4e..106df109d4daffc4f12c50c92e7079436d38df2a 100644
(file)
--- a/
tests/worker/cluster/asyncWorker.js
+++ b/
tests/worker/cluster/asyncWorker.js
@@
-1,5
+1,5
@@
'use strict'
'use strict'
-const { ClusterWorker, killBehavior
Enumeration
} = require('../../../lib/index')
+const { ClusterWorker, killBehavior
Types
} = require('../../../lib/index')
async function sleep (data) {
return new Promise((resolve, reject) => {
async function sleep (data) {
return new Promise((resolve, reject) => {
@@
-10,5
+10,5
@@
async function sleep (data) {
module.exports = new ClusterWorker(sleep, {
maxInactiveTime: 500,
async: true,
module.exports = new ClusterWorker(sleep, {
maxInactiveTime: 500,
async: true,
- killBehavior: killBehavior
Enumeration
.HARD
+ killBehavior: killBehavior
Types
.HARD
})
})
diff --git
a/tests/worker/cluster/echoWorker.js
b/tests/worker/cluster/echoWorker.js
index 8d4477ee386983aa6680d4b73a4c619b5fdeb9bc..77898bacbafb70caf8cd3deb48758a49d8d2100d 100644
(file)
--- a/
tests/worker/cluster/echoWorker.js
+++ b/
tests/worker/cluster/echoWorker.js
@@
-1,5
+1,5
@@
'use strict'
'use strict'
-const { ClusterWorker, killBehavior
Enumeration
} = require('../../../lib/index')
+const { ClusterWorker, killBehavior
Types
} = require('../../../lib/index')
function echo (data) {
return data
function echo (data) {
return data
@@
-7,5
+7,5
@@
function echo (data) {
module.exports = new ClusterWorker(echo, {
maxInactiveTime: 500,
module.exports = new ClusterWorker(echo, {
maxInactiveTime: 500,
- killBehavior: killBehavior
Enumeration
.HARD
+ killBehavior: killBehavior
Types
.HARD
})
})
diff --git
a/tests/worker/cluster/emptyWorker.js
b/tests/worker/cluster/emptyWorker.js
index 4e5eeca7a7a33f8a67b90447de69a05d574dda83..979057c261c7837ace12ef5c43b0aa3d4f4443d9 100644
(file)
--- a/
tests/worker/cluster/emptyWorker.js
+++ b/
tests/worker/cluster/emptyWorker.js
@@
-1,9
+1,9
@@
'use strict'
'use strict'
-const { ClusterWorker, killBehavior
Enumeration
} = require('../../../lib/index')
+const { ClusterWorker, killBehavior
Types
} = require('../../../lib/index')
function test (data) {}
module.exports = new ClusterWorker(test, {
maxInactiveTime: 500,
function test (data) {}
module.exports = new ClusterWorker(test, {
maxInactiveTime: 500,
- killBehavior: killBehavior
Enumeration
.HARD
+ killBehavior: killBehavior
Types
.HARD
})
})
diff --git
a/tests/worker/cluster/errorWorker.js
b/tests/worker/cluster/errorWorker.js
index bbcb78be74f5cf5fad08a097545303017013e737..02168a677b3367fbb5980cc3b9a6bf39b18da986 100644
(file)
--- a/
tests/worker/cluster/errorWorker.js
+++ b/
tests/worker/cluster/errorWorker.js
@@
-1,5
+1,5
@@
'use strict'
'use strict'
-const { ClusterWorker, killBehavior
Enumeration
} = require('../../../lib/index')
+const { ClusterWorker, killBehavior
Types
} = require('../../../lib/index')
function error (data) {
throw new Error('Error Message from ClusterWorker')
function error (data) {
throw new Error('Error Message from ClusterWorker')
@@
-8,5
+8,5
@@
function error (data) {
module.exports = new ClusterWorker(error, {
maxInactiveTime: 500,
async: false,
module.exports = new ClusterWorker(error, {
maxInactiveTime: 500,
async: false,
- killBehavior: killBehavior
Enumeration
+ killBehavior: killBehavior
Types
})
})
diff --git
a/tests/worker/cluster/longRunningWorkerHardBehavior.js
b/tests/worker/cluster/longRunningWorkerHardBehavior.js
index 9fe9d3f8e7152bb1525a38755e2294151a3e133d..4dc69525fac2746feea5891e477126d49e3f200a 100644
(file)
--- a/
tests/worker/cluster/longRunningWorkerHardBehavior.js
+++ b/
tests/worker/cluster/longRunningWorkerHardBehavior.js
@@
-1,5
+1,5
@@
'use strict'
'use strict'
-const { ClusterWorker, killBehavior
Enumeration
} = require('../../../lib/index')
+const { ClusterWorker, killBehavior
Types
} = require('../../../lib/index')
async function sleep (data) {
return new Promise((resolve, reject) => {
async function sleep (data) {
return new Promise((resolve, reject) => {
@@
-10,5
+10,5
@@
async function sleep (data) {
module.exports = new ClusterWorker(sleep, {
maxInactiveTime: 500,
async: true,
module.exports = new ClusterWorker(sleep, {
maxInactiveTime: 500,
async: true,
- killBehavior: killBehavior
Enumeration
.HARD
+ killBehavior: killBehavior
Types
.HARD
})
})
diff --git
a/tests/worker/cluster/testWorker.js
b/tests/worker/cluster/testWorker.js
index 3e1ed0d193f65ff029f1c2c954825993ba0330be..9b95294bbbb92a90bb923c864046b8d4bc7b40d1 100644
(file)
--- a/
tests/worker/cluster/testWorker.js
+++ b/
tests/worker/cluster/testWorker.js
@@
-1,5
+1,5
@@
'use strict'
'use strict'
-const { ClusterWorker, killBehavior
Enumeration
} = require('../../../lib/index')
+const { ClusterWorker, killBehavior
Types
} = require('../../../lib/index')
const { isMaster } = require('cluster')
function test (data) {
const { isMaster } = require('cluster')
function test (data) {
@@
-14,5
+14,5
@@
function test (data) {
module.exports = new ClusterWorker(test, {
maxInactiveTime: 500,
module.exports = new ClusterWorker(test, {
maxInactiveTime: 500,
- killBehavior: killBehavior
Enumeration
.HARD
+ killBehavior: killBehavior
Types
.HARD
})
})
diff --git
a/tests/worker/thread/asyncWorker.js
b/tests/worker/thread/asyncWorker.js
index 59a900e914404f89b1cedd28ed75330283e2d723..a6a9590d44334b5d99348bccd47cb5f7a78a39d2 100644
(file)
--- a/
tests/worker/thread/asyncWorker.js
+++ b/
tests/worker/thread/asyncWorker.js
@@
-1,5
+1,5
@@
'use strict'
'use strict'
-const { ThreadWorker, killBehavior
Enumeration
} = require('../../../lib/index')
+const { ThreadWorker, killBehavior
Types
} = require('../../../lib/index')
async function sleep (data) {
return new Promise((resolve, reject) => {
async function sleep (data) {
return new Promise((resolve, reject) => {
@@
-10,5
+10,5
@@
async function sleep (data) {
module.exports = new ThreadWorker(sleep, {
maxInactiveTime: 500,
async: true,
module.exports = new ThreadWorker(sleep, {
maxInactiveTime: 500,
async: true,
- killBehavior: killBehavior
Enumeration
.HARD
+ killBehavior: killBehavior
Types
.HARD
})
})
diff --git
a/tests/worker/thread/echoWorker.js
b/tests/worker/thread/echoWorker.js
index 3b554ccc4588dc0b2675149bfb46a706a5222767..9471891ea0fd30a0d0740492ef6609ee3145e55c 100644
(file)
--- a/
tests/worker/thread/echoWorker.js
+++ b/
tests/worker/thread/echoWorker.js
@@
-1,5
+1,5
@@
'use strict'
'use strict'
-const { ThreadWorker, killBehavior
Enumeration
} = require('../../../lib/index')
+const { ThreadWorker, killBehavior
Types
} = require('../../../lib/index')
function echo (data) {
return data
function echo (data) {
return data
@@
-7,5
+7,5
@@
function echo (data) {
module.exports = new ThreadWorker(echo, {
maxInactiveTime: 500,
module.exports = new ThreadWorker(echo, {
maxInactiveTime: 500,
- killBehavior: killBehavior
Enumeration
.HARD
+ killBehavior: killBehavior
Types
.HARD
})
})
diff --git
a/tests/worker/thread/emptyWorker.js
b/tests/worker/thread/emptyWorker.js
index c7034caaa3b66f901f9ee26f7b9fd664b4f957c0..1787a79c16c7923f01745bd086bac6329ee78423 100644
(file)
--- a/
tests/worker/thread/emptyWorker.js
+++ b/
tests/worker/thread/emptyWorker.js
@@
-1,9
+1,9
@@
'use strict'
'use strict'
-const { ThreadWorker, killBehavior
Enumeration
} = require('../../../lib/index')
+const { ThreadWorker, killBehavior
Types
} = require('../../../lib/index')
function test (data) {}
module.exports = new ThreadWorker(test, {
maxInactiveTime: 500,
function test (data) {}
module.exports = new ThreadWorker(test, {
maxInactiveTime: 500,
- killBehavior: killBehavior
Enumeration
.HARD
+ killBehavior: killBehavior
Types
.HARD
})
})
diff --git
a/tests/worker/thread/errorWorker.js
b/tests/worker/thread/errorWorker.js
index 6b7ee3c9e6dccdfcbcf063097e005ce8c531907e..7f7fdadd6ff4fe612588d2b6fc7ecd1e27fc74db 100644
(file)
--- a/
tests/worker/thread/errorWorker.js
+++ b/
tests/worker/thread/errorWorker.js
@@
-1,5
+1,5
@@
'use strict'
'use strict'
-const { ThreadWorker, killBehavior
Enumeration
} = require('../../../lib/index')
+const { ThreadWorker, killBehavior
Types
} = require('../../../lib/index')
function error (data) {
throw new Error(data)
function error (data) {
throw new Error(data)
@@
-7,5
+7,5
@@
function error (data) {
module.exports = new ThreadWorker(error, {
maxInactiveTime: 500,
module.exports = new ThreadWorker(error, {
maxInactiveTime: 500,
- killBehavior: killBehavior
Enumeration
.HARD
+ killBehavior: killBehavior
Types
.HARD
})
})
diff --git
a/tests/worker/thread/longRunningWorkerHardBehavior.js
b/tests/worker/thread/longRunningWorkerHardBehavior.js
index ec74579482d78b9aed762dffba288840d732108d..8e3eb38a82a8863d00a2f184fac969baf8660f8b 100644
(file)
--- a/
tests/worker/thread/longRunningWorkerHardBehavior.js
+++ b/
tests/worker/thread/longRunningWorkerHardBehavior.js
@@
-1,5
+1,5
@@
'use strict'
'use strict'
-const { ThreadWorker, killBehavior
Enumeration
} = require('../../../lib/index')
+const { ThreadWorker, killBehavior
Types
} = require('../../../lib/index')
async function sleep (data) {
return new Promise((resolve, reject) => {
async function sleep (data) {
return new Promise((resolve, reject) => {
@@
-10,5
+10,5
@@
async function sleep (data) {
module.exports = new ThreadWorker(sleep, {
maxInactiveTime: 500,
async: true,
module.exports = new ThreadWorker(sleep, {
maxInactiveTime: 500,
async: true,
- killBehavior: killBehavior
Enumeration
.HARD
+ killBehavior: killBehavior
Types
.HARD
})
})
diff --git
a/tests/worker/thread/testWorker.js
b/tests/worker/thread/testWorker.js
index 77dfdc8e050ccfca7a9a67f874b602e088c5234d..7510f00bf51086c7078f1bdeed385bd13a5707d8 100644
(file)
--- a/
tests/worker/thread/testWorker.js
+++ b/
tests/worker/thread/testWorker.js
@@
-1,5
+1,5
@@
'use strict'
'use strict'
-const { ThreadWorker, killBehavior
Enumeration
} = require('../../../lib/index')
+const { ThreadWorker, killBehavior
Types
} = require('../../../lib/index')
const { isMainThread } = require('worker_threads')
function test (data) {
const { isMainThread } = require('worker_threads')
function test (data) {
@@
-14,5
+14,5
@@
function test (data) {
module.exports = new ThreadWorker(test, {
maxInactiveTime: 500,
module.exports = new ThreadWorker(test, {
maxInactiveTime: 500,
- killBehavior: killBehavior
Enumeration
.HARD
+ killBehavior: killBehavior
Types
.HARD
})
})