@travetto/worker 5.0.16 → 5.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +3 -3
- package/src/pool.ts +1 -2
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ yarn add @travetto/worker
|
|
|
16
16
|
This module provides the necessary primitives for handling dependent workers. A worker can be an individual actor or could be a pool of workers. Node provides ipc (inter-process communication) functionality out of the box. This module builds upon that by providing enhanced event management, richer process management, as well as constructs for orchestrating a conversation between two processes.
|
|
17
17
|
|
|
18
18
|
## Execution Pools
|
|
19
|
-
With respect to managing multiple executions, [WorkPool](https://github.com/travetto/travetto/tree/main/module/worker/src/pool.ts#
|
|
19
|
+
With respect to managing multiple executions, [WorkPool](https://github.com/travetto/travetto/tree/main/module/worker/src/pool.ts#L34) is provided to allow for concurrent operation, and processing of jobs concurrently. To manage the flow of jobs, [AsyncQueue](https://github.com/travetto/travetto/tree/main/module/runtime/src/queue.ts#L6) is used to support a wide range of use cases. [AsyncQueue](https://github.com/travetto/travetto/tree/main/module/runtime/src/queue.ts#L6) allows for manual control of iteration, which is useful for event driven work loads.
|
|
20
20
|
|
|
21
21
|
## IPC Support
|
|
22
22
|
To handle communication between processes, [IpcChannel](https://github.com/travetto/travetto/tree/main/module/worker/src/ipc.ts#L9) is provided. This class abstracts the underlying IPC mechanism and provides a simple interface for sending and receiving messages. It also includes event management capabilities, allowing for easy handling of different message types. By default the class assumes it is running in a child process, but it can also be used in a parent process (by passing in the child process) to communicate with child processes.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/worker",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.18",
|
|
4
4
|
"description": "Process management utilities, with a focus on inter-process communication",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"exec",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
],
|
|
22
22
|
"main": "__index__.ts",
|
|
23
23
|
"repository": {
|
|
24
|
-
"url": "https://github.com/travetto/travetto.git",
|
|
24
|
+
"url": "git+https://github.com/travetto/travetto.git",
|
|
25
25
|
"directory": "module/worker"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@travetto/runtime": "^5.0.
|
|
28
|
+
"@travetto/runtime": "^5.0.16",
|
|
29
29
|
"generic-pool": "^3.9.0"
|
|
30
30
|
},
|
|
31
31
|
"travetto": {
|
package/src/pool.ts
CHANGED
|
@@ -34,7 +34,7 @@ const isWorkerFactory = <I, O>(o: WorkerInput<I, O>): o is (() => WorkerFactoryI
|
|
|
34
34
|
export class WorkPool {
|
|
35
35
|
|
|
36
36
|
static MAX_SIZE = os.availableParallelism();
|
|
37
|
-
static DEFAULT_SIZE = Math.
|
|
37
|
+
static DEFAULT_SIZE = Math.max(Math.trunc(WorkPool.MAX_SIZE * .75), 4);
|
|
38
38
|
|
|
39
39
|
/** Build worker pool */
|
|
40
40
|
static #buildPool<I, O>(worker: WorkerInput<I, O>, opts?: WorkPoolConfig<I, O>): Pool<Worker<I, O>> {
|
|
@@ -72,7 +72,6 @@ export class WorkPool {
|
|
|
72
72
|
min: opts?.min ?? 1,
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
-
|
|
76
75
|
// Listen for shutdown
|
|
77
76
|
opts?.shutdown?.addEventListener('abort', async () => {
|
|
78
77
|
while (pendingAcquires) {
|