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