@mark1russell7/service 0.7.3 → 0.8.1

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 CHANGED
@@ -91,6 +91,7 @@ The format of a description is `mark1russell7.service/1`.
91
91
  - **The levels.** Each step of the startup, each phase with its cap, its outcome and its duration, and the exit code are `info`. A phase at its cap is `warn`, and an error of the lifecycle is `error`. The polls are `debug`.
92
92
  - **The logger port.** A `Logger` has one method, `log(level, message, fields)`, thus an adapter to another logger is a few lines. `consoleLogger({ level })` writes to the console at `info` and above by default.
93
93
  - **Lines of JSON.** `consoleLogger({ level, format: "json" })` writes one line of JSON for each entry, with `level`, `message` and each field. An error field gives its name, its message and its stack. The default format is `text`, as before.
94
+ - **Trace ids.** `consoleLogger({ traceIds })`, with `traceIds` from `@mark1russell7/service/otel`, adds the `trace_id` and the `span_id` of the active span of OpenTelemetry to each entry. A field of the entry with the same name stays. When no span is active, for example when no program registered an SDK, the entry does not change. Only the entry `/otel` loads `@opentelemetry/api`.
94
95
  - **No logger.** Without a logger, the runtime writes no log, as before. `testLogger()` of `@mark1russell7/service/testing` keeps each entry, thus a test can examine the log.
95
96
 
96
97
  ## The machines
@@ -493,7 +494,7 @@ if (!decision.allowed) return limitedResponse(decision); // 429, with Retry-Afte
493
494
  - **The knobs.** The transport has no defaults. `server_idle_sweep_interval` is the interval of the sweep of idle connections. `server_retry_after` goes in the `Retry-After` of each 503 of the transport.
494
495
  - **The idle close.** `server_idle_close` is the real idle close of the server, which O01 compares with the idle time of a client. Node closes an idle connection at `keepAliveTimeout` plus `keepAliveTimeoutBuffer`. Thus the transport sets `keepAliveTimeout` to `server_idle_close` less the buffer of the server.
495
496
  - **The hint.** The buffer stays, thus the hint of each response (`Keep-Alive: timeout=…`) is less than the real close. A Node without a buffer gives 0. The transport refuses a `server_idle_close` at or below the buffer. A time without a bound stops the timer.
496
- - **The backlog.** The optional knob `server_listen_backlog` is a whole count of 0 or more. The transport gives it to listen(2) as the limit of the accept queue (SYS-103). The kernel clamps it to `net.core.somaxconn`, and a full queue holds the limit plus one (SYS-63). Without the knob, the transport gives no backlog, and Node asks for 511. The knob needs the listen options of the transport. The transport refuses the knob with a listen function, with a server that listens already, and with a second backlog in the listen options.
497
+ - **The backlog.** The optional knob `server_listen_backlog` is a whole count of 1 or more. Node gives listen(2) 511 for a backlog of 0, thus the transport refuses 0. The transport gives it to listen(2) as the limit of the accept queue (SYS-103). The kernel clamps it to `net.core.somaxconn`, and a full queue holds the limit plus one (SYS-63). Without the knob, the transport gives no backlog, and Node asks for 511. The knob needs the listen options of the transport. The transport refuses the knob with a listen function, with a server that listens already, and with a second backlog in the listen options.
497
498
  - **The three times.** `transport.knobs` adds `server_idle_close_hint` and `server_idle_close_buffer` to the knobs of the caller. Thus the declaration shows the hint, the buffer and the real close.
498
499
  - **The count.** The count of the work in flight comes from events. Each response counts until its `close` event, and each upgraded connection counts until it closes. The transport polls nothing.
499
500
  - **The stop of the intake.** `stopIntake()` closes the listener, thus each new connection gets a refusal. It closes the idle connections at once, and again at each `server_idle_sweep_interval`. Each later response gets `Connection: close`, and each later request gets a retryable 503. A connection is not idle while the bytes of its answer go, thus a slow client gets the whole body (SYS-33).
@@ -815,7 +816,7 @@ pnpm add @mark1russell7/service
815
816
 
816
817
  For the Redis client, the application also installs `ioredis@6`. For the PostgreSQL client, it installs `pg@8`. For the MongoDB client, it installs `mongodb@7`. For the RabbitMQ client, it installs `amqplib@2`. For the WebSocket client, it installs `ws@8`.
817
818
 
818
- For the gRPC client, it installs `@grpc/grpc-js@1`. The HTTP client needs no other package.
819
+ For the gRPC client, it installs `@grpc/grpc-js@1`. The HTTP client needs no other package. For the trace ids of `/otel`, it installs `@opentelemetry/api@1`.
819
820
 
820
821
  ### One copy of service
821
822
 
@@ -1,7 +1,7 @@
1
1
  import { n as Clock } from "./clock-DpVgpY4h.js";
