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