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 pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
14 ## [2.5.0] - 2023-05-31
18 - Switch pool event emitter to `EventEmitterAsyncResource`.
19 - Add tasks wait time accounting in per worker tasks usage.
20 - Add interleaved weighted round robin worker choice strategy (experimental).
24 - Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
26 ## [2.4.14] - 2023-05-09
30 - Ensure no undefined task runtime can land in the tasks history.
31 - Fix median computation implementation once again.
35 - Unit tests for median and queue implementations.
37 ## [2.4.13] - 2023-05-08
41 - Fix worker choice strategy options validation.
42 - Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
44 ## [2.4.12] - 2023-05-06
48 - Support multiple task functions per worker.
49 - Add custom worker weights support to worker choice strategies options.
53 - Use O(1) queue implementation for tasks queueing.
57 - Fix median computation implementation.
58 - Fix fair share worker choice strategy internals update.
60 ## [2.4.11] - 2023-04-23
64 - Optimize free worker finding in worker choice strategies.
66 ## [2.4.10] - 2023-04-15
70 - Fix typescript type definition for worker function: ensure the input data is optional.
71 - Fix typescript type definition for pool execute(): ensure the input data is optional.
73 ## [2.4.9] - 2023-04-15
77 - Add tasks queue enablement runtime setter to pool.
78 - Add tasks queue options runtime setter to pool.
79 - Add worker choice strategy options runtime setter to pool.
83 - Remove the tasks queuing experimental status.
87 - Fix worker function type definition and validation.
88 - Fix worker choice strategy options handling.
90 ## [2.4.8] - 2023-04-12
94 - Fix message between main worker and worker type definition for tasks.
95 - Fix code documentation.
97 ## [2.4.7] - 2023-04-11
101 - Add worker tasks queue options to pool options.
105 - Fix missing documentation.
107 ## [2.4.6] - 2023-04-10
111 - Ensure one task at a time is executed per worker with tasks queueing enabled.
112 - Properly count worker running tasks with tasks queueing enabled.
114 ## [2.4.5] - 2023-04-09
118 - Use monotonic high resolution timer for worker tasks runtime.
119 - Add worker tasks median runtime to statistics.
120 - Add worker tasks queue (experimental).
122 ## [2.4.4] - 2023-04-07
126 - Add `PoolEvents` enumeration and `PoolEvent` type.
130 - Destroy worker only on alive check.
132 ## [2.4.3] - 2023-04-07
136 - Fix typedoc generation with inheritance.
138 ## [2.4.2] - 2023-04-06
142 - Add `full` event to dynamic pool.
143 - Keep worker choice strategy in memory for conditional reuse.
147 - Fix possible negative worker key at worker removal in worker choice strategies.
149 ## [2.4.1] - 2023-04-05
153 - Optimize worker choice strategy for dynamic pool.
157 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
159 ## [2.4.0] - 2023-04-04
163 - Add `LESS_BUSY` worker choice strategy.
167 - Optimize worker storage in pool.
168 - Optimize worker alive status check.
169 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
170 - Optimize `LESS_USED` worker choice strategy.
171 - Update benchmarks versus external threads pools.
172 - Optimize tasks usage statistics requirements for worker choice strategy.
176 - Ensure trimmable characters are checked at pool initialization.
177 - Fix message id integer overflow.
178 - Fix pool worker removal in worker choice strategy internals.
179 - Fix package publication with pnpm.
181 ## [2.4.0-3] - 2023-04-04
185 - Add `LESS_BUSY` worker choice strategy.
189 - Optimize worker storage in pool.
190 - Optimize worker alive status check.
191 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
192 - Optimize `LESS_USED` worker choice strategy.
193 - Update benchmarks versus external threads pools.
197 - Ensure trimmable characters are checked at pool initialization.
198 - Fix message id integer overflow.
199 - Fix pool worker removal in worker choice strategy internals.
200 - Fix package publication with pnpm.
202 ## [2.4.0-2] - 2023-04-03
206 - Add `LESS_BUSY` worker choice strategy.
210 - Optimize worker storage in pool.
211 - Optimize worker alive status check.
212 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
213 - Optimize `LESS_USED` worker choice strategy.
217 - Ensure trimmable characters are checked at pool initialization.
218 - Fix message id integer overflow.
219 - Fix pool worker removal in worker choice strategy internals.
220 - Fix package publication with pnpm.
222 ## [2.4.0-1] - 2023-04-03
226 - Add `LESS_BUSY` worker choice strategy.
230 - Optimize worker storage in pool.
231 - Optimize worker alive status check.
232 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
233 - Optimize `LESS_USED` worker choice strategy.
237 - Ensure trimmable characters are checked at pool initialization.
238 - Fix message id integer overflow.
239 - Fix pool worker removal in worker choice strategy internals.
241 ## [2.4.0-0] - 2023-04-03
245 - Add `LESS_BUSY` worker choice strategy.
249 - Optimize worker storage in pool.
250 - Optimize worker alive status check.
251 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
252 - Optimize `LESS_USED` worker choice strategy.
256 - Ensure trimmable characters are checked at pool initialization.
257 - Fix message id integer overflow.
258 - Fix pool worker removal in worker choice strategy internals.
260 ## [2.3.10] - 2023-03-18
264 - Fix `exports` syntax for ESM and CommonJS.
268 - Permit SemVer pre-release publication.
270 ## [2.3.10-2] - 2023-03-18
274 - Fix `exports` syntax for ESM and CommonJS.
276 ## [2.3.10-1] - 2023-03-18
280 - Permit SemVer pre-release publication.
282 ## [2.3.10-0] - 2023-03-18
286 - Fix `exports` syntax for ESM and CommonJS.
288 ## [2.3.9] - 2023-03-18
292 - Introduce ESM module support along with CommonJS one.
296 - Fix brown paper bag bug referencing the same object literal.
298 ## [2.3.8] - 2023-03-18
302 - Switch internal benchmarking code to benny.
303 - Switch to TypeScript 5.x.x.
304 - Switch rollup bundler plugins to core ones.
305 - Switch to TSDoc syntax.
306 - Enforce conventional commits.
310 - Fix random integer generator.
311 - Fix worker choice strategy pool type identification at initialization.
313 ## [2.3.7] - 2022-10-23
317 - Switch to open collective FOSS project funding platform.
318 - Switch to ts-standard linter configuration on TypeScript code.
322 - Fixed missing async on pool execute method.
323 - Fixed typing in TypeScript example.
324 - Fixed types in unit tests.
326 ## [2.3.6] - 2022-10-22
330 - Cleanup pool attributes and methods.
331 - Refine error types thrown.
335 - Fix continuous integration build on windows.
336 - Fix code coverage reporting by using c8 instead of nyc.
338 ## [2.3.5] - 2022-10-21
342 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
343 - Optimize tasks usage lookup implementation.
347 - Fix missed pool event emitter type export.
348 - Fix typedoc documentation generation.
350 ## [2.3.4] - 2022-10-17
354 - Fully automate release process with release-it.
358 - Optimize fair share task scheduling algorithm implementation.
359 - Update benchmarks versus external pools results with latest version.
361 ## [2.3.3] - 2022-10-15
365 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
367 ## [2.3.2] - 2022-10-14
371 - Optimize fair share worker selection strategy implementation.
375 - Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
377 ## [2.3.1] - 2022-10-13
381 - Pool worker choice strategies:
382 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
383 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
385 ## [2.2.2] - 2022-10-09
389 - Fixed `README.md` file.
391 ## [2.2.1] - 2022-10-08
395 - Dynamic worker choice strategy change at runtime.
397 ## [2.2.0] - 2022-01-05
401 - Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
403 ## [2.1.0] - 2021-08-29
407 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
411 - `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
412 - `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
413 - `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
414 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
416 ## [2.0.2] - 2021-05-12
420 - Fix `busy` event emission on fixed pool type
422 ## [2.0.1] - 2021-03-16
426 - Check if pool options are properly set.
427 - `busy` event is emitted on all pool types.
429 ## [2.0.0] - 2021-03-01
433 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
437 - `FullPool` event is now renamed to `busy`.
438 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
439 _Find more details on our JSDoc._
441 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
443 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
445 ### Pool options types declaration merge
447 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
449 #### New `export` strategy
453 const DynamicThreadPool = require('poolifier/lib/dynamic')
455 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
458 But you should always prefer just using
461 const { DynamicThreadPool } = require('poolifier')
464 #### New type definitions for input data and response
466 For cluster worker and worker-thread pools, you can now only send and receive serializable data.
467 _This is not a limitation by poolifier but NodeJS._
469 #### Public property replacements
471 `numWorkers` property is now `numberOfWorkers`
473 #### Internal (protected) properties and methods renaming
475 These properties are not intended for end users
477 - `id` => `nextMessageId`
479 These methods are not intended for end users
481 - `_chooseWorker` => `chooseWorker`
482 - `_newWorker` => `createWorker`
483 - `_execute` => `internalExecute`
484 - `_chooseWorker` => `chooseWorker`
485 - `_checkAlive` => `checkAlive`
487 - `_runAsync` => `runAsync`
489 ## [1.1.0] - 2020-05-21
493 - ThreadWorker support async functions as option
494 - Various external library patches
496 ## [1.0.0] - 2020-01-24
500 - FixedThreadPool implementation
501 - DynamicThreadPool implementation
502 - WorkerThread implementation to improve developer experience