From: Jérôme Benoit Date: Fri, 21 Oct 2022 12:47:45 +0000 (+0200) Subject: Fix documentation generation X-Git-Tag: v2.3.5~4 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b4904890be69e53510b67172dda7b6bbf50a635a;p=poolifier.git Fix documentation generation Signed-off-by: Jérôme Benoit --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 8bc2947a..109deef4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter. - Optimize tasks usage lookup implementation. +### Fixed + +- Fix missed pool event emitter type export. +- Fix typedoc documentation generation. + ## [2.3.4] - 2022-10-17 ### Added diff --git a/src/index.ts b/src/index.ts index 6c139a27..92ed93a1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,11 +1,10 @@ export { DynamicClusterPool } from './pools/cluster/dynamic' export { FixedClusterPool } from './pools/cluster/fixed' export type { ClusterPoolOptions } from './pools/cluster/fixed' -export type { IPool, PoolOptions } from './pools/pool' +export type { IPool, PoolEmitter, PoolOptions } from './pools/pool' export type { ErrorHandler, ExitHandler, - IPoolWorker, MessageHandler, OnlineHandler } from './pools/pool-worker' @@ -14,7 +13,6 @@ export type { WorkerChoiceStrategy } from './pools/selection-strategies/selectio export { DynamicThreadPool } from './pools/thread/dynamic' export { FixedThreadPool } from './pools/thread/fixed' export type { ThreadWorkerWithMessageChannel } from './pools/thread/fixed' -export { AbstractWorker } from './worker/abstract-worker' export { ClusterWorker } from './worker/cluster-worker' export { ThreadWorker } from './worker/thread-worker' export { KillBehaviors } from './worker/worker-options' diff --git a/src/pools/abstract-pool.ts b/src/pools/abstract-pool.ts index 6393fe2e..1b10e03c 100644 --- a/src/pools/abstract-pool.ts +++ b/src/pools/abstract-pool.ts @@ -5,8 +5,9 @@ import type { import { EMPTY_FUNCTION } from '../utils' import { isKillBehavior, KillBehaviors } from '../worker/worker-options' import type { PoolOptions } from './pool' +import { PoolEmitter } from './pool' import type { IPoolInternal, TasksUsage } from './pool-internal' -import { PoolEmitter, PoolType } from './pool-internal' +import { PoolType } from './pool-internal' import type { IPoolWorker } from './pool-worker' import { WorkerChoiceStrategies, diff --git a/src/pools/cluster/dynamic.ts b/src/pools/cluster/dynamic.ts index f18f375c..3c077876 100644 --- a/src/pools/cluster/dynamic.ts +++ b/src/pools/cluster/dynamic.ts @@ -8,8 +8,8 @@ import { FixedClusterPool } from './fixed' * This cluster pool creates new workers when the others are busy, up to the maximum number of workers. * When the maximum number of workers is reached, an event is emitted. If you want to listen to this event, use the pool's `emitter`. * - * @template DataType of data sent to the worker. This can only be serializable data. - * @template ResponseType of response of execution. This can only be serializable data. + * @template Data Type of data sent to the worker. This can only be serializable data. + * @template Response Type of response of execution. This can only be serializable data. * @author [Christopher Quadflieg](https://github.com/Shinigami92) * @since 2.0.0 */ diff --git a/src/pools/cluster/fixed.ts b/src/pools/cluster/fixed.ts index 33d7f1c9..ce5a50a6 100644 --- a/src/pools/cluster/fixed.ts +++ b/src/pools/cluster/fixed.ts @@ -31,8 +31,8 @@ export interface ClusterPoolOptions extends PoolOptions { * * This pool selects the workers in a round robin fashion. * - * @template DataType of data sent to the worker. This can only be serializable data. - * @template ResponseType of response of execution. This can only be serializable data. + * @template Data Type of data sent to the worker. This can only be serializable data. + * @template Response Type of response of execution. This can only be serializable data. * @author [Christopher Quadflieg](https://github.com/Shinigami92) * @since 2.0.0 */ diff --git a/src/pools/pool-internal.ts b/src/pools/pool-internal.ts index 3f35ec13..470ccdd5 100644 --- a/src/pools/pool-internal.ts +++ b/src/pools/pool-internal.ts @@ -1,9 +1,8 @@ -import EventEmitter from 'events' import type { IPool } from './pool' import type { IPoolWorker } from './pool-worker' /** - * Pool types. + * Internal pool types. */ export enum PoolType { FIXED = 'fixed', @@ -11,7 +10,7 @@ export enum PoolType { } /** - * Tasks usage statistics. + * Internal tasks usage statistics. */ export interface TasksUsage { run: number @@ -20,11 +19,6 @@ export interface TasksUsage { avgRunTime: number } -/** - * Internal poolifier pool emitter. - */ -export class PoolEmitter extends EventEmitter {} - /** * Internal contract definition for a poolifier pool. * @@ -50,15 +44,6 @@ export interface IPoolInternal< */ readonly workersTasksUsage: Map - /** - * Emitter on which events can be listened to. - * - * Events that can currently be listened to: - * - * - `'busy'` - */ - readonly emitter?: PoolEmitter - /** * Pool type. * diff --git a/src/pools/pool-worker.ts b/src/pools/pool-worker.ts index c89205ac..fdca80c8 100644 --- a/src/pools/pool-worker.ts +++ b/src/pools/pool-worker.ts @@ -1,12 +1,3 @@ -import type { Worker as ClusterWorker } from 'cluster' -import type { Worker as WorkerThread } from 'worker_threads' -import type { Draft } from '../utility-types' - -/** - * Poolifier supported worker type. - */ -export type WorkerType = WorkerThread & ClusterWorker & Draft - /** * Callback invoked if the worker has received a message. */ diff --git a/src/pools/pool.ts b/src/pools/pool.ts index c6fbce43..78e7c981 100644 --- a/src/pools/pool.ts +++ b/src/pools/pool.ts @@ -1,3 +1,4 @@ +import EventEmitter from 'events' import type { ErrorHandler, ExitHandler, @@ -6,6 +7,11 @@ import type { } from './pool-worker' import type { WorkerChoiceStrategy } from './selection-strategies/selection-strategies-types' +/** + * Pool events emitter. + */ +export class PoolEmitter extends EventEmitter {} + /** * Options for a poolifier pool. */ @@ -45,6 +51,14 @@ export interface PoolOptions { * @template Response Type of response of execution. This can only be serializable data. */ export interface IPool { + /** + * Emitter on which events can be listened to. + * + * Events that can currently be listened to: + * + * - `'busy'` + */ + readonly emitter?: PoolEmitter /** * Performs the task specified in the constructor with the data parameter. * diff --git a/src/pools/thread/dynamic.ts b/src/pools/thread/dynamic.ts index 7069f7f3..9ba21899 100644 --- a/src/pools/thread/dynamic.ts +++ b/src/pools/thread/dynamic.ts @@ -9,8 +9,8 @@ import { FixedThreadPool } from './fixed' * This thread pool creates new threads when the others are busy, up to the maximum number of threads. * When the maximum number of threads is reached, an event is emitted. If you want to listen to this event, use the pool's `emitter`. * - * @template DataType of data sent to the worker. This can only be serializable data. - * @template ResponseType of response of execution. This can only be serializable data. + * @template Data Type of data sent to the worker. This can only be serializable data. + * @template Response Type of response of execution. This can only be serializable data. * @author [Alessandro Pio Ardizio](https://github.com/pioardi) * @since 0.0.1 */ diff --git a/src/pools/thread/fixed.ts b/src/pools/thread/fixed.ts index cd414502..e8be44f2 100644 --- a/src/pools/thread/fixed.ts +++ b/src/pools/thread/fixed.ts @@ -16,8 +16,8 @@ export type ThreadWorkerWithMessageChannel = Worker & Draft * * This pool selects the threads in a round robin fashion. * - * @template DataType of data sent to the worker. This can only be serializable data. - * @template ResponseType of response of execution. This can only be serializable data. + * @template Data Type of data sent to the worker. This can only be serializable data. + * @template Response Type of response of execution. This can only be serializable data. * @author [Alessandro Pio Ardizio](https://github.com/pioardi) * @since 0.0.1 */ diff --git a/src/worker/cluster-worker.ts b/src/worker/cluster-worker.ts index 4e57e963..19bfa4e5 100644 --- a/src/worker/cluster-worker.ts +++ b/src/worker/cluster-worker.ts @@ -13,8 +13,8 @@ import type { WorkerOptions } from './worker-options' * If you use a `DynamicClusterPool` the extra workers that were created will be terminated, * but the minimum number of workers will be guaranteed. * - * @template DataType of data this worker receives from pool's execution. This can only be serializable data. - * @template ResponseType of response the worker sends back to the main worker. This can only be serializable data. + * @template Data Type of data this worker receives from pool's execution. This can only be serializable data. + * @template Response Type of response the worker sends back to the main worker. This can only be serializable data. * @author [Christopher Quadflieg](https://github.com/Shinigami92) * @since 2.0.0 */ diff --git a/src/worker/thread-worker.ts b/src/worker/thread-worker.ts index de1c36bf..20141e44 100644 --- a/src/worker/thread-worker.ts +++ b/src/worker/thread-worker.ts @@ -13,8 +13,8 @@ import type { WorkerOptions } from './worker-options' * If you use a `DynamicThreadPool` the extra workers that were created will be terminated, * but the minimum number of workers will be guaranteed. * - * @template DataType of data this worker receives from pool's execution. This can only be serializable data. - * @template ResponseType of response the worker sends back to the main thread. This can only be serializable data. + * @template Data Type of data this worker receives from pool's execution. This can only be serializable data. + * @template Response Type of response the worker sends back to the main thread. This can only be serializable data. * @author [Alessandro Pio Ardizio](https://github.com/pioardi) * @since 0.0.1 */ diff --git a/tsconfig.json b/tsconfig.json index 442a4745..e3e37916 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,5 +9,5 @@ "importsNotUsedAsValues": "error" }, "include": ["**/*.ts"], - "exclude": ["node_modules"] + "exclude": ["node_modules", "examples/typescript"] } diff --git a/typedoc.json b/typedoc.json index 7b867079..2fdc1c5f 100644 --- a/typedoc.json +++ b/typedoc.json @@ -1,5 +1,5 @@ { - "entryPoints": ["src/index.ts"], + "entryPoints": ["src"], "out": "docs", "readme": "none" }