feat: support multiple functions per worker
[poolifier.git] / CHANGELOG.md
CommitLineData
522eea03 1# Changelog
2
3All notable changes to this project will be documented in this file.
4
d4abc60a 5The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
522eea03 6and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
45a5a54c
JB
8## [Unreleased]
9
a86b6df1
JB
10### Added
11
12- Support multiple task functions per worker.
13
936d53ec
JB
14## [2.4.11] - 2023-04-23
15
cb70b19d
JB
16### Changed
17
18- Optimize free worker finding in worker choice strategies.
19
15bb637a
JB
20## [2.4.10] - 2023-04-15
21
ef41a6e6
JB
22### Fixed
23
24- Fix typescript type definition for worker function: ensure the input data is optional.
25- Fix typescript type definition for pool execute(): ensure the input data is optional.
26
181eb2b4
JB
27## [2.4.9] - 2023-04-15
28
a20f0ba5
JB
29### Added
30
31- Add tasks queue enablement runtime setter to pool.
32- Add tasks queue options runtime setter to pool.
33- Add worker choice strategy options runtime setter to pool.
34
35### Changed
36
37- Remove the tasks queuing experimental status.
38
d4aeae5a
JB
39### Fixed
40
41- Fix worker function type definition and validation.
2fc5cae3 42- Fix worker choice strategy options handling.
d4aeae5a 43
1d9e7023
JB
44## [2.4.8] - 2023-04-12
45
f9b4bbf8
JB
46### Fixed
47
48- Fix message between main worker and worker type definition for tasks.
49- Fix code documentation.
50
12ae3210
JB
51## [2.4.7] - 2023-04-11
52
7171d33f
JB
53### Added
54
55- Add worker tasks queue options to pool options.
56
e8bd29ce
JB
57### Fixed
58
59- Fix missing documentation.
60
42c7bc10
JB
61## [2.4.6] - 2023-04-10
62
681196cc
JB
63### Fixed
64
65- Ensure one task at a time is executed per worker with tasks queueing enabled.
76545787 66- Properly count worker running tasks with tasks queueing enabled.
681196cc 67
54d360e3
JB
68## [2.4.5] - 2023-04-09
69
3fafb1b2
JB
70### Added
71
72- Use monotonic high resolution timer for worker tasks run time.
73- Add worker tasks median run time to statistics.
ff733df7 74- Add worker tasks queue (experimental).
3fafb1b2 75
92fa3eb6
JB
76## [2.4.4] - 2023-04-07
77
aee46736
JB
78### Added
79
80- Add `PoolEvents` enumeration and `PoolEvent` type.
81
36b5e78f
JB
82### Fixed
83
ff0c2b3e 84- Destroy worker only on alive check.
36b5e78f 85
9fb0f324
JB
86## [2.4.3] - 2023-04-07
87
28cf3617
JB
88### Fixed
89
90- Fix typedoc generation with inheritance.
91
848f0f27
JB
92## [2.4.2] - 2023-04-06
93
164d950a
JB
94### Added
95
96- Add `full` event to dynamic pool.
32417142 97- Keep worker choice strategy in memory for conditional reuse.
164d950a 98
78ab2555
JB
99### Fixed
100
101- Fix possible negative worker key at worker removal in worker choice strategies.
102
79aafe9f
JB
103## [2.4.1] - 2023-04-05
104
9cd39dd4
JB
105### Changed
106
107- Optimize worker choice strategy for dynamic pool.
108
965415bb
JB
109### Fixed
110
111- Ensure dynamic pool does not alter worker choice strategy expected behavior.
112
d8b60b1c
JB
113## [2.4.0] - 2023-04-04
114
c6bd2650
JB
115### Added
116
117- Add `LESS_BUSY` worker choice strategy.
118
119### Changed
120
121- Optimize worker storage in pool.
122- Optimize worker alive status check.
123- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
124- Optimize `LESS_USED` worker choice strategy.
125- Update benchmarks versus external threads pools.
126- Optimize tasks usage statistics requirements for worker choice strategy.
127
128### Fixed
129
130- Ensure trimmable characters are checked at pool initialization.
131- Fix message id integer overflow.
132- Fix pool worker removal in worker choice strategy internals.
133- Fix package publication with pnpm.
134
d0a3f018
JB
135## [2.4.0-3] - 2023-04-04
136
b2ede285
JB
137### Added
138
139- Add `LESS_BUSY` worker choice strategy.
140
141### Changed
142
143- Optimize worker storage in pool.
144- Optimize worker alive status check.
145- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
146- Optimize `LESS_USED` worker choice strategy.
147- Update benchmarks versus external threads pools.
148
149### Fixed
150
151- Ensure trimmable characters are checked at pool initialization.
152- Fix message id integer overflow.
153- Fix pool worker removal in worker choice strategy internals.
154- Fix package publication with pnpm.
155
a015ea40
JB
156## [2.4.0-2] - 2023-04-03
157
698f4bbc
JB
158### Added
159
160- Add `LESS_BUSY` worker choice strategy.
161
162### Changed
163
164- Optimize worker storage in pool.
165- Optimize worker alive status check.
166- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
167- Optimize `LESS_USED` worker choice strategy.
168
169### Fixed
170
171- Ensure trimmable characters are checked at pool initialization.
172- Fix message id integer overflow.
173- Fix pool worker removal in worker choice strategy internals.
174- Fix package publication with pnpm.
175
8fe15920
JB
176## [2.4.0-1] - 2023-04-03
177
5b301c28
JB
178### Added
179
180- Add `LESS_BUSY` worker choice strategy.
181
182### Changed
183
184- Optimize worker storage in pool.
185- Optimize worker alive status check.
186- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
187- Optimize `LESS_USED` worker choice strategy.
188
189### Fixed
190
191- Ensure trimmable characters are checked at pool initialization.
192- Fix message id integer overflow.
193- Fix pool worker removal in worker choice strategy internals.
194
2fb9ca9c
JB
195## [2.4.0-0] - 2023-04-03
196
168c526f
JB
197### Added
198
199- Add `LESS_BUSY` worker choice strategy.
200
1d71a908
JB
201### Changed
202
ffcbbad8 203- Optimize worker storage in pool.
1d71a908 204- Optimize worker alive status check.
65a60b3b 205- BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
737c6d97 206- Optimize `LESS_USED` worker choice strategy.
1d71a908 207
ffcbbad8
JB
208### Fixed
209
210- Ensure trimmable characters are checked at pool initialization.
b4e75778 211- Fix message id integer overflow.
97a2abc3 212- Fix pool worker removal in worker choice strategy internals.
ffcbbad8 213
08372738
JB
214## [2.3.10] - 2023-03-18
215
710826bc
JB
216### Fixed
217
218- Fix `exports` syntax for ESM and CommonJS.
219
220### Changed
221
222- Permit SemVer pre-release publication.
76e5ac6f 223
e4796ecd
JB
224## [2.3.10-2] - 2023-03-18
225
6abad580
JB
226### Fixed
227
228- Fix `exports` syntax for ESM and CommonJS.
229
a2ee98cc
JB
230## [2.3.10-1] - 2023-03-18
231
7e060cee
JB
232### Changed
233
90483887 234- Permit SemVer pre-release publication.
7e060cee 235
c81bfafb
JB
236## [2.3.10-0] - 2023-03-18
237
fe18768d
JB
238### Fixed
239
240- Fix `exports` syntax for ESM and CommonJS.
241
d7b78217
JB
242## [2.3.9] - 2023-03-18
243
ed6dd37f
JB
244### Changed
245
246- Introduce ESM module support along with CommonJS one.
247
248### Fixed
249
250- Fix brown paper bag bug referencing the same object literal.
251
68e2ad86
JB
252## [2.3.8] - 2023-03-18
253
ca6c7d70
JB
254### Changed
255
256- Switch internal benchmarking code to benny.
fbdedeb9
JB
257- Switch to TypeScript 5.x.x.
258- Switch rollup bundler plugins to core ones.
ed6dd37f 259- Switch to TSDoc syntax.
fbdedeb9 260- Enforce conventional commits.
ca6c7d70 261
d15211d4
JB
262### Fixed
263
264- Fix random integer generator.
fbdedeb9 265- Fix worker choice strategy pool type identification at initialization.
d15211d4 266
995705ea
JB
267## [2.3.7] - 2022-10-23
268
b953022b
JB
269### Changed
270
271- Switch to open collective FOSS project funding platform.
78cea37e
JB
272- Switch to ts-standard linter configuration on TypeScript code.
273
274### Fixed
275
276- Fixed missing async on pool execute method.
277- Fixed typing in TypeScript example.
278- Fixed types in unit tests.
b953022b 279
3b9f6953
JB
280## [2.3.6] - 2022-10-22
281
f80cead4
JB
282### Changed
283
284- Cleanup pool attributes and methods.
285- Refine error types thrown.
286
287### Fixed
288
289- Fix continuous integration build on windows.
290- Fix code coverage reporting by using c8 instead of nyc.
291
efc22107
JB
292## [2.3.5] - 2022-10-21
293
7a6a0a96
JB
294### Changed
295
a05c10de
JB
296- Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
297- Optimize tasks usage lookup implementation.
7a6a0a96 298
b4904890
JB
299### Fixed
300
301- Fix missed pool event emitter type export.
302- Fix typedoc documentation generation.
303
a875f8d1
JB
304## [2.3.4] - 2022-10-17
305
73cda448
JB
306### Added
307
308- Fully automate release process with release-it.
309
45a5a54c
JB
310### Changed
311
73cda448 312- Optimize fair share task scheduling algorithm implementation.
eb4a8a82 313- Update benchmarks versus external pools results with latest version.
45a5a54c 314
90ee1b18 315## [2.3.3] - 2022-10-15
1a76932b
JB
316
317### Added
318
319- Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
320
90ee1b18 321## [2.3.2] - 2022-10-14
11df3590
JB
322
323### Changed
324
325- Optimize fair share worker selection strategy implementation.
326
327### Fixed
328
329- Fix WRR worker selection strategy: ensure the condition triggering the round robin can be fulfilled.
330
90ee1b18 331## [2.3.1] - 2022-10-13
23ff945a
JB
332
333### Added
334
335- Pool worker choice strategies:
336 - `WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN` strategy based on weighted round robin scheduling algorithm using tasks execution time for now.
337 - `WorkerChoiceStrategies.FAIR_SHARE` strategy based on fair share scheduling algorithm using tasks execution time for now.
338
90ee1b18 339## [2.2.2] - 2022-10-09
cb2b6c69
JB
340
341### Fixed
342
343- Fixed `README.md` file.
344
90ee1b18 345## [2.2.1] - 2022-10-08
bdacc2d2 346
bdaf31cd
JB
347### Added
348
349- Dynamic worker choice strategy change at runtime.
bdacc2d2 350
90ee1b18 351## [2.2.0] - 2022-01-05
7e0d447f
JB
352
353### Breaking Changes
354
355- Support only NodeJS version 16.x.x for cluster pool: upstream cluster API have changed on that version.
356
90ee1b18 357## [2.1.0] - 2021-08-29
35cf1c03
JB
358
359### Added
360
361- Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
e088a00c
JB
362
363### Breaking Changes
364
365- `AbstractWorker` class `maxInactiveTime`, `killBehavior` and `async` attributes have been removed in favour of the same ones in the worker options `opts` public attribute.
366- `AbstractWorker` class `lastTask` attribute have been renamed to `lastTaskTimestamp`.
367- `AbstractWorker` class `interval` attribute have been renamed to `aliveInterval`.
c365b2d3 368- `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
e088a00c 369
90ee1b18 370## [2.0.2] - 2021-05-12
14916bf9
JB
371
372### Bug fixes
373
374- Fix `busy` event emission on fixed pool type
375
90ee1b18 376## [2.0.1] - 2021-03-16
7f685093
JB
377
378### Bug fixes
379
380- Check if pool options are properly set.
381- `busy` event is emitted on all pool types.
382
90ee1b18 383## [2.0.0] - 2021-03-01
fa0f5b28 384
f3f833ab 385### Bug fixes
d63d3be3 386
ddbeaffd 387- Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
d63d3be3 388
fa0f5b28
S
389### Breaking Changes
390
7f685093 391- `FullPool` event is now renamed to `busy`.
1927ee67 392- `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
1a81f8af 393 _Find more details on our JSDoc._
ddbeaffd 394
1927ee67
APA
395- `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
396
ddbeaffd 397- We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
fa0f5b28 398
ec2ccfc8
JB
399### Pool options types declaration merge
400
401`FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
402
fa0f5b28
S
403#### New `export` strategy
404
405```js
406// Before
777b7824 407const DynamicThreadPool = require('poolifier/lib/dynamic')
fa0f5b28 408// After
777b7824 409const { DynamicThreadPool } = require('poolifier/lib/dynamic')
fa0f5b28
S
410```
411
412But you should always prefer just using
413
414```js
777b7824 415const { DynamicThreadPool } = require('poolifier')
fa0f5b28
S
416```
417
d3c8a1a8
S
418#### New type definitions for input data and response
419
ec2ccfc8 420For cluster worker and worker-thread pools, you can now only send and receive serializable data.
d3c8a1a8
S
421_This is not a limitation by poolifier but NodeJS._
422
3a4b605f 423#### Public property replacements
5c5a1fb7 424
3a4b605f 425`numWorkers` property is now `numberOfWorkers`
5c5a1fb7 426
280c2a77 427#### Internal (protected) properties and methods renaming
fa0f5b28 428
280c2a77
S
429These properties are not intended for end users
430
431- `id` => `nextMessageId`
432
433These methods are not intended for end users
fa0f5b28
S
434
435- `_chooseWorker` => `chooseWorker`
280c2a77 436- `_newWorker` => `createWorker`
fa0f5b28
S
437- `_execute` => `internalExecute`
438- `_chooseWorker` => `chooseWorker`
439- `_checkAlive` => `checkAlive`
440- `_run` => `run`
441- `_runAsync` => `runAsync`
442
90ee1b18 443## [1.1.0] - 2020-05-21
0312f71a
APA
444
445### Added
446
447- ThreadWorker support async functions as option
cf9aa6c3 448- Various external library patches
0312f71a 449
90ee1b18 450## [1.0.0] - 2020-01-24
522eea03 451
452### Added
453
454- FixedThreadPool implementation
455- DynamicThreadPool implementation
0312f71a 456- WorkerThread implementation to improve developer experience