@procedures/node 0.3.0 → 0.4.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @procedures/node
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 4c51727: The process registry of `@procedures/shell/command` gives the output of a process after a time. `processes.subscribe(id, { output, end })` calls `output` with each new piece of output and its stream, and `end` with the record at the end of the process. `processes.follow(id, { backlog, signal, maxBufferedBytes })` gives the output as an async stream: the kept output without a gap, the new pieces in UTF-8, a `dropped` item for a slow reader, and an `end` item. The end of the process removes each subscriber, and a follow that ends removes its subscriber.
8
+
9
+ `node.logs` has the option `follow` (short `-f`). With it, the result is a stream: the kept output as `output` lines (`lines` limits them), each new line of stdout and stderr, and an `exit` item at the end of the process. The stream ends at the end of the process, at an abort of the caller and when the reader stops. `node.logs` declares `stream: { unbounded: true }`.
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [d919678]
14
+ - Updated dependencies [057d69a]
15
+ - Updated dependencies [b2a1a1e]
16
+ - Updated dependencies [057d69a]
17
+ - Updated dependencies [057d69a]
18
+ - Updated dependencies [057d69a]
19
+ - Updated dependencies [057d69a]
20
+ - Updated dependencies [057d69a]
21
+ - Updated dependencies [afd6a19]
22
+ - Updated dependencies [057d69a]
23
+ - Updated dependencies [4c51727]
24
+ - Updated dependencies [4e751da]
25
+ - @procedures/client@0.4.0
26
+ - @procedures/shell@0.4.0
27
+
3
28
  ## 0.3.0
4
29
 
5
30
  ### Minor Changes
package/README.md CHANGED
@@ -237,10 +237,33 @@ The input has these fields:
237
237
  - `processId` (necessary): the process ID that `node.spawn` gave.
238
238
  - `lines`: give only the last lines of the output.
239
239
  - `stripAnsi`: remove the ANSI escape codes (colors) from the output.
240
+ - `follow`: give a stream of lines (see below).
240
241
 
241
242
  The output has the `processId`, the `status` (`running`, `exited` or `error`), the `exitCode` of an ended process and the `output`.
242
243
 
243
- The procedure knows only the processes of its host. The process writes to two pipes, stdout and stderr. Thus `output` has their lines in the order of their arrival. A process that `node.spawn` did not start is an error. The procedure has no stream: a stream of new output needs a subscription to the process registry of `client-shell`.
244
+ The procedure knows only the processes of its host. The process writes to two pipes, stdout and stderr. Thus `output` has their lines in the order of their arrival. A process that `node.spawn` did not start is an error.
245
+
246
+ #### `follow`: a stream of the lines
247
+
248
+ With `follow: true`, the result is a stream. It uses `processes.follow` of `@procedures/shell/command`.
249
+
250
+ ```typescript
251
+ for await (const item of client.stream(["node", "logs"], { processId, follow: true, lines: 20 })) {
252
+ if (item.type === "exit") break;
253
+ console.log(item.type, item.line);
254
+ }
255
+ ```
256
+
257
+ | Item | Meaning |
258
+ |---|---|
259
+ | `{ type: "output", line }` | A line of the kept output. `lines` limits these lines. The kept output has stdout and stderr together. |
260
+ | `{ type: "stdout" \| "stderr", line }` | A new line of the process, without its line end. |
261
+ | `{ type: "dropped", bytes }` | The reader was slow, and the stream dropped this many bytes of output. |
262
+ | `{ type: "exit", status, exitCode, signal }` | The end of the process. It is the last item. |
263
+
264
+ - The stream ends at the end of the process, at an abort of the caller, and when the reader stops. Each end removes the subscription from the process registry.
265
+ - A line without a line end at the end of the process is the last line of its stream.
266
+ - The procedure declares `stream: { unbounded: true }`, because a process can run without an end.
244
267
 
245
268
  ## Process Lifecycle
246
269