2
2
  import { l as LimiterSpec } from "./policy-CwYR95Sz.js";
3
- import { C as MessageTrigger, D as ServiceDescription, E as RepeatSignal, G as ExitTrigger, N as Timing, S as Gate, Z as ProcessTrigger, _ as CooperativeFloor, b as ExitCodes, ct as Operation, h as Check, j as Poll, v as Coupling, w as Phase, y as Dependency, z as OperationOf } from "./logger-BY1RFLzq.js";
4
- import { D as CheckFn, E as StartOptions, F as Outcome, L as Trace, S as Health, d as TransportImpl, n as HealthServer, o as PhaseWork, r as Lifecycle, s as RunOptions, t as DependencyHandle } from "./lifecycle-C8ffyrQ9.js";
3
+ import { $ as ProcessTrigger, E as Phase, F as Timing, N as Poll, O as RepeatSignal, S as ExitCodes, T as MessageTrigger, V as OperationOf, _ as Check, b as Coupling, k as ServiceDescription, q as ExitTrigger, ut as Operation, w as Gate, x as Dependency, y as CooperativeFloor } from "./logger-BN2BfPgU.js";
4
+ import { D as CheckFn, E as StartOptions, F as Outcome, L as Trace, S as Health, d as TransportImpl, n as HealthServer, o as PhaseWork, r as Lifecycle, s as RunOptions, t as DependencyHandle } from "./lifecycle-Br0jAjTk.js";
5
5
  import { Extent, Quantity } from "@mark1russell7/quantity";
6
6
  //#region src/profiles.d.ts
7
7
  /**
@@ -209,4 +209,4 @@ interface ServiceBuilder {
209
209
  declare const service: (name: string) => ServiceBuilder;
210
210
  //#endregion
211
211
  export { WatchdogSpec as a, Profile as c, kubernetes as d, localDev as f, Watchdog as i, daemon as l, ServiceBuilder as n, watchdog as o, service as r, PodTiming as s, ControllerBuilder as t, ephemeral as u };
212
- //# sourceMappingURL=builder-BWfcgx__.d.ts.map
212
+ //# sourceMappingURL=builder-DQj3NNNc.d.ts.map
@@ -1,8 +1,8 @@
1
1
  import { t as Backoff } from "./backoff-B-jGWVDm.js";
2
2
  import { n as Clock } from "./clock-DpVgpY4h.js";
3
- import { D as ServiceDescription, O as Step, S as Gate, ct as Operation, h as Check, j as Poll, m as Recorder, y as Dependency } from "./logger-BY1RFLzq.js";
4
- import { D as CheckFn, t as DependencyHandle } from "./lifecycle-C8ffyrQ9.js";
5
- import { n as ServiceBuilder } from "./builder-BWfcgx__.js";
3
+ import { A as Step, N as Poll, _ as Check, g as Recorder, k as ServiceDescription, ut as Operation, w as Gate, x as Dependency } from "./logger-BN2BfPgU.js";
4
+ import { D as CheckFn, t as DependencyHandle } from "./lifecycle-Br0jAjTk.js";
5
+ import { n as ServiceBuilder } from "./builder-DQj3NNNc.js";
6
6
  import { Extent, Quantity } from "@mark1russell7/quantity";
7
7
  //#region src/client/meets.d.ts
8
8
  /** A situation is what the connection did when the failure started: a command in flight, or idle. */
@@ -231,4 +231,4 @@ declare const retryProblems: (name: string, knobs: RetryKnobs) => string[];
231
231
  declare const STARTING_POLL: Poll;
232
232
  //#endregion
233
233
  export { MANIFESTATIONS as C, firstDetector as D, Situation as E, unwatched as O, Detector as S, Meeting as T, Sent as _, ClientKnobs as a, retryProblems as b, ClientSpec as c, Factory as d, ReadyWait as f, SendOptions as g, STARTING_POLL as h, ClientJoin as i, ClientStep as l, RetrySchedule as m, CheckOptions as n, ClientOptions as o, RetryKnobs as p, Client as r, ClientSocket as s, Attempt as t, DialFn as u, readyWait as v, Manifestation as w, retrySchedule as x, retryBackoff as y };
234
- //# sourceMappingURL=core-Cuh3oSfr.d.ts.map
234
+ //# sourceMappingURL=core-Dt0HEVMq.d.ts.map
@@ -1,4 +1,4 @@
1
- import "./core-Cuh3oSfr.js";
1
+ import "./core-Dt0HEVMq.js";
2
2
  //#region src/client/dial.d.ts
