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).
10 ## [2.5.1] - 2023-06-01
14 - Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
16 ## [2.5.0] - 2023-05-31
20 - Switch pool event emitter to `EventEmitterAsyncResource`.
21 - Add tasks wait time accounting in per worker tasks usage.
22 - Add interleaved weighted round robin worker choice strategy (experimental).
26 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
28 ## [2.4.14] - 2023-05-09
32 - Ensure no undefined task runtime can land in the tasks history.
33 - Fix median computation implementation once again.
37 - Unit tests for median and queue implementations.
39 ## [2.4.13] - 2023-05-08
43 - Fix worker choice strategy options validation.
44 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
46 ## [2.4.12] - 2023-05-06
50 - Support multiple task functions per worker.
51 - Add custom worker weights support to worker choice strategies options.
55 - Use O(1) queue implementation for tasks queueing.
59 - Fix median computation implementation.
60 - Fix fair share worker choice strategy internals update.
62 ## [2.4.11] - 2023-04-23
66 - Optimize free worker finding in worker choice strategies.
68 ## [2.4.10] - 2023-04-15
72 - Fix typescript type definition for worker function: ensure the input data is optional.
73 - Fix typescript type definition for pool execute(): ensure the input data is optional.
75 ## [2.4.9] - 2023-04-15
79 - Add tasks queue enablement runtime setter to pool.
80 - Add tasks queue options runtime setter to pool.
81 - Add worker choice strategy options runtime setter to pool.
85 - Remove the tasks queuing experimental status.
89 - Fix worker function type definition and validation.
90 - Fix worker choice strategy options handling.
92 ## [2.4.8] - 2023-04-12
96 - Fix message between main worker and worker type definition for tasks.
97 - Fix code documentation.
99 ## [2.4.7] - 2023-04-11
103 - Add worker tasks queue options to pool options.
107 - Fix missing documentation.
109 ## [2.4.6] - 2023-04-10
113 - Ensure one task at a time is executed per worker with tasks queueing enabled.
114 - Properly count worker running tasks with tasks queueing enabled.
116 ## [2.4.5] - 2023-04-09
120 - Use monotonic high resolution timer for worker tasks runtime.
121 - Add worker tasks median runtime to statistics.
122 - Add worker tasks queue (experimental).
124 ## [2.4.4] - 2023-04-07
128 - Add `PoolEvents` enumeration and `PoolEvent` type.
132 - Destroy worker only on alive check.
134 ## [2.4.3] - 2023-04-07
138 - Fix typedoc generation with inheritance.
140 ## [2.4.2] - 2023-04-06
144 - Add `full` event to dynamic pool.
145 - Keep worker choice strategy in memory for conditional reuse.
149 - Fix possible negative worker key at worker removal in worker choice strategies.
151 ## [2.4.1] - 2023-04-05
155 - Optimize worker choice strategy for dynamic pool.
159 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
161 ## [2.4.0] - 2023-04-04
165 - Add `LESS_BUSY` worker choice strategy.
169 - Optimize worker storage in pool.
170 - Optimize worker alive status check.
171 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
172 - Optimize `LESS_USED` worker choice strategy.
173 - Update benchmarks versus external threads pools.
174 - Optimize tasks usage statistics requirements for worker choice strategy.
178 - Ensure trimmable characters are checked at pool initialization.
179 - Fix message id integer overflow.
180 - Fix pool worker removal in worker choice strategy internals.
181 - Fix package publication with pnpm.
183 ## [2.4.0-3] - 2023-04-04
187 - Add `LESS_BUSY` worker choice strategy.
191 - Optimize worker storage in pool.
192 - Optimize worker alive status check.
193 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
194 - Optimize `LESS_USED` worker choice strategy.
195 - Update benchmarks versus external threads pools.
199 - Ensure trimmable characters are checked at pool initialization.
200 - Fix message id integer overflow.
201 - Fix pool worker removal in worker choice strategy internals.
202 - Fix package publication with pnpm.
204 ## [2.4.0-2] - 2023-04-03
208 - Add `LESS_BUSY` worker choice strategy.
212 - Optimize worker storage in pool.
213 - Optimize worker alive status check.
214 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
215 - Optimize `LESS_USED` worker choice strategy.
219 - Ensure trimmable characters are checked at pool initialization.
220 - Fix message id integer overflow.
221 - Fix pool worker removal in worker choice strategy internals.
222 - Fix package publication with pnpm.
224 ## [2.4.0-1] - 2023-04-03
228 - Add `LESS_BUSY` worker choice strategy.
232 - Optimize worker storage in pool.
233 - Optimize worker alive status check.
234 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
235 - Optimize `LESS_USED` worker choice strategy.
239 - Ensure trimmable characters are checked at pool initialization.
240 - Fix message id integer overflow.
241 - Fix pool worker removal in worker choice strategy internals.
243 ## [2.4.0-0] - 2023-04-03
247 - Add `LESS_BUSY` worker choice strategy.
251 - Optimize worker storage in pool.
252 - Optimize worker alive status check.
253 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
254 - Optimize `LESS_USED` worker choice strategy.
258 - Ensure trimmable characters are checked at pool initialization.
259 - Fix message id integer overflow.
260 - Fix pool worker removal in worker choice strategy internals.
262 ## [2.3.10] - 2023-03-18
266 - Fix `exports` syntax for ESM and CommonJS.
270 - Permit SemVer pre-release publication.
272 ## [2.3.10-2] - 2023-03-18
276 - Fix `exports` syntax for ESM and CommonJS.
278 ## [2.3.10-1] - 2023-03-18
282 - Permit SemVer pre-release publication.
284 ## [2.3.10-0] - 2023-03-18
288 - Fix `exports` syntax for ESM and CommonJS.
290 ## [2.3.9] - 2023-03-18
294 - Introduce ESM module support along with CommonJS one.
298 - Fix brown paper bag bug referencing the same object literal.
300 ## [2.3.8] - 2023-03-18
304 - Switch internal benchmarking code to benny.
305 - Switch to TypeScript 5.x.x.
306 - Switch rollup bundler plugins to core ones.
307 - Switch to TSDoc syntax.
308 - Enforce conventional commits.
312 - Fix random integer generator.
313 - Fix worker choice strategy pool type identification at initialization.
315 ## [2.3.7] - 2022-10-23
319 - Switch to open collective FOSS project funding platform.
320 - Switch to ts-standard linter configuration on TypeScript code.
324 - Fixed missing async on pool execute method.
325 - Fixed typing in TypeScript example.
326 - Fixed types in unit tests.
328 ## [2.3.6] - 2022-10-22
332 - Cleanup pool attributes and methods.
333 - Refine error types thrown.
337 - Fix continuous integration build on windows.
338 - Fix code coverage reporting by using c8 instead of nyc.
340 ## [2.3.5] - 2022-10-21
344 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
345 - Optimize tasks usage lookup implementation.
349 - Fix missed pool event emitter type export.
350 - Fix typedoc documentation generation.
352 ## [2.3.4] - 2022-10-17
356 - Fully automate release process with release-it.
360 - Optimize fair share task scheduling algorithm implementation.
361 - Update benchmarks versus external pools results with latest version.
363 ## [2.3.3] - 2022-10-15
367 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
369 ## [2.3.2] - 2022-10-14
373 - Optimize fair share worker selection strategy implementation.
377 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
379 ## [2.3.1] - 2022-10-13
383 - Pool worker choice strategies:
384 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
385 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
387 ## [2.2.2] - 2022-10-09
391 - Fixed `README.md` file.
393 ## [2.2.1] - 2022-10-08
397 - Dynamic worker choice strategy change at runtime.
399 ## [2.2.0] - 2022-01-05
403 - Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
405 ## [2.1.0] - 2021-08-29
409 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
413 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
414 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
415 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
416 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
418 ## [2.0.2] - 2021-05-12
422 - Fix `busy` event emission on fixed pool type
424 ## [2.0.1] - 2021-03-16
428 - Check if pool options are properly set.
429 - `busy` event is emitted on all pool types.
431 ## [2.0.0] - 2021-03-01
435 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
439 - `FullPool` event is now renamed to `busy`.
440 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
441 _Find more details on our JSDoc._
443 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
445 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
447 ### Pool options types declaration merge
449 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
451 #### New `export` strategy
455 const DynamicThreadPool = require('poolifier/lib/dynamic')
457 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
460 But you should always prefer just using
463 const { DynamicThreadPool } = require('poolifier')
466 #### New type definitions for input data and response
468 For cluster worker and worker-thread pools, you can now only send and receive serializable data.
469 _This is not a limitation by poolifier but NodeJS._
471 #### Public property replacements
473 `numWorkers` property is now `numberOfWorkers`
475 #### Internal (protected) properties and methods renaming
477 These properties are not intended for end users
479 - `id` => `nextMessageId`
481 These methods are not intended for end users
483 - `_chooseWorker` => `chooseWorker`
484 - `_newWorker` => `createWorker`
485 - `_execute` => `internalExecute`
486 - `_chooseWorker` => `chooseWorker`
487 - `_checkAlive` => `checkAlive`
489 - `_runAsync` => `runAsync`
491 ## [1.1.0] - 2020-05-21
495 - ThreadWorker support async functions as option
496 - Various external library patches
498 ## [1.0.0] - 2020-01-24
502 - FixedThreadPool implementation
503 - DynamicThreadPool implementation
504 - WorkerThread implementation to improve developer experience