3 All notable changes to this project will be documented in this file.
5 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
12 - Add `taskError` pool event for task execution error.
13 - Add pool information `info` property to pool.
14 - Emit pool information on `busy` and `full` pool events.
16 ## [2.5.1] - 2023-06-01
20 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
21 - Add `error` pool event for uncaught worker error.
23 ## [2.5.0] - 2023-05-31
27 - Switch pool event emitter to `EventEmitterAsyncResource`.
28 - Add tasks wait time accounting in per worker tasks usage.
29 - Add interleaved weighted round robin worker choice strategy (experimental).
33 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
35 ## [2.4.14] - 2023-05-09
39 - Ensure no undefined task runtime can land in the tasks history.
40 - Fix median computation implementation once again.
44 - Unit tests for median and queue implementations.
46 ## [2.4.13] - 2023-05-08
50 - Fix worker choice strategy options validation.
51 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
53 ## [2.4.12] - 2023-05-06
57 - Support multiple task functions per worker.
58 - Add custom worker weights support to worker choice strategies options.
62 - Use O(1) queue implementation for tasks queueing.
66 - Fix median computation implementation.
67 - Fix fair share worker choice strategy internals update.
69 ## [2.4.11] - 2023-04-23
73 - Optimize free worker finding in worker choice strategies.
75 ## [2.4.10] - 2023-04-15
79 - Fix typescript type definition for worker function: ensure the input data is optional.
80 - Fix typescript type definition for pool execute(): ensure the input data is optional.
82 ## [2.4.9] - 2023-04-15
86 - Add tasks queue enablement runtime setter to pool.
87 - Add tasks queue options runtime setter to pool.
88 - Add worker choice strategy options runtime setter to pool.
92 - Remove the tasks queuing experimental status.
96 - Fix worker function type definition and validation.
97 - Fix worker choice strategy options handling.
99 ## [2.4.8] - 2023-04-12
103 - Fix message between main worker and worker type definition for tasks.
104 - Fix code documentation.
106 ## [2.4.7] - 2023-04-11
110 - Add worker tasks queue options to pool options.
114 - Fix missing documentation.
116 ## [2.4.6] - 2023-04-10
120 - Ensure one task at a time is executed per worker with tasks queueing enabled.
121 - Properly count worker running tasks with tasks queueing enabled.
123 ## [2.4.5] - 2023-04-09
127 - Use monotonic high resolution timer for worker tasks runtime.
128 - Add worker tasks median runtime to statistics.
129 - Add worker tasks queue (experimental).
131 ## [2.4.4] - 2023-04-07
135 - Add `PoolEvents` enumeration and `PoolEvent` type.
139 - Destroy worker only on alive check.
141 ## [2.4.3] - 2023-04-07
145 - Fix typedoc generation with inheritance.
147 ## [2.4.2] - 2023-04-06
151 - Add `full` event to dynamic pool.
152 - Keep worker choice strategy in memory for conditional reuse.
156 - Fix possible negative worker key at worker removal in worker choice strategies.
158 ## [2.4.1] - 2023-04-05
162 - Optimize worker choice strategy for dynamic pool.
166 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
168 ## [2.4.0] - 2023-04-04
172 - Add `LESS_BUSY` worker choice strategy.
176 - Optimize worker storage in pool.
177 - Optimize worker alive status check.
178 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
179 - Optimize `LESS_USED` worker choice strategy.
180 - Update benchmarks versus external threads pools.
181 - Optimize tasks usage statistics requirements for worker choice strategy.
185 - Ensure trimmable characters are checked at pool initialization.
186 - Fix message id integer overflow.
187 - Fix pool worker removal in worker choice strategy internals.
188 - Fix package publication with pnpm.
190 ## [2.4.0-3] - 2023-04-04
194 - Add `LESS_BUSY` worker choice strategy.
198 - Optimize worker storage in pool.
199 - Optimize worker alive status check.
200 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
201 - Optimize `LESS_USED` worker choice strategy.
202 - Update benchmarks versus external threads pools.
206 - Ensure trimmable characters are checked at pool initialization.
207 - Fix message id integer overflow.
208 - Fix pool worker removal in worker choice strategy internals.
209 - Fix package publication with pnpm.
211 ## [2.4.0-2] - 2023-04-03
215 - Add `LESS_BUSY` worker choice strategy.
219 - Optimize worker storage in pool.
220 - Optimize worker alive status check.
221 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
222 - Optimize `LESS_USED` worker choice strategy.
226 - Ensure trimmable characters are checked at pool initialization.
227 - Fix message id integer overflow.
228 - Fix pool worker removal in worker choice strategy internals.
229 - Fix package publication with pnpm.
231 ## [2.4.0-1] - 2023-04-03
235 - Add `LESS_BUSY` worker choice strategy.
239 - Optimize worker storage in pool.
240 - Optimize worker alive status check.
241 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
242 - Optimize `LESS_USED` worker choice strategy.
246 - Ensure trimmable characters are checked at pool initialization.
247 - Fix message id integer overflow.
248 - Fix pool worker removal in worker choice strategy internals.
250 ## [2.4.0-0] - 2023-04-03
254 - Add `LESS_BUSY` worker choice strategy.
258 - Optimize worker storage in pool.
259 - Optimize worker alive status check.
260 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
261 - Optimize `LESS_USED` worker choice strategy.
265 - Ensure trimmable characters are checked at pool initialization.
266 - Fix message id integer overflow.
267 - Fix pool worker removal in worker choice strategy internals.
269 ## [2.3.10] - 2023-03-18
273 - Fix `exports` syntax for ESM and CommonJS.
277 - Permit SemVer pre-release publication.
279 ## [2.3.10-2] - 2023-03-18
283 - Fix `exports` syntax for ESM and CommonJS.
285 ## [2.3.10-1] - 2023-03-18
289 - Permit SemVer pre-release publication.
291 ## [2.3.10-0] - 2023-03-18
295 - Fix `exports` syntax for ESM and CommonJS.
297 ## [2.3.9] - 2023-03-18
301 - Introduce ESM module support along with CommonJS one.
305 - Fix brown paper bag bug referencing the same object literal.
307 ## [2.3.8] - 2023-03-18
311 - Switch internal benchmarking code to benny.
312 - Switch to TypeScript 5.x.x.
313 - Switch rollup bundler plugins to core ones.
314 - Switch to TSDoc syntax.
315 - Enforce conventional commits.
319 - Fix random integer generator.
320 - Fix worker choice strategy pool type identification at initialization.
322 ## [2.3.7] - 2022-10-23
326 - Switch to open collective FOSS project funding platform.
327 - Switch to ts-standard linter configuration on TypeScript code.
331 - Fixed missing async on pool execute method.
332 - Fixed typing in TypeScript example.
333 - Fixed types in unit tests.
335 ## [2.3.6] - 2022-10-22
339 - Cleanup pool attributes and methods.
340 - Refine error types thrown.
344 - Fix continuous integration build on windows.
345 - Fix code coverage reporting by using c8 instead of nyc.
347 ## [2.3.5] - 2022-10-21
351 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
352 - Optimize tasks usage lookup implementation.
356 - Fix missed pool event emitter type export.
357 - Fix typedoc documentation generation.
359 ## [2.3.4] - 2022-10-17
363 - Fully automate release process with release-it.
367 - Optimize fair share task scheduling algorithm implementation.
368 - Update benchmarks versus external pools results with latest version.
370 ## [2.3.3] - 2022-10-15
374 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
376 ## [2.3.2] - 2022-10-14
380 - Optimize fair share worker selection strategy implementation.
384 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
386 ## [2.3.1] - 2022-10-13
390 - Pool worker choice strategies:
391 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
392 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
394 ## [2.2.2] - 2022-10-09
398 - Fixed `README.md` file.
400 ## [2.2.1] - 2022-10-08
404 - Dynamic worker choice strategy change at runtime.
406 ## [2.2.0] - 2022-01-05
410 - Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
412 ## [2.1.0] - 2021-08-29
416 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
420 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
421 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
422 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
423 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
425 ## [2.0.2] - 2021-05-12
429 - Fix `busy` event emission on fixed pool type
431 ## [2.0.1] - 2021-03-16
435 - Check if pool options are properly set.
436 - `busy` event is emitted on all pool types.
438 ## [2.0.0] - 2021-03-01
442 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
446 - `FullPool` event is now renamed to `busy`.
447 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
448 _Find more details on our JSDoc._
450 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
452 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
454 ### Pool options types declaration merge
456 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
458 #### New `export` strategy
462 const DynamicThreadPool = require('poolifier/lib/dynamic')
464 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
467 But you should always prefer just using
470 const { DynamicThreadPool } = require('poolifier')
473 #### New type definitions for input data and response
475 For cluster worker and worker-thread pools, you can now only send and receive serializable data.
476 _This is not a limitation by poolifier but NodeJS._
478 #### Public property replacements
480 `numWorkers` property is now `numberOfWorkers`
482 #### Internal (protected) properties and methods renaming
484 These properties are not intended for end users
486 - `id` => `nextMessageId`
488 These methods are not intended for end users
490 - `_chooseWorker` => `chooseWorker`
491 - `_newWorker` => `createWorker`
492 - `_execute` => `internalExecute`
493 - `_chooseWorker` => `chooseWorker`
494 - `_checkAlive` => `checkAlive`
496 - `_runAsync` => `runAsync`
498 ## [1.1.0] - 2020-05-21
502 - ThreadWorker support async functions as option
503 - Various external library patches
505 ## [1.0.0] - 2020-01-24
509 - FixedThreadPool implementation
510 - DynamicThreadPool implementation
511 - WorkerThread implementation to improve developer experience