refactor: add type aliases for worker function
[poolifier.git] / CHANGELOG.md
1 # Changelog
2
3 All notable changes to this project will be documented in this file.
4
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).
7
8 ## [Unreleased]
9
10 ## [2.4.9] - 2023-04-15
11
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
22 ### Fixed
23
24 - Fix worker function type definition and validation.
25 - Fix worker choice strategy options handling.
26
27 ## [2.4.8] - 2023-04-12
28
29 ### Fixed
30
31 - Fix message between main worker and worker type definition for tasks.
32 - Fix code documentation.
33
34 ## [2.4.7] - 2023-04-11
35
36 ### Added
37
38 - Add worker tasks queue options to pool options.
39
40 ### Fixed
41
42 - Fix missing documentation.
43
44 ## [2.4.6] - 2023-04-10
45
46 ### Fixed
47
48 - Ensure one task at a time is executed per worker with tasks queueing enabled.
49 - Properly count worker running tasks with tasks queueing enabled.
50
51 ## [2.4.5] - 2023-04-09
52
53 ### Added
54
55 - Use monotonic high resolution timer for worker tasks run time.
56 - Add worker tasks median run time to statistics.
57 - Add worker tasks queue (experimental).
58
59 ## [2.4.4] - 2023-04-07
60
61 ### Added
62
63 - Add `PoolEvents` enumeration and `PoolEvent` type.
64
65 ### Fixed
66
67 - Destroy worker only on alive check.
68
69 ## [2.4.3] - 2023-04-07
70
71 ### Fixed
72
73 - Fix typedoc generation with inheritance.
74
75 ## [2.4.2] - 2023-04-06
76
77 ### Added
78
79 - Add `full` event to dynamic pool.
80 - Keep worker choice strategy in memory for conditional reuse.
81
82 ### Fixed
83
84 - Fix possible negative worker key at worker removal in worker choice strategies.
85
86 ## [2.4.1] - 2023-04-05
87
88 ### Changed
89
90 - Optimize worker choice strategy for dynamic pool.
91
92 ### Fixed
93
94 - Ensure dynamic pool does not alter worker choice strategy expected behavior.
95
96 ## [2.4.0] - 2023-04-04
97
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
118 ## [2.4.0-3] - 2023-04-04
119
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
139 ## [2.4.0-2] - 2023-04-03
140
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
159 ## [2.4.0-1] - 2023-04-03
160
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
178 ## [2.4.0-0] - 2023-04-03
179
180 ### Added
181
182 - Add `LESS_BUSY` worker choice strategy.
183
184 ### Changed
185
186 - Optimize worker storage in pool.
187 - Optimize worker alive status check.
188 - BREAKING CHANGE: Rename worker choice strategy `LESS_RECENTLY_USED` to `LESS_USED`.
189 - Optimize `LESS_USED` worker choice strategy.
190
191 ### Fixed
192
193 - Ensure trimmable characters are checked at pool initialization.
194 - Fix message id integer overflow.
195 - Fix pool worker removal in worker choice strategy internals.
196
197 ## [2.3.10] - 2023-03-18
198
199 ### Fixed
200
201 - Fix `exports` syntax for ESM and CommonJS.
202
203 ### Changed
204
205 - Permit SemVer pre-release publication.
206
207 ## [2.3.10-2] - 2023-03-18
208
209 ### Fixed
210
211 - Fix `exports` syntax for ESM and CommonJS.
212
213 ## [2.3.10-1] - 2023-03-18
214
215 ### Changed
216
217 - Permit SemVer pre-release publication.
218
219 ## [2.3.10-0] - 2023-03-18
220
221 ### Fixed
222
223 - Fix `exports` syntax for ESM and CommonJS.
224
225 ## [2.3.9] - 2023-03-18
226
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
235 ## [2.3.8] - 2023-03-18
236
237 ### Changed
238
239 - Switch internal benchmarking code to benny.
240 - Switch to TypeScript 5.x.x.
241 - Switch rollup bundler plugins to core ones.
242 - Switch to TSDoc syntax.
243 - Enforce conventional commits.
244
245 ### Fixed
246
247 - Fix random integer generator.
248 - Fix worker choice strategy pool type identification at initialization.
249
250 ## [2.3.7] - 2022-10-23
251
252 ### Changed
253
254 - Switch to open collective FOSS project funding platform.
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.
262
263 ## [2.3.6] - 2022-10-22
264
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
275 ## [2.3.5] - 2022-10-21
276
277 ### Changed
278
279 - Improve benchmarks: add IO intensive task workload, add task size option, integrate code into linter.
280 - Optimize tasks usage lookup implementation.
281
282 ### Fixed
283
284 - Fix missed pool event emitter type export.
285 - Fix typedoc documentation generation.
286
287 ## [2.3.4] - 2022-10-17
288
289 ### Added
290
291 - Fully automate release process with release-it.
292
293 ### Changed
294
295 - Optimize fair share task scheduling algorithm implementation.
296 - Update benchmarks versus external pools results with latest version.
297
298 ## [2.3.3] - 2022-10-15
299
300 ### Added
301
302 - Add support for [cluster settings](https://nodejs.org/api/cluster.html#cluster_cluster_settings) in cluster pool options.
303
304 ## [2.3.2] - 2022-10-14
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
314 ## [2.3.1] - 2022-10-13
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
322 ## [2.2.2] - 2022-10-09
323
324 ### Fixed
325
326 - Fixed `README.md` file.
327
328 ## [2.2.1] - 2022-10-08
329
330 ### Added
331
332 - Dynamic worker choice strategy change at runtime.
333
334 ## [2.2.0] - 2022-01-05
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
340 ## [2.1.0] - 2021-08-29
341
342 ### Added
343
344 - Add an optional pool option `messageHandler` to `PoolOptions<Worker>` for registering a message handler callback on each worker.
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`.
351 - `AbstractWorker` class cannot be instantiated without specifying the `mainWorker` argument referencing the main worker.
352
353 ## [2.0.2] - 2021-05-12
354
355 ### Bug fixes
356
357 - Fix `busy` event emission on fixed pool type
358
359 ## [2.0.1] - 2021-03-16
360
361 ### Bug fixes
362
363 - Check if pool options are properly set.
364 - `busy` event is emitted on all pool types.
365
366 ## [2.0.0] - 2021-03-01
367
368 ### Bug fixes
369
370 - Now a thread/process by default is not deleted when the task submitted take more time than maxInactiveTime configured (issue #70).
371
372 ### Breaking Changes
373
374 - `FullPool` event is now renamed to `busy`.
375 - `maxInactiveTime` on `ThreadWorker` default behavior is now changed, if you want to keep the old behavior set `killBehavior` to `KillBehaviors.HARD`.
376 _Find more details on our JSDoc._
377
378 - `maxTasks` option on `FixedThreadPool` and `DynamicThreadPool` is now removed since is no more needed.
379
380 - We changed some internal structures, but you shouldn't be too affected by them as these are internal changes.
381
382 ### Pool options types declaration merge
383
384 `FixedThreadPoolOptions` and `DynamicThreadPoolOptions` type declarations have been merged to `PoolOptions<Worker>`.
385
386 #### New `export` strategy
387
388 ```js
389 // Before
390 const DynamicThreadPool = require('poolifier/lib/dynamic')
391 // After
392 const { DynamicThreadPool } = require('poolifier/lib/dynamic')
393 ```
394
395 But you should always prefer just using
396
397 ```js
398 const { DynamicThreadPool } = require('poolifier')
399 ```
400
401 #### New type definitions for input data and response
402
403 For cluster worker and worker-thread pools, you can now only send and receive serializable data.
404 _This is not a limitation by poolifier but NodeJS._
405
406 #### Public property replacements
407
408 `numWorkers` property is now `numberOfWorkers`
409
410 #### Internal (protected) properties and methods renaming
411
412 These properties are not intended for end users
413
414 - `id` => `nextMessageId`
415
416 These methods are not intended for end users
417
418 - `_chooseWorker` => `chooseWorker`
419 - `_newWorker` => `createWorker`
420 - `_execute` => `internalExecute`
421 - `_chooseWorker` => `chooseWorker`
422 - `_checkAlive` => `checkAlive`
423 - `_run` => `run`
424 - `_runAsync` => `runAsync`
425
426 ## [1.1.0] - 2020-05-21
427
428 ### Added
429
430 - ThreadWorker support async functions as option
431 - Various external library patches
432
433 ## [1.0.0] - 2020-01-24
434
435 ### Added
436
437 - FixedThreadPool implementation
438 - DynamicThreadPool implementation
439 - WorkerThread implementation to improve developer experience