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