@effect/platform-node 4.0.0-beta.70 → 4.0.0-beta.71
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/dist/Mime.d.ts +6 -0
- package/dist/Mime.d.ts.map +1 -1
- package/dist/Mime.js +6 -0
- package/dist/Mime.js.map +1 -1
- package/dist/NodeCrypto.d.ts.map +1 -1
- package/dist/NodeCrypto.js +9 -1
- package/dist/NodeCrypto.js.map +1 -1
- package/dist/NodeFileSystem.d.ts.map +1 -1
- package/dist/NodeFileSystem.js +22 -14
- package/dist/NodeFileSystem.js.map +1 -1
- package/dist/NodeHttpClient.d.ts +31 -22
- package/dist/NodeHttpClient.d.ts.map +1 -1
- package/dist/NodeHttpClient.js +29 -20
- package/dist/NodeHttpClient.js.map +1 -1
- package/dist/NodeHttpIncomingMessage.d.ts +23 -10
- package/dist/NodeHttpIncomingMessage.d.ts.map +1 -1
- package/dist/NodeHttpIncomingMessage.js +23 -10
- package/dist/NodeHttpIncomingMessage.js.map +1 -1
- package/dist/NodeMultipart.d.ts +31 -16
- package/dist/NodeMultipart.d.ts.map +1 -1
- package/dist/NodeMultipart.js +29 -14
- package/dist/NodeMultipart.js.map +1 -1
- package/dist/NodePath.d.ts.map +1 -1
- package/dist/NodePath.js +24 -11
- package/dist/NodePath.js.map +1 -1
- package/dist/NodeRedis.d.ts +34 -16
- package/dist/NodeRedis.d.ts.map +1 -1
- package/dist/NodeRedis.js +33 -15
- package/dist/NodeRedis.js.map +1 -1
- package/dist/NodeRuntime.d.ts +3 -3
- package/dist/NodeRuntime.d.ts.map +1 -1
- package/dist/NodeRuntime.js +26 -12
- package/dist/NodeRuntime.js.map +1 -1
- package/dist/NodeServices.d.ts +31 -16
- package/dist/NodeServices.d.ts.map +1 -1
- package/dist/NodeServices.js.map +1 -1
- package/dist/NodeSocket.d.ts.map +1 -1
- package/dist/NodeSocket.js +31 -16
- package/dist/NodeSocket.js.map +1 -1
- package/dist/NodeStdio.d.ts.map +1 -1
- package/dist/NodeStdio.js +21 -13
- package/dist/NodeStdio.js.map +1 -1
- package/dist/NodeTerminal.d.ts.map +1 -1
- package/dist/NodeTerminal.js +18 -8
- package/dist/NodeTerminal.js.map +1 -1
- package/dist/NodeWorker.d.ts.map +1 -1
- package/dist/NodeWorker.js +28 -14
- package/dist/NodeWorker.js.map +1 -1
- package/dist/NodeWorkerRunner.d.ts.map +1 -1
- package/dist/NodeWorkerRunner.js +35 -15
- package/dist/NodeWorkerRunner.js.map +1 -1
- package/dist/Undici.d.ts +13 -0
- package/dist/Undici.d.ts.map +1 -1
- package/dist/Undici.js +13 -0
- package/dist/Undici.js.map +1 -1
- package/dist/index.d.ts +0 -350
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -350
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/Mime.ts +7 -0
- package/src/NodeCrypto.ts +9 -1
- package/src/NodeFileSystem.ts +22 -14
- package/src/NodeHttpClient.ts +29 -20
- package/src/NodeHttpIncomingMessage.ts +23 -10
- package/src/NodeMultipart.ts +29 -14
- package/src/NodePath.ts +24 -11
- package/src/NodeRedis.ts +33 -15
- package/src/NodeRuntime.ts +28 -14
- package/src/NodeServices.ts +31 -16
- package/src/NodeSocket.ts +29 -14
- package/src/NodeStdio.ts +21 -13
- package/src/NodeTerminal.ts +18 -8
- package/src/NodeWorker.ts +28 -14
- package/src/NodeWorkerRunner.ts +35 -15
- package/src/Undici.ts +13 -0
- package/src/index.ts +0 -350
package/src/NodeMultipart.ts
CHANGED
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Node
|
|
2
|
+
* Node.js multipart parsing for HTTP `multipart/form-data` request bodies.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* files should be written into scoped temporary files through the current
|
|
10
|
-
* `FileSystem` and `Path` services.
|
|
4
|
+
* `NodeMultipart` adapts a Node `Readable` plus incoming HTTP headers into
|
|
5
|
+
* Effect's shared multipart model. It can expose form parts as a stream for
|
|
6
|
+
* incremental processing, or collect a complete persisted form by writing file
|
|
7
|
+
* uploads to scoped temporary files through the current `FileSystem` and `Path`
|
|
8
|
+
* services.
|
|
11
9
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
10
|
+
* **Mental model**
|
|
11
|
+
*
|
|
12
|
+
* Multipart request bodies are one-shot byte streams. {@link stream} parses the
|
|
13
|
+
* body as it arrives: fields are decoded to strings and file parts keep their
|
|
14
|
+
* underlying Node readable stream. {@link persisted} consumes the same kind of
|
|
15
|
+
* body, builds a `Multipart.Persisted` record, and ties temporary upload files
|
|
16
|
+
* to the surrounding `Scope`.
|
|
17
|
+
*
|
|
18
|
+
* **Common tasks**
|
|
19
|
+
*
|
|
20
|
+
* - Use {@link stream} when a route validates fields while piping file uploads
|
|
21
|
+
* to storage.
|
|
22
|
+
* - Use {@link persisted} when a route needs a complete form value with scoped
|
|
23
|
+
* temporary files.
|
|
24
|
+
* - Use {@link fileToReadable} when a downstream Node library expects a
|
|
25
|
+
* `Readable`.
|
|
26
|
+
*
|
|
27
|
+
* **Gotchas**
|
|
28
|
+
*
|
|
29
|
+
* Consume a request body with only one parser. File parts must be drained,
|
|
30
|
+
* piped, or persisted so the request can finish reading. `contentEffect` loads
|
|
31
|
+
* an uploaded file into memory, so reserve it for small files. Client-supplied
|
|
32
|
+
* filenames are metadata, not trusted filesystem paths.
|
|
18
33
|
*
|
|
19
34
|
* @since 4.0.0
|
|
20
35
|
*/
|
package/src/NodePath.ts
CHANGED
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Node.js layers for Effect's `Path` service.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* not read the filesystem or validate that paths
|
|
13
|
-
*
|
|
14
|
-
*
|
|
4
|
+
* This module adapts Node's path and file URL behavior to the
|
|
5
|
+
* platform-independent `Path` service. Provide one of its layers when a Node
|
|
6
|
+
* program needs to build, normalize, parse, resolve, or convert paths without
|
|
7
|
+
* depending directly on `node:path`.
|
|
8
|
+
*
|
|
9
|
+
* **Mental model**
|
|
10
|
+
*
|
|
11
|
+
* `Path` is a syntactic service: it manipulates strings and `file:` URLs. It
|
|
12
|
+
* does not read the filesystem, check permissions, or validate that paths
|
|
13
|
+
* exist. The selected layer decides which separator, drive-letter, UNC, and URL
|
|
14
|
+
* conversion rules are used.
|
|
15
|
+
*
|
|
16
|
+
* **Common tasks**
|
|
17
|
+
*
|
|
18
|
+
* Use `layer` for host-platform Node semantics, `layerPosix` for stable POSIX
|
|
19
|
+
* behavior, and `layerWin32` for stable Windows behavior. `NodeServices.layer`
|
|
20
|
+
* already includes `layer`, so import this module directly when a program wants
|
|
21
|
+
* only path support or a platform-specific variant.
|
|
22
|
+
*
|
|
23
|
+
* **Gotchas**
|
|
24
|
+
*
|
|
25
|
+
* Results that are correct on one platform may not be portable to another.
|
|
26
|
+
* `fromFileUrl` and `toFileUrl` use Node's `node:url` conversion rules and
|
|
27
|
+
* report invalid conversions as `BadArgument` failures.
|
|
15
28
|
*
|
|
16
29
|
* @since 4.0.0
|
|
17
30
|
*/
|
package/src/NodeRedis.ts
CHANGED
|
@@ -1,22 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Node.js Redis integration backed by `ioredis`.
|
|
3
3
|
*
|
|
4
|
-
* This module
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* distributed rate limiting, or custom Redis commands alongside the Effect
|
|
9
|
-
* services that build on Redis.
|
|
4
|
+
* This module creates a scoped `ioredis` client and exposes it in two forms:
|
|
5
|
+
* the generic `Redis` service consumed by Effect persistence modules, and the
|
|
6
|
+
* {@link NodeRedis} service for code that needs direct access to the underlying
|
|
7
|
+
* client.
|
|
10
8
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
9
|
+
* **Mental model**
|
|
10
|
+
*
|
|
11
|
+
* - {@link layer} creates one `ioredis` client from explicit client options
|
|
12
|
+
* - {@link layerConfig} reads the same options from `Config`
|
|
13
|
+
* - Building the layer opens the client, and closing the layer scope calls
|
|
14
|
+
* `quit`
|
|
15
|
+
* - The generic `Redis` service sends command strings through `client.call`
|
|
16
|
+
* - {@link NodeRedis} exposes the raw client plus `use`, which maps promise
|
|
17
|
+
* failures into `RedisError`
|
|
18
|
+
*
|
|
19
|
+
* **Common tasks**
|
|
20
|
+
*
|
|
21
|
+
* - Provide Redis-backed persistence, persisted queues, or distributed rate
|
|
22
|
+
* limiting in Node.js
|
|
23
|
+
* - Configure connection, TLS, database, retry, and reconnect behavior with
|
|
24
|
+
* standard `ioredis` options
|
|
25
|
+
* - Run custom Redis commands through {@link NodeRedis} when the generic
|
|
26
|
+
* `Redis` service does not cover the command shape you need
|
|
27
|
+
*
|
|
28
|
+
* **Gotchas**
|
|
29
|
+
*
|
|
30
|
+
* - Install the layer at the lifetime you want for the connection; a short
|
|
31
|
+
* scope opens and closes a Redis client for that scope
|
|
32
|
+
* - Persistence and rate limiter stores create their own keys and Lua scripts
|
|
33
|
+
* on top of this service, so choose stable prefixes and store ids
|
|
34
|
+
* - Persisted values may fail to decode after schema changes; plan migrations
|
|
35
|
+
* or cleanup for long-lived Redis data
|
|
36
|
+
* - Avoid unbounded high-cardinality rate-limit keys unless another process or
|
|
37
|
+
* key policy bounds their lifetime
|
|
20
38
|
*
|
|
21
39
|
* @since 4.0.0
|
|
22
40
|
*/
|
package/src/NodeRuntime.ts
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Node.js
|
|
2
|
+
* Node.js process runner for starting an Effect program at the application
|
|
3
|
+
* edge.
|
|
3
4
|
*
|
|
4
|
-
* This module exposes `runMain`, the
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* This module exposes `runMain`, the launcher used by Node CLIs, scripts,
|
|
6
|
+
* servers, and workers when a single Effect should become the process root. It
|
|
7
|
+
* handles runtime error reporting, Node process signals, and teardown so the
|
|
8
|
+
* rest of the program can stay inside Effect.
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
10
|
+
* **Mental model**
|
|
11
|
+
*
|
|
12
|
+
* `runMain` is the last call in `main.ts`: build the effect, provide the layers
|
|
13
|
+
* it needs, then hand the self-contained program to this module. The function
|
|
14
|
+
* does not provide Node services itself; use `NodeServices.layer` or narrower
|
|
15
|
+
* platform layers before launching.
|
|
16
|
+
*
|
|
17
|
+
* **Common tasks**
|
|
18
|
+
*
|
|
19
|
+
* - Run a CLI command or script and let failures become process failures.
|
|
20
|
+
* - Keep a server or worker fiber alive as the process main program.
|
|
21
|
+
* - Override teardown or disable automatic error reporting at the boundary.
|
|
22
|
+
*
|
|
23
|
+
* **Gotchas**
|
|
24
|
+
*
|
|
25
|
+
* `SIGINT` and `SIGTERM` interrupt the main fiber so scoped finalizers can run.
|
|
26
|
+
* Clean success lets the event loop drain naturally, while signal-triggered
|
|
27
|
+
* interruption or a non-zero teardown code exits the process. Keep long-lived
|
|
28
|
+
* resources in Effect scopes and avoid finalizers that never complete.
|
|
15
29
|
*
|
|
16
30
|
* @since 4.0.0
|
|
17
31
|
*/
|
|
@@ -24,7 +38,7 @@ import type * as Runtime from "effect/Runtime"
|
|
|
24
38
|
*
|
|
25
39
|
* **When to use**
|
|
26
40
|
*
|
|
27
|
-
* Use
|
|
41
|
+
* Use to run an Effect as your application's main program, especially
|
|
28
42
|
* when you need structured error handling, log management, interrupt support,
|
|
29
43
|
* or advanced teardown capabilities.
|
|
30
44
|
*
|
|
@@ -49,7 +63,7 @@ export const runMain: {
|
|
|
49
63
|
*
|
|
50
64
|
* **When to use**
|
|
51
65
|
*
|
|
52
|
-
* Use
|
|
66
|
+
* Use to run an Effect as your application's main program, especially
|
|
53
67
|
* when you need structured error handling, log management, interrupt support,
|
|
54
68
|
* or advanced teardown capabilities.
|
|
55
69
|
*
|
|
@@ -79,7 +93,7 @@ export const runMain: {
|
|
|
79
93
|
*
|
|
80
94
|
* **When to use**
|
|
81
95
|
*
|
|
82
|
-
* Use
|
|
96
|
+
* Use to run an Effect as your application's main program, especially
|
|
83
97
|
* when you need structured error handling, log management, interrupt support,
|
|
84
98
|
* or advanced teardown capabilities.
|
|
85
99
|
*
|
package/src/NodeServices.ts
CHANGED
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* interaction, and
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
2
|
+
* Standard Node.js service bundle for Effect applications.
|
|
3
|
+
*
|
|
4
|
+
* `NodeServices.layer` provides the Node implementations of the core services
|
|
5
|
+
* most command-line programs and server entrypoints need: child process
|
|
6
|
+
* spawning, cryptography, filesystem access, path operations, stdio, terminal
|
|
7
|
+
* interaction, and related process I/O.
|
|
8
|
+
*
|
|
9
|
+
* **Mental model**
|
|
10
|
+
*
|
|
11
|
+
* Application code should depend on the individual Effect service tags it uses,
|
|
12
|
+
* such as `FileSystem`, `Path`, or `Stdio`. This module is the composition
|
|
13
|
+
* point for a Node runtime: provide the aggregate layer once near the program
|
|
14
|
+
* boundary, and those service requirements are satisfied by Node-backed
|
|
15
|
+
* implementations.
|
|
16
|
+
*
|
|
17
|
+
* **Common tasks**
|
|
18
|
+
*
|
|
19
|
+
* - Install the default Node platform services for a CLI, script, or process
|
|
20
|
+
* entrypoint with {@link layer}
|
|
21
|
+
* - Use narrower modules such as `NodeFileSystem`, `NodePath`, or `NodeStdio`
|
|
22
|
+
* when a test or embedded runtime should expose only one service
|
|
23
|
+
* - Keep libraries platform-independent by requiring service tags instead of
|
|
24
|
+
* importing this module directly
|
|
25
|
+
*
|
|
26
|
+
* **Gotchas**
|
|
27
|
+
*
|
|
28
|
+
* This is not every Node integration in `@effect/platform-node`. HTTP clients,
|
|
29
|
+
* HTTP servers, sockets, workers, Redis, and other specialized integrations
|
|
30
|
+
* still have their own modules and layers. Providing this layer also means
|
|
31
|
+
* effects can reach real process resources such as the filesystem, stdio,
|
|
32
|
+
* terminal handles, and child processes.
|
|
18
33
|
*
|
|
19
34
|
* @since 4.0.0
|
|
20
35
|
*/
|
package/src/NodeSocket.ts
CHANGED
|
@@ -1,20 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Node
|
|
3
|
-
* and WebSocket implementations.
|
|
2
|
+
* Node.js socket constructors and layers for Effect sockets.
|
|
4
3
|
*
|
|
5
|
-
* This module
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* opening WebSocket clients in Node.
|
|
4
|
+
* This module combines shared Node stream-backed socket support with
|
|
5
|
+
* Node-specific WebSocket constructor layers. Use it to open TCP clients, Unix
|
|
6
|
+
* domain socket clients, adapt existing Node `Duplex` streams, or provide
|
|
7
|
+
* WebSocket clients to protocols built on Effect's `Socket.Socket`.
|
|
10
8
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* `
|
|
9
|
+
* **Mental model**
|
|
10
|
+
*
|
|
11
|
+
* TCP and Unix sockets come from `node:net` and are exposed as scoped
|
|
12
|
+
* `Socket.Socket` values. Stream open, read, write, and close events are
|
|
13
|
+
* translated to `SocketError` values, and finalization closes or destroys the
|
|
14
|
+
* underlying stream. WebSocket layers provide only the constructor service used
|
|
15
|
+
* by `Socket.makeWebSocket`; `layerWebSocket` combines that constructor with a
|
|
16
|
+
* URL to provide a socket layer.
|
|
17
|
+
*
|
|
18
|
+
* **Common tasks**
|
|
19
|
+
*
|
|
20
|
+
* - Use `makeNet`, `makeNetChannel`, or `layerNet` for TCP connections.
|
|
21
|
+
* - Set `NetConnectOpts.path` for Unix domain sockets.
|
|
22
|
+
* - Use `fromDuplex` when another library already owns a Node `Duplex`.
|
|
23
|
+
* - Use `layerWebSocketConstructor` for the native WebSocket when present, with
|
|
24
|
+
* fallback to `ws`; use `layerWebSocketConstructorWS` to force `ws`.
|
|
25
|
+
*
|
|
26
|
+
* **Gotchas**
|
|
27
|
+
*
|
|
28
|
+
* Socket lifetime is scoped, so release the layer or scope to close the
|
|
29
|
+
* connection. Writes complete when Node accepts or flushes the chunk, not when
|
|
30
|
+
* a peer processes it. Remote `end` events complete the socket run, while
|
|
31
|
+
* abnormal closes, open timeouts, and stream errors surface through
|
|
32
|
+
* `SocketError`; handle them in the Effect that runs the socket.
|
|
18
33
|
*
|
|
19
34
|
* @since 4.0.0
|
|
20
35
|
*/
|
package/src/NodeStdio.ts
CHANGED
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Node.js
|
|
2
|
+
* Node.js `Stdio` layer for the current process.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* command-line arguments
|
|
6
|
-
* `process.stdin`, and
|
|
7
|
-
* `process.stderr`. It is
|
|
8
|
-
*
|
|
9
|
-
* Effect services.
|
|
4
|
+
* The exported layer satisfies the platform-independent `Stdio` service by
|
|
5
|
+
* reading command-line arguments from `process.argv`, consuming input from
|
|
6
|
+
* `process.stdin`, and writing output streams to `process.stdout` and
|
|
7
|
+
* `process.stderr`. It is the stdio bridge used by CLIs, scripts, command
|
|
8
|
+
* runners, and tests that intentionally communicate through the host process.
|
|
10
9
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
10
|
+
* **Mental model**
|
|
11
|
+
*
|
|
12
|
+
* Effects should depend on `Stdio`; this module decides that the backing
|
|
13
|
+
* streams are the global Node process handles. Provide `NodeStdio.layer` when a
|
|
14
|
+
* program only needs standard input and output, or `NodeServices.layer` when the
|
|
15
|
+
* same entrypoint also needs the other default Node services.
|
|
16
|
+
*
|
|
17
|
+
* **Gotchas**
|
|
18
|
+
*
|
|
19
|
+
* The process stdio streams are shared resources. The layer leaves stdin open
|
|
20
|
+
* and does not end stdout or stderr by default, avoiding accidental closure of
|
|
21
|
+
* handles that other code in the same process may still use. Stdio might be a
|
|
22
|
+
* pipe, file, or TTY; terminal-specific behavior such as raw mode, echo, color
|
|
23
|
+
* detection, and cursor movement belongs with terminal APIs rather than this
|
|
24
|
+
* service.
|
|
17
25
|
*
|
|
18
26
|
* @since 4.0.0
|
|
19
27
|
*/
|
package/src/NodeTerminal.ts
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
2
|
+
* Node.js implementation of the Effect `Terminal` service.
|
|
3
|
+
*
|
|
4
|
+
* `NodeTerminal` connects `Terminal` to the current process' stdin and stdout
|
|
5
|
+
* so Node programs can read lines, stream key presses, write display output,
|
|
6
|
+
* and inspect terminal dimensions through the Effect service environment.
|
|
7
|
+
*
|
|
8
|
+
* **Mental model**
|
|
9
|
+
*
|
|
10
|
+
* `make` acquires a scoped terminal backed by process streams, and `layer`
|
|
11
|
+
* provides that service with the default key sequence for quitting input. When
|
|
12
|
+
* stdin is a TTY, low-level key input temporarily enables raw mode for the
|
|
13
|
+
* lifetime of the scope; finalization restores the previous terminal state.
|
|
14
|
+
*
|
|
15
|
+
* **Gotchas**
|
|
16
|
+
*
|
|
17
|
+
* In non-TTY environments such as CI, pipes, or redirected input, terminal
|
|
10
18
|
* dimensions may be reported as zero and raw-mode key handling is unavailable.
|
|
19
|
+
* For plain stdin/stdout byte streams, use the standard I/O service instead of
|
|
20
|
+
* the interactive terminal service.
|
|
11
21
|
*
|
|
12
22
|
* @since 4.0.0
|
|
13
23
|
*/
|
package/src/NodeWorker.ts
CHANGED
|
@@ -1,21 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Parent-side Node.js support for Effect workers.
|
|
3
3
|
*
|
|
4
|
-
* This module
|
|
5
|
-
*
|
|
6
|
-
* processes through Effect's worker protocol
|
|
7
|
-
*
|
|
8
|
-
* CPU-bound work, isolating Node resources, or hosting services that should
|
|
9
|
-
* exchange typed messages with the parent process.
|
|
4
|
+
* This module installs the `WorkerPlatform` used by a Node program that owns
|
|
5
|
+
* workers. It supports both `node:worker_threads` workers and IPC-enabled child
|
|
6
|
+
* processes, routing messages through Effect's worker protocol so higher-level
|
|
7
|
+
* worker clients can treat either runtime as the same parent-side transport.
|
|
10
8
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* `
|
|
18
|
-
*
|
|
9
|
+
* **Mental model**
|
|
10
|
+
*
|
|
11
|
+
* `NodeWorker` runs in the parent process. The worker entrypoint should install
|
|
12
|
+
* `NodeWorkerRunner`, which receives parent messages, runs the registered
|
|
13
|
+
* Effect handler, and sends replies back over the same channel. Use `layer`
|
|
14
|
+
* when you want this module to provide both the platform and a `Worker.Spawner`;
|
|
15
|
+
* use `layerPlatform` when the spawner is provided elsewhere.
|
|
16
|
+
*
|
|
17
|
+
* **Common tasks**
|
|
18
|
+
*
|
|
19
|
+
* - Spawn CPU-bound or resource-isolated work in `worker_threads`.
|
|
20
|
+
* - Spawn a child process that was created with an IPC channel.
|
|
21
|
+
* - Share one parent-side worker implementation across both Node transports.
|
|
22
|
+
*
|
|
23
|
+
* **Gotchas**
|
|
24
|
+
*
|
|
25
|
+
* Worker-thread spawners can use `postMessage` transfer lists for values such as
|
|
26
|
+
* `ArrayBuffer` and `MessagePort`; transferring moves ownership, and invalid
|
|
27
|
+
* transfer lists surface as send or receive failures. Child-process spawners
|
|
28
|
+
* must provide an IPC channel, for example via `child_process.fork` or
|
|
29
|
+
* `stdio: "ipc"`; their messages use Node IPC serialization and transfer lists
|
|
30
|
+
* are not forwarded to `ChildProcess.send`. Scope finalization sends the worker
|
|
31
|
+
* close signal and waits for exit before falling back to `terminate()` or
|
|
32
|
+
* `SIGKILL`.
|
|
19
33
|
*
|
|
20
34
|
* @since 4.0.0
|
|
21
35
|
*/
|
package/src/NodeWorkerRunner.ts
CHANGED
|
@@ -1,21 +1,41 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Node.js runtime support for workers that serve Effect worker requests.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* `
|
|
7
|
-
*
|
|
8
|
-
* over the parent channel.
|
|
4
|
+
* `NodeWorkerRunner` supplies the Node implementation of the Effect worker
|
|
5
|
+
* runner platform. Install {@link layer} inside code that is already running in
|
|
6
|
+
* a `node:worker_threads` worker or in a child process with an IPC channel. The
|
|
7
|
+
* layer listens for parent messages, runs handlers registered through
|
|
8
|
+
* `WorkerRunner`, and replies over the same parent channel.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
10
|
+
* **Mental model**
|
|
11
|
+
*
|
|
12
|
+
* - The parent process creates a worker with the Node worker APIs.
|
|
13
|
+
* - The worker process provides this module's {@link layer} to its runner program.
|
|
14
|
+
* - Startup sends a ready message to the parent, then request messages are
|
|
15
|
+
* dispatched to the registered Effect handler.
|
|
16
|
+
* - Responses are sent with Node `postMessage` for worker threads or
|
|
17
|
+
* `process.send` for child processes.
|
|
18
|
+
* - Shutdown is initiated by the parent protocol and closes or unreferences the
|
|
19
|
+
* parent channel.
|
|
20
|
+
*
|
|
21
|
+
* **Common tasks**
|
|
22
|
+
*
|
|
23
|
+
* - Provide {@link layer} in the worker entrypoint before running `WorkerRunner`.
|
|
24
|
+
* - Host CPU-bound work or isolated Node resources behind the Effect worker protocol.
|
|
25
|
+
* - Return transferable values when using `worker_threads`.
|
|
26
|
+
*
|
|
27
|
+
* **Gotchas**
|
|
28
|
+
*
|
|
29
|
+
* - The runner must start inside an actual worker context; otherwise the layer
|
|
30
|
+
* fails because neither `parentPort` nor `process.send` is available.
|
|
31
|
+
* - Transfer lists only apply to `worker_threads`; child-process IPC uses Node
|
|
32
|
+
* serialization.
|
|
33
|
+
* - Long-running handlers should remain interruptible and keep cleanup in
|
|
34
|
+
* scopes so parent-driven shutdown can release resources.
|
|
35
|
+
*
|
|
36
|
+
* **See also**
|
|
37
|
+
*
|
|
38
|
+
* - {@link layer} for the Node worker runner platform.
|
|
19
39
|
*
|
|
20
40
|
* @since 4.0.0
|
|
21
41
|
*/
|
package/src/Undici.ts
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* Re-export of the Undici HTTP client package used by the Node platform.
|
|
3
|
+
*
|
|
4
|
+
* This module gives Effect applications a package-local import for Undici
|
|
5
|
+
* primitives while working with `@effect/platform-node`. Import named Undici
|
|
6
|
+
* APIs from here when configuring Node HTTP client dispatchers, creating agents
|
|
7
|
+
* or mock agents, setting the process-global dispatcher, or sharing the same
|
|
8
|
+
* Undici types with integrations that use the platform HTTP client.
|
|
9
|
+
*
|
|
10
|
+
* The module does not wrap or reinterpret Undici behavior. It forwards the
|
|
11
|
+
* installed `undici` named exports and default export, so connection pooling,
|
|
12
|
+
* dispatcher lifetimes, mocking, aborts, and request options follow Undici's
|
|
13
|
+
* own semantics.
|
|
14
|
+
*
|
|
2
15
|
* @since 4.0.0
|
|
3
16
|
*/
|
|
4
17
|
import Undici from "undici"
|