export { ClusterWorker } from './worker/cluster-worker'
export { ThreadWorker } from './worker/thread-worker'
export type { WorkerOptions } from './worker/worker-options'
-export { killBehaviorEnumeration } from './worker/worker-options'
+export { killBehaviorTypes } from './worker/worker-options'
import type { JSONValue } from '../../utility-types'
import type { ClusterPoolOptions } from './fixed'
import { FixedClusterPool } from './fixed'
-import { killBehaviorEnumeration } from '../../worker/worker-options'
+import { killBehaviorTypes } from '../../worker/worker-options'
/**
* A cluster pool with a dynamic number of workers, but a guaranteed minimum number of workers.
this.registerWorkerMessageListener<Data>(worker, message => {
const tasksInProgress = this.tasks.get(worker)
const isKillBehaviorOptionHard =
- message.kill === killBehaviorEnumeration.HARD
+ message.kill === killBehaviorTypes.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 })
import type { PoolOptions } from '../abstract-pool'
import type { ThreadWorkerWithMessageChannel } from './fixed'
import { FixedThreadPool } from './fixed'
-import { killBehaviorEnumeration } from '../../worker/worker-options'
+import { killBehaviorTypes } from '../../worker/worker-options'
/**
* A thread pool with a dynamic number of threads, but a guaranteed minimum number of threads.
this.registerWorkerMessageListener<Data>(worker, message => {
const tasksInProgress = this.tasks.get(worker)
const isKillBehaviorOptionHard =
- message.kill === killBehaviorEnumeration.HARD
+ message.kill === killBehaviorTypes.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 })
import type { MessagePort } from 'worker_threads'
import type { MessageValue, KillBehavior } from '../utility-types'
import type { WorkerOptions } from './worker-options'
-// import { killBehaviorEnumeration } from './worker-options'
+// import { killBehaviorTypes } from './worker-options'
const defaultMaxInactiveTime = 1000 * 60
// TODO fix this and avoid that SOFT/HARD words are replicated so much times into the project
/**
* Kill behavior enumeration
*/
-export const killBehaviorEnumeration = Object.freeze({
+export const killBehaviorTypes = Object.freeze({
SOFT: 'SOFT',
HARD: 'HARD'
})
'use strict'
-const { ClusterWorker, killBehaviorEnumeration } = require('../../../lib/index')
+const { ClusterWorker, killBehaviorTypes } = require('../../../lib/index')
async function error (data) {
return new Promise((resolve, reject) => {
module.exports = new ClusterWorker(error, {
maxInactiveTime: 500,
async: true,
- killBehavior: killBehaviorEnumeration
+ killBehavior: killBehaviorTypes
})
'use strict'
-const { ClusterWorker, killBehaviorEnumeration } = require('../../../lib/index')
+const { ClusterWorker, killBehaviorTypes } = require('../../../lib/index')
async function sleep (data) {
return new Promise((resolve, reject) => {
module.exports = new ClusterWorker(sleep, {
maxInactiveTime: 500,
async: true,
- killBehavior: killBehaviorEnumeration.HARD
+ killBehavior: killBehaviorTypes.HARD
})
'use strict'
-const { ClusterWorker, killBehaviorEnumeration } = require('../../../lib/index')
+const { ClusterWorker, killBehaviorTypes } = require('../../../lib/index')
function echo (data) {
return data
module.exports = new ClusterWorker(echo, {
maxInactiveTime: 500,
- killBehavior: killBehaviorEnumeration.HARD
+ killBehavior: killBehaviorTypes.HARD
})
'use strict'
-const { ClusterWorker, killBehaviorEnumeration } = require('../../../lib/index')
+const { ClusterWorker, killBehaviorTypes } = require('../../../lib/index')
function test (data) {}
module.exports = new ClusterWorker(test, {
maxInactiveTime: 500,
- killBehavior: killBehaviorEnumeration.HARD
+ killBehavior: killBehaviorTypes.HARD
})
'use strict'
-const { ClusterWorker, killBehaviorEnumeration } = require('../../../lib/index')
+const { ClusterWorker, killBehaviorTypes } = require('../../../lib/index')
function error (data) {
throw new Error('Error Message from ClusterWorker')
module.exports = new ClusterWorker(error, {
maxInactiveTime: 500,
async: false,
- killBehavior: killBehaviorEnumeration
+ killBehavior: killBehaviorTypes
})
'use strict'
-const { ClusterWorker, killBehaviorEnumeration } = require('../../../lib/index')
+const { ClusterWorker, killBehaviorTypes } = require('../../../lib/index')
async function sleep (data) {
return new Promise((resolve, reject) => {
module.exports = new ClusterWorker(sleep, {
maxInactiveTime: 500,
async: true,
- killBehavior: killBehaviorEnumeration.HARD
+ killBehavior: killBehaviorTypes.HARD
})
'use strict'
-const { ClusterWorker, killBehaviorEnumeration } = require('../../../lib/index')
+const { ClusterWorker, killBehaviorTypes } = require('../../../lib/index')
const { isMaster } = require('cluster')
function test (data) {
module.exports = new ClusterWorker(test, {
maxInactiveTime: 500,
- killBehavior: killBehaviorEnumeration.HARD
+ killBehavior: killBehaviorTypes.HARD
})
'use strict'
-const { ThreadWorker, killBehaviorEnumeration } = require('../../../lib/index')
+const { ThreadWorker, killBehaviorTypes } = require('../../../lib/index')
async function sleep (data) {
return new Promise((resolve, reject) => {
module.exports = new ThreadWorker(sleep, {
maxInactiveTime: 500,
async: true,
- killBehavior: killBehaviorEnumeration.HARD
+ killBehavior: killBehaviorTypes.HARD
})
'use strict'
-const { ThreadWorker, killBehaviorEnumeration } = require('../../../lib/index')
+const { ThreadWorker, killBehaviorTypes } = require('../../../lib/index')
function echo (data) {
return data
module.exports = new ThreadWorker(echo, {
maxInactiveTime: 500,
- killBehavior: killBehaviorEnumeration.HARD
+ killBehavior: killBehaviorTypes.HARD
})
'use strict'
-const { ThreadWorker, killBehaviorEnumeration } = require('../../../lib/index')
+const { ThreadWorker, killBehaviorTypes } = require('../../../lib/index')
function test (data) {}
module.exports = new ThreadWorker(test, {
maxInactiveTime: 500,
- killBehavior: killBehaviorEnumeration.HARD
+ killBehavior: killBehaviorTypes.HARD
})
'use strict'
-const { ThreadWorker, killBehaviorEnumeration } = require('../../../lib/index')
+const { ThreadWorker, killBehaviorTypes } = require('../../../lib/index')
function error (data) {
throw new Error(data)
module.exports = new ThreadWorker(error, {
maxInactiveTime: 500,
- killBehavior: killBehaviorEnumeration.HARD
+ killBehavior: killBehaviorTypes.HARD
})
'use strict'
-const { ThreadWorker, killBehaviorEnumeration } = require('../../../lib/index')
+const { ThreadWorker, killBehaviorTypes } = require('../../../lib/index')
async function sleep (data) {
return new Promise((resolve, reject) => {
module.exports = new ThreadWorker(sleep, {
maxInactiveTime: 500,
async: true,
- killBehavior: killBehaviorEnumeration.HARD
+ killBehavior: killBehaviorTypes.HARD
})
'use strict'
-const { ThreadWorker, killBehaviorEnumeration } = require('../../../lib/index')
+const { ThreadWorker, killBehaviorTypes } = require('../../../lib/index')
const { isMainThread } = require('worker_threads')
function test (data) {
module.exports = new ThreadWorker(test, {
maxInactiveTime: 500,
- killBehavior: killBehaviorEnumeration.HARD
+ killBehavior: killBehaviorTypes.HARD
})