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