## [Unreleased]
+### Changed
+
+- Readd ThreadPoolOptions and ClusterPoolOptions TS type aliases to PoolOptions.
+
## [3.1.8] - 2023-12-21
### Fixed
- [`pool.removeTaskFunction(name)`](#poolremovetaskfunctionname)
- [`pool.listTaskFunctionNames()`](#poollisttaskfunctionnames)
- [`pool.setDefaultTaskFunction(name)`](#poolsetdefaulttaskfunctionname)
- - [`PoolOptions`](#pooloptions)
+ - [`Pool options`](#pool-options)
- [Worker](#worker)
- [`class YourWorker extends ThreadWorker/ClusterWorker`](#class-yourworker-extends-threadworkerclusterworker)
- [`YourWorker.hasTaskFunction(name)`](#yourworkerhastaskfunctionname)
This method is available on both pool implementations and returns a boolean promise.
-### `PoolOptions`
+### `Pool options`
An object with these properties:
-import type { Worker } from 'node:worker_threads'
-import type { PoolOptions } from 'poolifier'
+import type { ThreadPoolOptions } from 'poolifier'
-export interface ClusterWorkerData extends PoolOptions<Worker> {
+export interface ClusterWorkerData extends ThreadPoolOptions {
port: number
workerFile: string
minWorkers?: number
-import type { Worker } from 'node:worker_threads'
-import type { PoolOptions } from 'poolifier'
+import type { ThreadPoolOptions } from 'poolifier'
export interface ClusterWorkerData extends FastifyPoolifierOptions {
port: number
data: T
}
-export interface FastifyPoolifierOptions extends PoolOptions<Worker> {
+export interface FastifyPoolifierOptions extends ThreadPoolOptions {
workerFile: string
minWorkers?: number
maxWorkers?: number
-import type { Worker } from 'node:worker_threads'
-import type { PoolOptions } from 'poolifier'
+import type { ThreadPoolOptions } from 'poolifier'
export interface BodyPayload {
number?: number
body: T
}
-export interface FastifyPoolifierOptions extends PoolOptions<Worker> {
+export interface FastifyPoolifierOptions extends ThreadPoolOptions {
workerFile: string
minWorkers?: number
maxWorkers?: number
-import type { Worker } from 'node:worker_threads'
-import type { PoolOptions } from 'poolifier'
+import type { ThreadPoolOptions } from 'poolifier'
export enum MessageType {
echo = 'echo',
number?: number
}
-export interface ClusterWorkerData extends PoolOptions<Worker> {
+export interface ClusterWorkerData extends ThreadPoolOptions {
port: number
workerFile: string
minWorkers?: number
export type { AbstractPool } from './pools/abstract-pool'
export { DynamicClusterPool } from './pools/cluster/dynamic'
export { FixedClusterPool } from './pools/cluster/fixed'
+export type { ClusterPoolOptions } from './pools/cluster/fixed'
export { PoolEvents, PoolTypes } from './pools/pool'
export type {
IPool,
} from './pools/selection-strategies/selection-strategies-types'
export type {
IWorkerChoiceStrategy,
+ InternalWorkerChoiceStrategyOptions,
Measurement,
MeasurementOptions,
MeasurementStatisticsRequirements,
export type { WorkerChoiceStrategyContext } from './pools/selection-strategies/worker-choice-strategy-context'
export { DynamicThreadPool } from './pools/thread/dynamic'
export { FixedThreadPool } from './pools/thread/fixed'
+export type { ThreadPoolOptions } from './pools/thread/fixed'
export type { AbstractWorker } from './worker/abstract-worker'
export { ClusterWorker } from './worker/cluster-worker'
export { ThreadWorker } from './worker/thread-worker'
-import { type Worker } from 'node:cluster'
-import { type PoolOptions, type PoolType, PoolTypes } from '../pool'
import { checkDynamicPoolSize } from '../utils'
-import { FixedClusterPool } from './fixed'
+import { type PoolType, PoolTypes } from '../pool'
+import { type ClusterPoolOptions, FixedClusterPool } from './fixed'
/**
* A cluster pool with a dynamic number of workers, but a guaranteed minimum number of workers.
min: number,
max: number,
filePath: string,
- opts: PoolOptions<Worker> = {}
+ opts: ClusterPoolOptions = {}
) {
super(min, filePath, opts, max)
checkDynamicPoolSize(
import { type PoolOptions, type PoolType, PoolTypes } from '../pool'
import { type WorkerType, WorkerTypes } from '../worker'
+/**
+ * Options for a poolifier cluster pool.
+ */
+export type ClusterPoolOptions = PoolOptions<Worker>
+
/**
* A cluster pool with a fixed number of workers.
*
public constructor (
numberOfWorkers: number,
filePath: string,
- opts: PoolOptions<Worker> = {},
+ opts: ClusterPoolOptions = {},
maximumNumberOfWorkers?: number
) {
super(numberOfWorkers, filePath, opts, maximumNumberOfWorkers)
-import { type Worker } from 'node:worker_threads'
-import { type PoolOptions, type PoolType, PoolTypes } from '../pool'
+import { type PoolType, PoolTypes } from '../pool'
import { checkDynamicPoolSize } from '../utils'
-import { FixedThreadPool } from './fixed'
+import { FixedThreadPool, type ThreadPoolOptions } from './fixed'
/**
* A thread pool with a dynamic number of threads, but a guaranteed minimum number of threads.
min: number,
max: number,
filePath: string,
- opts: PoolOptions<Worker> = {}
+ opts: ThreadPoolOptions = {}
) {
super(min, filePath, opts, max)
checkDynamicPoolSize(
import { type PoolOptions, type PoolType, PoolTypes } from '../pool'
import { type WorkerType, WorkerTypes } from '../worker'
+/**
+ * Options for a poolifier thread pool.
+ */
+export type ThreadPoolOptions = PoolOptions<Worker>
+
/**
* A thread pool with a fixed number of threads.
*
public constructor (
numberOfThreads: number,
filePath: string,
- opts: PoolOptions<Worker> = {},
+ opts: ThreadPoolOptions = {},
maximumNumberOfThreads?: number
) {
super(numberOfThreads, filePath, opts, maximumNumberOfThreads)