Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
### Added
- Add pool `utilization` ratio to pool information.
### Added
- Add pool `utilization` ratio to pool information.
+- Add `version` to pool information.
- Add worker information to worker nodes.
## [2.6.6] - 2023-07-01
- Add worker information to worker nodes.
## [2.6.6] - 2023-07-01
'node:cluster',
'node:crypto',
'node:events',
'node:cluster',
'node:crypto',
'node:events',
'node:os',
'node:perf_hooks',
'node:worker_threads'
'node:os',
'node:perf_hooks',
'node:worker_threads'
import crypto from 'node:crypto'
import { performance } from 'node:perf_hooks'
import crypto from 'node:crypto'
import { performance } from 'node:perf_hooks'
+import { readFileSync } from 'node:fs'
import type { MessageValue, PromiseResponseWrapper } from '../utility-types'
import {
DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS,
import type { MessageValue, PromiseResponseWrapper } from '../utility-types'
import {
DEFAULT_WORKER_CHOICE_STRATEGY_OPTIONS,
} from './selection-strategies/selection-strategies-types'
import { WorkerChoiceStrategyContext } from './selection-strategies/worker-choice-strategy-context'
} from './selection-strategies/selection-strategies-types'
import { WorkerChoiceStrategyContext } from './selection-strategies/worker-choice-strategy-context'
+const version = (
+ JSON.parse(
+ readFileSync(new URL('../../package.json', import.meta.url), 'utf8')
+ ) as Record<string, unknown>
+).version as string
+
/**
* Base class that implements some shared logic for all poolifier pools.
*
/**
* Base class that implements some shared logic for all poolifier pools.
*
/** @inheritDoc */
public get info (): PoolInfo {
return {
/** @inheritDoc */
public get info (): PoolInfo {
return {
type: this.type,
worker: this.worker,
minSize: this.minSize,
type: this.type,
worker: this.worker,
minSize: this.minSize,
* Pool information.
*/
export interface PoolInfo {
* Pool information.
*/
export interface PoolInfo {
type: PoolType
worker: WorkerType
minSize: number
type: PoolType
worker: WorkerType
minSize: number
} = require('../../../lib')
const { CircularArray } = require('../../../lib/circular-array')
const { Queue } = require('../../../lib/queue')
} = require('../../../lib')
const { CircularArray } = require('../../../lib/circular-array')
const { Queue } = require('../../../lib/queue')
+const { version } = require('../../../package.json')
describe('Abstract pool test suite', () => {
const numberOfWorkers = 2
describe('Abstract pool test suite', () => {
const numberOfWorkers = 2
'./tests/worker-files/thread/testWorker.js'
)
expect(pool.info).toStrictEqual({
'./tests/worker-files/thread/testWorker.js'
)
expect(pool.info).toStrictEqual({
type: PoolTypes.fixed,
worker: WorkerTypes.thread,
minSize: numberOfWorkers,
type: PoolTypes.fixed,
worker: WorkerTypes.thread,
minSize: numberOfWorkers,
'./tests/worker-files/cluster/testWorker.js'
)
expect(pool.info).toStrictEqual({
'./tests/worker-files/cluster/testWorker.js'
)
expect(pool.info).toStrictEqual({
type: PoolTypes.dynamic,
worker: WorkerTypes.cluster,
minSize: numberOfWorkers,
type: PoolTypes.dynamic,
worker: WorkerTypes.cluster,
minSize: numberOfWorkers,
// So in total numberOfWorkers * 2 times for a loop submitting up to numberOfWorkers * 2 tasks to the dynamic pool with min = max = numberOfWorkers.
expect(poolFull).toBe(numberOfWorkers * 2)
expect(poolInfo).toStrictEqual({
// So in total numberOfWorkers * 2 times for a loop submitting up to numberOfWorkers * 2 tasks to the dynamic pool with min = max = numberOfWorkers.
expect(poolFull).toBe(numberOfWorkers * 2)
expect(poolInfo).toStrictEqual({
type: PoolTypes.dynamic,
worker: WorkerTypes.thread,
minSize: expect.any(Number),
type: PoolTypes.dynamic,
worker: WorkerTypes.thread,
minSize: expect.any(Number),
// So in total numberOfWorkers + 1 times for a loop submitting up to numberOfWorkers * 2 tasks to the fixed pool.
expect(poolBusy).toBe(numberOfWorkers + 1)
expect(poolInfo).toStrictEqual({
// So in total numberOfWorkers + 1 times for a loop submitting up to numberOfWorkers * 2 tasks to the fixed pool.
expect(poolBusy).toBe(numberOfWorkers + 1)
expect(poolInfo).toStrictEqual({
type: PoolTypes.fixed,
worker: WorkerTypes.thread,
minSize: expect.any(Number),
type: PoolTypes.fixed,
worker: WorkerTypes.thread,
minSize: expect.any(Number),
"target": "ES2022",
"module": "ES2022",
"outDir": "lib",
"target": "ES2022",
"module": "ES2022",
"outDir": "lib",
+ "moduleResolution": "Node",
"esModuleInterop": true,
"declaration": true,
"esModuleInterop": true,
"declaration": true,
+ "strict": true,
+ "forceConsistentCasingInFileNames": true
},
"include": ["**/*.ts"],
"exclude": ["node_modules", "lib"]
},
"include": ["**/*.ts"],
"exclude": ["node_modules", "lib"]