refactor: more object destructuration cleanup in examples
[poolifier.git] / CHANGELOG.md
... / ...
CommitLineData
1# Changelog
2
3All notable changes to this project will be documented in this file.
4
5The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
8## [Unreleased]
9
10### Added
11
12- HTTP server pool examples: express-cluster, express-hybrid.
13
14## [2.6.27] - 2023-08-15
15
16### Fixed
17
18- Add `KillHandler` type definition to exported types.
19
20### Added
21
22- Add `destroy` event to pool API.
23
24## [2.6.26] - 2023-08-15
25
26### Added
27
28- Add kill handler to worker options allowing to execute custom code when worker is killed.
29- Add `listTaskFunctions()` method to pool API.
30- SMTP server pool example: nodemailer.
31
32## [2.6.25] - 2023-08-13
33
34### Added
35
36- HTTP server pool examples: fastify-cluster, fastify-hybrid.
37- WebSocket server pool examples: ws-cluster, ws-hybrid.
38
39## [2.6.24] - 2023-08-12
40
41### Added
42
43- Add array of transferable objects to the `execute()` method arguments.
44- WebSocket server pool examples: ws-worker_threads.
45
46## [2.6.23] - 2023-08-11
47
48### Fixed
49
50- Fix pool busyness semantic when tasks queueing is enabled: the pool is busy when the number of executing tasks on each worker has reached the maximum tasks concurrency per worker.
51
52### Added
53
54- HTTP client pool examples: fetch, node-fetch and axios with multiple task functions.
55- HTTP server pool examples: express-worker_threads, fastify-worker_threads.
56
57## [2.6.22] - 2023-08-10
58
59### Fixed
60
61- Add missing `types` field to package.json `exports`.
62
63### Changed
64
65- Structure markdown documentation (PR #811).
66
67## [2.6.21] - 2023-08-03
68
69### Changed
70
71- Improve code documentation.
72- Code refactoring and cleanup for better maintainability and readability.
73
74## [2.6.20] - 2023-07-21
75
76### Fixed
77
78- Fix queued tasks redistribution on error task execution starvation.
79- Ensure task queueing per worker condition is untangled from the pool busyness semantic.
80
81### Changed
82
83- Drastically reduce lookups by worker in the worker nodes.
84
85## [2.6.19] - 2023-07-20
86
87### Added
88
89- Dedicated internal communication channel for worker_threads pools.
90
91## [2.6.18] - 2023-07-19
92
93### Changed
94
95- Code refactoring and cleanup for better maintainability and readability. Bundle size is a bit smaller.
96
97## [2.6.17] - 2023-07-16
98
99### Added
100
101- Add `listTaskFunctions()` method to worker API.
102
103## [2.6.16] - 2023-07-12
104
105### Fixed
106
107- Fix pool startup detection.
108- Fix worker task functions handling.
109
110## [2.6.15] - 2023-07-11
111
112### Added
113
114- Take into account worker node readiness in worker choice strategies.
115
116## [2.6.14] - 2023-07-10
117
118### Fixed
119
120- Fix task function statistics tracking.
121
122## [2.6.13] - 2023-07-10
123
124### Added
125
126- Add per task function statistics tracking.
127- Add public methods to manipulate the worker task functions at runtime.
128
129## [2.6.12] - 2023-07-09
130
131### Fixed
132
133- Workaround import issue with `node:os` module in node 16.x.x.
134
135## [2.6.11] - 2023-07-09
136
137### Fixed
138
139- Fix pool readiness semantic.
140
141## [2.6.10] - 2023-07-08
142
143### Fixed
144
145- Ensure workers are not recreated on error at pool startup.
146
147### Added
148
149- Add `ready` and `strategy` fields to pool information.
150- Add pool event `ready` to notify when the number of workers created in the pool has reached the maximum size expected and are ready.
151- Add dynamic pool sizing checks.
152
153## [2.6.9] - 2023-07-07
154
155### Fixed
156
157- Recreate the right worker type on uncaught exception.
158
159### Added
160
161- Add minimum and maximum to internal measurement statistics.
162- Add `runTime` and `waitTime` to pool information.
163- Check worker inactive time only on dynamic worker.
164
165## [2.6.8] - 2023-07-03
166
167### Fixed
168
169- Brown paper bag release to fix version handling in pool information.
170
171## [2.6.7] - 2023-07-03
172
173### Fixed
174
175- Ensure worker queued tasks at error are reassigned to other pool workers.
176
177### Added
178
179- Add pool `utilization` ratio to pool information.
180- Add `version` to pool information.
181- Add worker information to worker nodes.
182
183## [2.6.6] - 2023-07-01
184
185### Added
186
187- Add safe helper `availableParallelism` to help sizing the pool.
188
189### Fixed
190
191- Ensure message handler is only registered in worker.
192
193## [2.6.5] - 2023-06-27
194
195### Known issues
196
197- Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
198
199### Fixed
200
201- Artificial version bump to 2.6.5 to workaround publication issue.
202- Ensure cluster pool destroy() gracefully shutdowns worker's server.
203- Ensure pool event is emitted before task error promise rejection.
204- Fix queued tasks count computation.
205
206### Removed
207
208- Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
209
210## [2.6.4] - 2023-06-27
211
212### Known issues
213
214- Cluster pools tasks execution are not working by using ESM files extension: https://github.com/poolifier/poolifier/issues/782
215
216### Fixed
217
218- Ensure cluster pool destroy() gracefully shutdowns worker's server.
219- Ensure pool event is emitted before task error promise rejection.
220- Fix queued tasks count computation.
221
222### Removed
223
224- Remove unneeded worker_threads worker `MessageChannel` internal usage for IPC.
225
226## [2.6.3] - 2023-06-19
227
228### Fixed
229
230- Ensure no tasks are queued when trying to soft kill a dynamic worker.
231- Update strategies internals after statistics computation.
232
233### Changed
234
235- Optimize O(1) queue implementation.
236
237## [2.6.2] - 2023-06-12
238
239### Fixed
240
241- Fix new worker use after creation in dynamic pool given the current worker choice strategy.
242
243## [2.6.1] - 2023-06-10
244
245### Added
246
247- Add worker choice strategy documentation: [README.md](./docs/worker-choice-strategies.md).
248
249### Fixed
250
251- Fix average statistics computation: ensure failed tasks are not accounted.
252
253## [2.6.0] - 2023-06-09
254
255### Added
256
257- Add `LEAST_ELU` worker choice strategy (experimental).
258- Add tasks ELU instead of runtime support to `FAIR_SHARE` worker choice strategy.
259
260### Changed
261
262- Refactor pool worker node usage internals.
263- Breaking change: refactor worker choice strategy statistics requirements: the syntax of the worker choice strategy options has changed.
264- Breaking change: pool information `info` property object fields have been renamed.
265
266### Fixed
267
268- Fix wait time accounting.
269- Ensure worker choice strategy `LEAST_BUSY` accounts also tasks wait time.
270- Ensure worker choice strategy `LEAST_USED` accounts also queued tasks.
271
272## [2.5.4] - 2023-06-07
273
274### Added
275
276- Add Event Loop Utilization (ELU) statistics to worker tasks usage.
277
278### Changed
279
280- Compute statistics at the worker level only if needed.
281- Add `worker_threads` options to thread pool options.
282
283### Fixed
284
285- Make the `LEAST_BUSY` strategy only relies on task runtime.
286
287## [2.5.3] - 2023-06-04
288
289### Changed
290
291- Refine pool information content.
292- Limit pool internals public exposure.
293
294## [2.5.2] - 2023-06-02
295
296### Added
297
298- Add `taskError` pool event for task execution error.
299- Add pool information `info` property to pool.
300- Emit pool information on `busy` and `full` pool events.
301
302## [2.5.1] - 2023-06-01
303
304### Added
305
306- Add pool option `restartWorkerOnError` to restart worker on uncaught error. Default to `true`.
307- Add `error` pool event for uncaught worker error.
308
309## [2.5.0] - 2023-05-31
310
311### Added
312
313- Switch pool event emitter to `EventEmitterAsyncResource`.
314- Add tasks wait time accounting in per worker tasks usage.
315- Add interleaved weighted round robin `INTERLEAVED_WEIGHTED_ROUND_ROBIN` worker choice strategy (experimental).
316
317### Changed
318
319- Renamed worker choice strategy `LESS_BUSY` to `LEAST_BUSY` and `LESS_USED` to `LEAST_USED`.
320
321## [2.4.14] - 2023-05-09
322
323### Fixed
324
325- Ensure no undefined task runtime can land in the tasks history.
326- Fix median computation implementation once again.
327
328### Added
329
330- Unit tests for median and queue implementations.
331
332## [2.4.13] - 2023-05-08
333
334### Fixed
335
336- Fix worker choice strategy options validation.
337- Fix fair share worker choice strategy internals update: ensure virtual task end timestamp is computed at task submission.
338
339## [2.4.12] - 2023-05-06
340
341### Added
342
343- Support multiple task functions per worker.
344- Add custom worker weights support to worker choice strategies options.
345
346### Changed
347
348- Use O(1) queue implementation for tasks queueing.
349
350### Fixed
351
352- Fix median computation implementation.
353- Fix fair share worker choice strategy internals update.
354
355## [2.4.11] - 2023-04-23
356
357### Changed
358
359- Optimize free worker finding in worker choice strategies.
360
361## [2.4.10] - 2023-04-15
362
363### Fixed
364
365- Fix typescript type definition for task function: ensure the input data is optional.
366- Fix typescript type definition for pool execute(): ensure the input data is optional.
367
368## [2.4.9] - 2023-04-15
369
370### Added
371
372- Add tasks queue enablement runtime setter to pool.
373- Add tasks queue options runtime setter to pool.
374- Add worker choice strategy options runtime setter to pool.
375
376### Changed
377
378- Remove the tasks queuing experimental status.
379
380### Fixed
381
382- Fix task function type definition and validation.
383- Fix worker choice strategy options handling.
384
385## [2.4.8] - 2023-04-12
386
387### Fixed
388
389- Fix message between main worker and worker type definition for tasks.
390- Fix code documentation.
391
392## [2.4.7] - 2023-04-11
393
394### Added
395
396- Add worker tasks queue options to pool options.
397
398### Fixed
399
400- Fix missing documentation.
401
402## [2.4.6] - 2023-04-10
403
404### Fixed
405
406- Ensure one task at a time is executed per worker with tasks queueing enabled.
407- Properly count worker executing tasks with tasks queueing enabled.
408
409## [2.4.5] - 2023-04-09
410
411### Added
412
413- Use monotonic high resolution timer for worker tasks runtime.
414- Add worker tasks median runtime to statistics.
415- Add worker tasks queue (experimental).
416
417## [2.4.4] - 2023-04-07
418
419### Added
420
421- Add `PoolEvents` enumeration and `PoolEvent` type.
422
423### Fixed
424
425- Destroy worker only on alive check.
426
427## [2.4.3] - 2023-04-07
428
429### Fixed
430
431- Fix typedoc generation with inheritance.
432
433## [2.4.2] - 2023-04-06
434
435### Added
436
437- Add `full` event to dynamic pool.
438- Keep worker choice strategy in memory for conditional reuse.
439
440### Fixed
441
442- Fix possible negative worker key at worker removal in worker choice strategies.
443
444## [2.4.1] - 2023-04-05
445
446### Changed
447
448- Optimize worker choice strategy for dynamic pool.
449
450### Fixed
451
452- Ensure dynamic pool does not alter worker choice strategy expected behavior.
453
454## [2.4.0] - 2023-04-04
455
456### Added
457
458- Add `LESS_BUSY` worker choice strategy.
459
460### Changed
461
462- Optimize worker storage in pool.
463- Optimize worker alive status check.
464- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
465- Optimize `LESS_USED` worker choice strategy.
466- Update benchmarks versus external threads pools.
467- Optimize tasks usage statistics requirements for worker choice strategy.
468
469### Fixed
470
471- Ensure trimmable characters are checked at pool initialization.
472- Fix message id integer overflow.
473- Fix pool worker removal in worker choice strategy internals.
474- Fix package publication with pnpm.
475
476## [2.4.0-3] - 2023-04-04
477
478### Added
479
480- Add `LESS_BUSY` worker choice strategy.
481
482### Changed
483
484- Optimize worker storage in pool.
485- Optimize worker alive status check.
486- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
487- Optimize `LESS_USED` worker choice strategy.
488- Update benchmarks versus external threads pools.
489
490### Fixed
491
492- Ensure trimmable characters are checked at pool initialization.
493- Fix message id integer overflow.
494- Fix pool worker removal in worker choice strategy internals.
495- Fix package publication with pnpm.
496
497## [2.4.0-2] - 2023-04-03
498
499### Added
500
501- Add `LESS_BUSY` worker choice strategy.
502
503### Changed
504
505- Optimize worker storage in pool.
506- Optimize worker alive status check.
507- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
508- Optimize `LESS_USED` worker choice strategy.
509
510### Fixed
511
512- Ensure trimmable characters are checked at pool initialization.
513- Fix message id integer overflow.
514- Fix pool worker removal in worker choice strategy internals.
515- Fix package publication with pnpm.
516
517## [2.4.0-1] - 2023-04-03
518
519### Added
520
521- Add `LESS_BUSY` worker choice strategy.
522
523### Changed
524
525- Optimize worker storage in pool.
526- Optimize worker alive status check.
527- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
528- Optimize `LESS_USED` worker choice strategy.
529
530### Fixed
531
532- Ensure trimmable characters are checked at pool initialization.
533- Fix message id integer overflow.
534- Fix pool worker removal in worker choice strategy internals.
535
536## [2.4.0-0] - 2023-04-03
537
538### Added
539
540- Add `LESS_BUSY` worker choice strategy.
541
542### Changed
543
544- Optimize worker storage in pool.
545- Optimize worker alive status check.
546- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
547- Optimize `LESS_USED` worker choice strategy.
548
549### Fixed
550
551- Ensure trimmable characters are checked at pool initialization.
552- Fix message id integer overflow.
553- Fix pool worker removal in worker choice strategy internals.
554
555## [2.3.10] - 2023-03-18
556
557### Fixed
558
559- Fix package.json `exports` syntax for ESM and CommonJS.
560
561### Changed
562
563- Permit SemVer pre-release publication.
564
565## [2.3.10-2] - 2023-03-18
566
567### Fixed
568
569- Fix package.json `exports` syntax for ESM and CommonJS.
570
571## [2.3.10-1] - 2023-03-18
572
573### Changed
574
575- Permit SemVer pre-release publication.
576
577## [2.3.10-0] - 2023-03-18
578
579### Fixed
580
581- Fix package.json `exports` syntax for ESM and CommonJS.
582
583## [2.3.9] - 2023-03-18
584
585### Changed
586
587- Introduce ESM module support along with CommonJS one.
588
589### Fixed
590
591- Fix brown paper bag bug referencing the same object literal.
592
593## [2.3.8] - 2023-03-18
594
595### Changed
596
597- Switch internal benchmarking code to benny.
598- Switch to TypeScript 5.x.x.
599- Switch rollup bundler plugins to core ones.
600- Switch to TSDoc syntax.
601- Enforce conventional commits.
602
603### Fixed
604
605- Fix random integer generator.
606- Fix worker choice strategy pool type identification at initialization.
607
608## [2.3.7] - 2022-10-23
609
610### Changed
611
612- Switch to open collective FOSS project funding platform.
613- Switch to ts-standard linter configuration on TypeScript code.
614
615### Fixed
616
617- Fixed missing async on pool execute method.
618- Fixed typing in TypeScript example.
619- Fixed types in unit tests.
620
621## [2.3.6] - 2022-10-22
622
623### Changed
624
625- Cleanup pool attributes and methods.
626- Refine error types thrown.
627
628### Fixed
629
630- Fix continuous integration build on windows.
631- Fix code coverage reporting by using c8 instead of nyc.
632
633## [2.3.5] - 2022-10-21
634
635### Changed
636
637- Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
638- Optimize tasks usage lookup implementation.
639
640### Fixed
641
642- Fix missed pool event emitter type export.
643- Fix typedoc documentation generation.
644
645## [2.3.4] - 2022-10-17
646
647### Added
648
649- Fully automate release process with release-it.
650
651### Changed
652
653- Optimize fair share task scheduling algorithm implementation.
654- Update benchmarks versus external pools results with latest version.
655
656## [2.3.3] - 2022-10-15
657
658### Added
659
660- Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
661
662## [2.3.2] - 2022-10-14
663
664### Changed
665
666- Optimize fair share worker selection strategy implementation.
667
668### Fixed
669
670- Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
671
672## [2.3.1] - 2022-10-13
673
674### Added
675
676- Pool worker choice strategies:
677 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
678 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
679
680## [2.2.2] - 2022-10-09
681
682### Fixed
683
684- Fixed `README.md` file.
685
686## [2.2.1] - 2022-10-08
687
688### Added
689
690- Dynamic worker choice strategy change at runtime.
691
692## [2.2.0] - 2022-01-05
693
694### Breaking Changes
695
696- Support only Node.js version 16.x.x for cluster pool: upstream cluster API have changed on that version.
697
698## [2.1.0] - 2021-08-29
699
700### Added
701
702- Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
703
704### Breaking Changes
705
706- `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
707- `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
708- `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
709- `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
710
711## [2.0.2] - 2021-05-12
712
713### Bug fixes
714
715- Fix `busy` event emission on fixed pool type
716
717## [2.0.1] - 2021-03-16
718
719### Bug fixes
720
721- Check if pool options are properly set.
722- `busy` event is emitted on all pool types.
723
724## [2.0.0] - 2021-03-01
725
726### Bug fixes
727
728- Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
729
730### Breaking Changes
731
732- `FullPool` event is now renamed to `busy`.
733- `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
734 _Find more details on our JSDoc._
735
736- `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
737
738- We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
739
740### Pool options types declaration merge
741
742`FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
743
744#### New `export` strategy
745
746```js
747// Before
748const DynamicThreadPool = require('poolifier/lib/dynamic')
749// After
750const { DynamicThreadPool } = require('poolifier/lib/dynamic')
751```
752
753But you should always prefer just using
754
755```js
756const { DynamicThreadPool } = require('poolifier')
757```
758
759#### New type definitions for input data and response
760
761For cluster worker and worker-thread pools, you can now only send and receive structured-cloneable data.
762_This is not a limitation by poolifier but Node.js._
763
764#### Public property replacements
765
766`numWorkers` property is now `numberOfWorkers`
767
768#### Internal (protected) properties and methods renaming
769
770These properties are not intended for end users
771
772- `id` => `nextMessageId`
773
774These methods are not intended for end users
775
776- `_chooseWorker` => `chooseWorker`
777- `_newWorker` => `createWorker`
778- `_execute` => `internalExecute`
779- `_chooseWorker` => `chooseWorker`
780- `_checkAlive` => `checkAlive`
781- `_run` => `run`
782- `_runAsync` => `runAsync`
783
784## [1.1.0] - 2020-05-21
785
786### Added
787
788- ThreadWorker support async functions as option
789- Various external library patches
790
791## [1.0.0] - 2020-01-24
792
793### Added
794
795- FixedThreadPool implementation
796- DynamicThreadPool implementation
797- WorkerThread implementation to improve developer experience