3
3
  /**
4
4
  * A judge reads the bytes that the server sent so far. It gives null for a good answer, an error for
@@ -13,4 +13,4 @@ type Judge = (received: Buffer) => Error | null | "more";
13
13
  declare const statusLineJudge: (accept: (status: number, line: string) => Error | null) => Judge;
14
14
  //#endregion
15
15
  export { statusLineJudge as n, Judge as t };
16
- //# sourceMappingURL=dial-ZJNa6s9i.d.ts.map
16
+ //# sourceMappingURL=dial-CSQOl-yj.d.ts.map
package/build/grpc.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { ct as Operation, j as Poll } from "./logger-BY1RFLzq.js";
2
- import { C as MANIFESTATIONS, D as firstDetector, E as Situation, O as unwatched, S as Detector, T as Meeting, _ as Sent, a as ClientKnobs, b as retryProblems, c as ClientSpec, d as Factory, f as ReadyWait, g as SendOptions, h as STARTING_POLL, i as ClientJoin, l as ClientStep, n as CheckOptions, o as ClientOptions, p as RetryKnobs, r as Client, s as ClientSocket, t as Attempt, u as DialFn, v as readyWait, w as Manifestation } from "./core-Cuh3oSfr.js";
3
- import { t as Judge } from "./dial-ZJNa6s9i.js";
1
+ import { N as Poll, ut as Operation } from "./logger-BN2BfPgU.js";
2
+ import { C as MANIFESTATIONS, D as firstDetector, E as Situation, O as unwatched, S as Detector, T as Meeting, _ as Sent, a as ClientKnobs, b as retryProblems, c as ClientSpec, d as Factory, f as ReadyWait, g as SendOptions, h as STARTING_POLL, i as ClientJoin, l as ClientStep, n as CheckOptions, o as ClientOptions, p as RetryKnobs, r as Client, s as ClientSocket, t as Attempt, u as DialFn, v as readyWait, w as Manifestation } from "./core-Dt0HEVMq.js";
3
+ import { t as Judge } from "./dial-CSQOl-yj.js";
4
4
  import { Extent, Quantity } from "@mark1russell7/quantity";
5
5
  import { Machine } from "@mark1russell7/algebra";
6
6
  //#region src/grpc/connection.d.ts
package/build/host.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { t as Backoff } from "./backoff-B-jGWVDm.js";
2
2
  import { n as Clock } from "./clock-DpVgpY4h.js";
3
- import { c as Logger, q as MessageShape } from "./logger-BY1RFLzq.js";
4
- import { a as FilePort, c as ProcessMark, d as StopSignal, f as joinPath, i as CommandResult, l as ProcessesPort, n as CommandOptions, o as HostPorts, r as CommandPort, s as NetPort, t as ChildHandle, u as SpawnRequest } from "./ports-D-Anj51B.js";
3
+ import { Y as MessageShape, c as Logger } from "./logger-BN2BfPgU.js";
4
+ import { a as FilePort, c as ProcessMark, d as StopSignal, f as joinPath, i as CommandResult, l as ProcessesPort, n as CommandOptions, o as HostPorts, r as CommandPort, s as NetPort, t as ChildHandle, u as SpawnRequest } from "./ports-CSr7qWrA.js";
5
5
  import { Quantity } from "@mark1russell7/quantity";
6
6
  //#region src/host/render.d.ts
7
7
  /**
package/build/host.js CHANGED
@@ -1590,6 +1590,12 @@ const nodeFiles = {
1590
1590
  };
1591
1591
  /** This difference is the time from the start of the Windows file time (1601) to the start of the epoch (1970), in milliseconds. */
1592
1592
  const FILETIME_EPOCH_MS = 11644473600000n;
1593
+ /**
1594
+ * This limit is the longest time of the query of a start time on Windows, in milliseconds. A cold start of PowerShell
1595
+ * on a loaded host can take more than 10 seconds (SYS-47). After the limit the start time is null, and the lock then
1596
+ * counts a live process ID as its owner. Thus a short limit can hold a stale lock, and the limit is wide.
1597
+ */
1598
+ const WINDOWS_START_LIMIT_MS = 3e4;
1593
1599
  /** This function gives the start time of a Windows process from PowerShell, in milliseconds after the epoch, or null. */
1594
1600
  const windowsStart = async (pid) => {
1595
1601
  const result = await nodeCommands.run("powershell.exe", [
@@ -1597,7 +1603,7 @@ const windowsStart = async (pid) => {
1597
1603
  "-NonInteractive",
1598
1604
  "-Command",
1599
1605
  `(Get-Process -Id ${pid} -ErrorAction Stop).StartTime.ToFileTimeUtc()`
1600
- ], { timeout: 1e4 });
1606
+ ], { timeout: WINDOWS_START_LIMIT_MS });
1601
1607
  const text = result.out.trim();
1602
1608
  if (result.code !== 0 || !/^\d+$/.test(text)) return null;
1603
1609
  return Number(BigInt(text) / 10000n - FILETIME_EPOCH_MS);