@mark1russell7/service 0.8.19 → 0.8.20
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/build/backoff.d.ts +44 -2
- package/build/{builder-zO48Vgoj.d.ts → builder.d.ts} +14 -101
- package/build/builder.js +499 -0
- package/build/builder.js.map +1 -0
- package/build/{call-context-DDhcVvn5.d.ts → call-context.d.ts} +3 -4
- package/build/channel.d.ts +1 -1
- package/build/{core-BSzt4RI2.d.ts → client/core.d.ts} +32 -61
- package/build/{machine-BhVeHr_m.js → client/core.js} +4 -153
- package/build/client/core.js.map +1 -0
- package/build/{dial-ChwIcvd4.d.ts → client/dial.d.ts} +3 -4
- package/build/client/dial.js +52 -0
- package/build/client/dial.js.map +1 -0
- package/build/client/machine.js +29 -0
- package/build/client/machine.js.map +1 -0
- package/build/client/meets.d.ts +35 -0
- package/build/client/meets.js +78 -0
- package/build/client/meets.js.map +1 -0
- package/build/clock.d.ts +1 -1
- package/build/conformance.d.ts +122 -0
- package/build/conformance.js +470 -0
- package/build/conformance.js.map +1 -0
- package/build/contract.d.ts +28 -0
- package/build/contract.js +184 -0
- package/build/contract.js.map +1 -0
- package/build/description.d.ts +161 -0
- package/build/description.js +11 -0
- package/build/description.js.map +1 -0
- package/build/drains.js +35 -0
- package/build/drains.js.map +1 -0
- package/build/events.d.ts +25 -0
- package/build/fakes.d.ts +43 -0
- package/build/fakes.js +93 -0
- package/build/fakes.js.map +1 -0
- package/build/grpc/client.d.ts +153 -0
- package/build/grpc/client.js +474 -0
- package/build/grpc/client.js.map +1 -0
- package/build/grpc/connection.d.ts +97 -0
- package/build/grpc/connection.js +59 -0
- package/build/grpc/connection.js.map +1 -0
- package/build/grpc/machine.d.ts +12 -0
- package/build/grpc/machine.js +149 -0
- package/build/grpc/machine.js.map +1 -0
- package/build/grpc/meets.d.ts +14 -0
- package/build/grpc/meets.js +105 -0
- package/build/grpc/meets.js.map +1 -0
- package/build/grpc/starting.d.ts +33 -0
- package/build/grpc/starting.js +89 -0
- package/build/grpc/starting.js.map +1 -0
- package/build/grpc.d.ts +9 -303
- package/build/grpc.js +7 -854
- package/build/health.d.ts +93 -0
- package/build/health.js +223 -0
- package/build/health.js.map +1 -0
- package/build/heartbeat.d.ts +1 -1
- package/build/host/discovery.d.ts +61 -0
- package/build/host/discovery.js +113 -0
- package/build/host/discovery.js.map +1 -0
- package/build/host/env.d.ts +14 -0
- package/build/host/env.js +57 -0
- package/build/host/env.js.map +1 -0
- package/build/host/fakes.d.ts +82 -0
- package/build/host/fakes.js +239 -0
- package/build/host/fakes.js.map +1 -0
- package/build/host/group.d.ts +142 -0
- package/build/host/group.js +517 -0
- package/build/host/group.js.map +1 -0
- package/build/host/install.d.ts +96 -0
- package/build/host/install.js +330 -0
- package/build/host/install.js.map +1 -0
- package/build/host/lock.d.ts +78 -0
- package/build/host/lock.js +190 -0
- package/build/host/lock.js.map +1 -0
- package/build/host/logs.d.ts +26 -0
- package/build/host/logs.js +48 -0
- package/build/host/logs.js.map +1 -0
- package/build/host/node.d.ts +14 -0
- package/build/host/node.js +309 -0
- package/build/host/node.js.map +1 -0
- package/build/{ports-B1ayTL-j.d.ts → host/ports.d.ts} +15 -16
- package/build/host/ports.js +17 -0
- package/build/host/ports.js.map +1 -0
- package/build/host/probes.d.ts +51 -0
- package/build/host/probes.js +139 -0
- package/build/host/probes.js.map +1 -0
- package/build/host/processes.d.ts +32 -0
- package/build/host/processes.js +63 -0
- package/build/host/processes.js.map +1 -0
- package/build/host/render.d.ts +84 -0
- package/build/host/render.js +235 -0
- package/build/host/render.js.map +1 -0
- package/build/host/watch.d.ts +90 -0
- package/build/host/watch.js +165 -0
- package/build/host/watch.js.map +1 -0
- package/build/host.d.ts +13 -671
- package/build/host.js +12 -2126
- package/build/http/answers.js +29 -0
- package/build/http/answers.js.map +1 -0
- package/build/http/fake-server.js +61 -0
- package/build/http/fake-server.js.map +1 -0
- package/build/http/outcome.d.ts +115 -0
- package/build/http/outcome.js +325 -0
- package/build/http/outcome.js.map +1 -0
- package/build/http/probes.d.ts +83 -0
- package/build/http/probes.js +232 -0
- package/build/http/probes.js.map +1 -0
- package/build/http/transport.d.ts +165 -0
- package/build/http/transport.js +517 -0
- package/build/http/transport.js.map +1 -0
- package/build/http-client/client.d.ts +121 -0
- package/build/http-client/client.js +330 -0
- package/build/http-client/client.js.map +1 -0
- package/build/http-client/connection.d.ts +78 -0
- package/build/http-client/connection.js +54 -0
- package/build/http-client/connection.js.map +1 -0
- package/build/http-client/machine.d.ts +14 -0
- package/build/http-client/machine.js +109 -0
- package/build/http-client/machine.js.map +1 -0
- package/build/http-client/meets.d.ts +11 -0
- package/build/http-client/meets.js +74 -0
- package/build/http-client/meets.js.map +1 -0
- package/build/http-client/session.d.ts +87 -0
- package/build/http-client/session.js +99 -0
- package/build/http-client/session.js.map +1 -0
- package/build/http-client/starting.d.ts +25 -0
- package/build/http-client/starting.js +65 -0
- package/build/http-client/starting.js.map +1 -0
- package/build/http-client.d.ts +9 -330
- package/build/http-client.js +8 -707
- package/build/http.d.ts +5 -353
- package/build/http.js +3 -1086
- package/build/identity.d.ts +16 -0
- package/build/identity.js +44 -0
- package/build/identity.js.map +1 -0
- package/build/index.d.ts +35 -412
- package/build/index.js +24 -3277
- package/build/knobs.d.ts +1 -0
- package/build/{knobs-BJcz6m01.js → knobs.js} +2 -34
- package/build/knobs.js.map +1 -0
- package/build/latch.d.ts +29 -0
- package/build/latch.js +122 -0
- package/build/latch.js.map +1 -0
- package/build/{rules-HyFCBStQ.d.ts → law.d.ts} +19 -37
- package/build/law.js +149 -0
- package/build/law.js.map +1 -0
- package/build/lifecycle.d.ts +144 -0
- package/build/lifecycle.js +411 -0
- package/build/lifecycle.js.map +1 -0
- package/build/limiter/machine.d.ts +40 -0
- package/build/limiter/machine.js +279 -0
- package/build/limiter/machine.js.map +1 -0
- package/build/{policy-CBcK2XGg.d.ts → limiter/policy.d.ts} +28 -29
- package/build/{policy-UYALkqVq.js → limiter/policy.js} +10 -9
- package/build/limiter/policy.js.map +1 -0
- package/build/{limiter-BNKnwzeY.d.ts → limiter/quota.d.ts} +32 -74
- package/build/{limiter-DrM0PQV9.js → limiter/quota.js} +3 -418
- package/build/limiter/quota.js.map +1 -0
- package/build/{store-DFwFKrsB.d.ts → limiter/store.d.ts} +10 -11
- package/build/limiter/store.js +145 -0
- package/build/limiter/store.js.map +1 -0
- package/build/limiter.d.ts +4 -3
- package/build/limiter.js +4 -2
- package/build/lint.d.ts +152 -0
- package/build/lint.js +576 -0
- package/build/lint.js.map +1 -0
- package/build/logger.d.ts +71 -0
- package/build/logger.js +183 -0
- package/build/logger.js.map +1 -0
- package/build/machines.d.ts +41 -0
- package/build/machines.js +451 -0
- package/build/machines.js.map +1 -0
- package/build/metrics.d.ts +53 -0
- package/build/metrics.js +111 -0
- package/build/metrics.js.map +1 -0
- package/build/mongodb/client.d.ts +131 -0
- package/build/mongodb/client.js +388 -0
- package/build/mongodb/client.js.map +1 -0
- package/build/mongodb/connection.d.ts +112 -0
- package/build/mongodb/connection.js +12 -0
- package/build/mongodb/connection.js.map +1 -0
- package/build/mongodb/machine.d.ts +14 -0
- package/build/mongodb/machine.js +122 -0
- package/build/mongodb/machine.js.map +1 -0
- package/build/mongodb/meets.d.ts +15 -0
- package/build/mongodb/meets.js +103 -0
- package/build/mongodb/meets.js.map +1 -0
- package/build/mongodb/starting.d.ts +29 -0
- package/build/mongodb/starting.js +77 -0
- package/build/mongodb/starting.js.map +1 -0
- package/build/mongodb.d.ts +8 -296
- package/build/mongodb.js +7 -682
- package/build/operation.d.ts +27 -0
- package/build/{operation-DF73RZOI.js → operation.js} +2 -2
- package/build/operation.js.map +1 -0
- package/build/otel.d.ts +2 -2
- package/build/pg/client.d.ts +96 -0
- package/build/pg/client.js +277 -0
- package/build/pg/client.js.map +1 -0
- package/build/pg/connection.d.ts +75 -0
- package/build/pg/connection.js +11 -0
- package/build/pg/connection.js.map +1 -0
- package/build/pg/machine.d.ts +13 -0
- package/build/pg/machine.js +111 -0
- package/build/pg/machine.js.map +1 -0
- package/build/pg/meets.d.ts +14 -0
- package/build/pg/meets.js +83 -0
- package/build/pg/meets.js.map +1 -0
- package/build/pg/starting.d.ts +26 -0
- package/build/pg/starting.js +62 -0
- package/build/pg/starting.js.map +1 -0
- package/build/pg.d.ts +8 -219
- package/build/pg.js +7 -525
- package/build/poller.d.ts +9 -0
- package/build/poller.js +152 -0
- package/build/poller.js.map +1 -0
- package/build/process.d.ts +114 -0
- package/build/process.js +170 -0
- package/build/process.js.map +1 -0
- package/build/profiles.d.ts +68 -0
- package/build/profiles.js +120 -0
- package/build/profiles.js.map +1 -0
- package/build/{queue-DXdw1vLO.d.ts → queue.d.ts} +16 -29
- package/build/queue.js +279 -0
- package/build/queue.js.map +1 -0
- package/build/rabbitmq/client.d.ts +144 -0
- package/build/rabbitmq/client.js +426 -0
- package/build/rabbitmq/client.js.map +1 -0
- package/build/rabbitmq/connection.d.ts +91 -0
- package/build/rabbitmq/connection.js +15 -0
- package/build/rabbitmq/connection.js.map +1 -0
- package/build/rabbitmq/machine.d.ts +13 -0
- package/build/rabbitmq/machine.js +159 -0
- package/build/rabbitmq/machine.js.map +1 -0
- package/build/rabbitmq/meets.d.ts +12 -0
- package/build/rabbitmq/meets.js +96 -0
- package/build/rabbitmq/meets.js.map +1 -0
- package/build/rabbitmq/starting.d.ts +27 -0
- package/build/rabbitmq/starting.js +67 -0
- package/build/rabbitmq/starting.js.map +1 -0
- package/build/rabbitmq.d.ts +8 -283
- package/build/rabbitmq.js +7 -742
- package/build/redis/client.d.ts +86 -0
- package/build/redis/client.js +285 -0
- package/build/redis/client.js.map +1 -0
- package/build/redis/connection.d.ts +57 -0
- package/build/redis/connection.js +11 -0
- package/build/redis/connection.js.map +1 -0
- package/build/redis/limiter.d.ts +43 -0
- package/build/redis/limiter.js +164 -0
- package/build/redis/limiter.js.map +1 -0
- package/build/redis/machine.d.ts +12 -0
- package/build/redis/machine.js +144 -0
- package/build/redis/machine.js.map +1 -0
- package/build/redis/meets.d.ts +11 -0
- package/build/redis/meets.js +75 -0
- package/build/redis/meets.js.map +1 -0
- package/build/redis/operations.d.ts +5 -0
- package/build/redis/operations.js +114 -0
- package/build/redis/operations.js.map +1 -0
- package/build/redis.d.ts +10 -207
- package/build/redis.js +9 -771
- package/build/requests.d.ts +66 -0
- package/build/requests.js +279 -0
- package/build/requests.js.map +1 -0
- package/build/retrier.d.ts +62 -0
- package/build/{retrier-Dnjhvxol.js → retrier.js} +2 -2
- package/build/retrier.js.map +1 -0
- package/build/routes.d.ts +35 -0
- package/build/routes.js +77 -0
- package/build/routes.js.map +1 -0
- package/build/rules.d.ts +19 -2
- package/build/stops.d.ts +51 -0
- package/build/stops.js +86 -0
- package/build/stops.js.map +1 -0
- package/build/testing.d.ts +8 -270
- package/build/testing.js +4 -1027
- package/build/testing.js.map +1 -1
- package/build/timing.d.ts +63 -0
- package/build/{timing-DZl36uXs.js → timing.js} +2 -2
- package/build/timing.js.map +1 -0
- package/build/units.d.ts +17 -0
- package/build/units.js +236 -0
- package/build/units.js.map +1 -0
- package/build/watchdog.d.ts +34 -0
- package/build/watchdog.js +53 -0
- package/build/watchdog.js.map +1 -0
- package/build/websocket/client.d.ts +136 -0
- package/build/websocket/client.js +422 -0
- package/build/websocket/client.js.map +1 -0
- package/build/websocket/connection.d.ts +83 -0
- package/build/websocket/connection.js +57 -0
- package/build/websocket/connection.js.map +1 -0
- package/build/websocket/machine.d.ts +12 -0
- package/build/websocket/machine.js +155 -0
- package/build/websocket/machine.js.map +1 -0
- package/build/websocket/meets.d.ts +14 -0
- package/build/websocket/meets.js +92 -0
- package/build/websocket/meets.js.map +1 -0
- package/build/websocket/starting.d.ts +25 -0
- package/build/websocket/starting.js +69 -0
- package/build/websocket/starting.js.map +1 -0
- package/build/websocket.d.ts +9 -264
- package/build/websocket.js +8 -774
- package/build/worker.d.ts +92 -0
- package/build/worker.js +153 -0
- package/build/worker.js.map +1 -0
- package/package.json +4 -3
- package/build/backoff-QTRGfkEK.d.ts +0 -45
- package/build/clock-DpVgpY4h.d.ts +0 -2
- package/build/grpc.js.map +0 -1
- package/build/host.js.map +0 -1
- package/build/http-client.js.map +0 -1
- package/build/http.js.map +0 -1
- package/build/index.js.map +0 -1
- package/build/knobs-BJcz6m01.js.map +0 -1
- package/build/lifecycle-D0J-zwZF.d.ts +0 -374
- package/build/limiter-DrM0PQV9.js.map +0 -1
- package/build/logger-B6drv9w0.d.ts +0 -488
- package/build/machine-BhVeHr_m.js.map +0 -1
- package/build/mongodb.js.map +0 -1
- package/build/operation-DF73RZOI.js.map +0 -1
- package/build/pg.js.map +0 -1
- package/build/policy-UYALkqVq.js.map +0 -1
- package/build/process-7R9M29wN.js +0 -437
- package/build/process-7R9M29wN.js.map +0 -1
- package/build/rabbitmq.js.map +0 -1
- package/build/redis.js.map +0 -1
- package/build/requests-DD2ALv0_.js +0 -583
- package/build/requests-DD2ALv0_.js.map +0 -1
- package/build/retrier-Dnjhvxol.js.map +0 -1
- package/build/timing-DZl36uXs.js.map +0 -1
- package/build/websocket.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.js","names":[],"sources":["../src/builder.ts"],"sourcesContent":["import type { Extent, Quantity } from \"@mark1russell7/quantity\";\nimport { convertible, valueIn } from \"@mark1russell7/quantity\";\nimport type {\n Check,\n Controller,\n CooperativeFloor,\n Coupling,\n Dependency,\n ExitCodes,\n Gate,\n MessageTrigger,\n Phase,\n RepeatSignal,\n ServiceDescription,\n Transport,\n} from \"./description.ts\";\nimport { FORMAT } from \"./description.ts\";\nimport { realClock } from \"./clock.ts\";\nimport type { Health, Runtime, StartOptions } from \"./health.ts\";\nimport type { Limiter, LimiterSpec } from \"./limiter/policy.ts\";\nimport { limiterProblems } from \"./limiter/policy.ts\";\nimport { healthRuntime } from \"./health.ts\";\nimport { logEvents } from \"./logger.ts\";\nimport type {\n Components,\n DependencyHandle,\n HealthServer,\n Lifecycle,\n PhaseWork,\n RunOptions,\n TransportImpl,\n} from \"./lifecycle.ts\";\nimport { STAGES, lifecycle, lifecycleProblems, stageRank, uncaughtProblems } from \"./lifecycle.ts\";\nimport type { Operation } from \"./operation.ts\";\nimport { operationProblems } from \"./operation.ts\";\nimport type { CheckFn } from \"./poller.ts\";\nimport type { ExitTrigger, ProcessTrigger } from \"./process.ts\";\nimport { EXIT_SIGNALS, PROCESS_TRIGGERS, isExitCode, isExitSignal, isMessageShape } from \"./process.ts\";\nimport type { Profile } from \"./profiles.ts\";\nimport type { OperationOf, RoutePattern } from \"./routes.ts\";\nimport { routePatternProblems } from \"./routes.ts\";\nimport type { Timing } from \"./timing.ts\";\nimport type { Watchdog, WatchdogSpec } from \"./watchdog.ts\";\nimport { watchdog } from \"./watchdog.ts\";\n\n/**\n * The caller composes a service with plain method uses before it starts. The builder is imperative, and\n * it holds static knowledge. The service does not use an `init` function that gives registrations.\n *\n * const svc = service(\"app\");\n * svc.dependency(\"weather\", {\n * system: null,\n * knobs: { request_timeout },\n * operations: { \"GET /v1/forecast\": { idempotent: true } },\n * });\n * svc.controller(\"forecast\").requires(\"weather\").route(\"GET /api/forecast\", { idempotent: true });\n * svc.check({ name: \"weather.round-trip\", dependency: \"weather\", … }, roundTrip);\n * svc.describe(); // the whole graph as data, with nothing started\n * const health = await svc.start();\n *\n * The graph has one source, thus its parts cannot disagree. A dependency or a check can join\n * after the start. It starts tripped, and the export is partial. The runtime has no defaults of\n * its own. Thus `describe()` refuses a service that does not declare a policy, its startup budget\n * or its shutdown, and it tells which. The shutdown includes what a repeat signal does.\n *\n * `start()` starts only the health runtime. `run()` starts the whole lifecycle: the startup in its\n * sequence, the exit signals, the capped phases of the shutdown, and the exit of the process.\n */\nexport interface ControllerBuilder {\n /** This method declares the dependencies that its routes need. The controller is ready only while they are ready. */\n requires(...dependencies: string[]): ControllerBuilder;\n /** This method declares a route that the controller serves, and if its callers can send it again. */\n route(route: string, operation: Operation): ControllerBuilder;\n /**\n * This method declares a route pattern, the operations that its requests can be, and the function\n * that picks the operation of each request. A pattern with one operation needs no function.\n */\n pattern(pattern: string, operations: Readonly<Record<string, Operation>>, operationOf?: OperationOf): ControllerBuilder;\n}\n\n/** A service builder composes a service, gives it as data, and starts it. */\nexport interface ServiceBuilder {\n readonly name: string;\n /** This method declares a dependency, and the handle that connects to it and closes it, if it has one. */\n dependency(name: string, spec: Omit<Dependency, \"name\">, handle?: DependencyHandle): ServiceBuilder;\n /** This method declares a server, and its implementation. `run()` needs the implementation. */\n server(name: string, knobs: Readonly<Record<string, Extent>>, impl?: TransportImpl): ServiceBuilder;\n consumer(name: string, knobs: Readonly<Record<string, Extent>>, impl?: TransportImpl): ServiceBuilder;\n worker(name: string, knobs: Readonly<Record<string, Extent>>, impl?: TransportImpl): ServiceBuilder;\n /** This method gives the server of the probes. It starts first and closes last. */\n healthServer(server: HealthServer): ServiceBuilder;\n /** This method adds work to a declared phase of the shutdown: the owner of the work registers it. */\n onPhase(phase: string, work: PhaseWork): ServiceBuilder;\n /** This method declares a watchdog of the event loop, as a check on the state of the process. */\n watchdog(spec: WatchdogSpec): ServiceBuilder;\n controller(name: string): ControllerBuilder;\n /** This method declares a check, and the function that measures its step. `start()` needs the function. */\n check(check: Check, run?: CheckFn): ServiceBuilder;\n /**\n * This method declares a keyed limiter as data: its key, its policy, its store and the bound on its\n * keys. `describe()` shows it and refuses a part that is absent, because a limiter has no defaults.\n * `keyedLimiter(name, spec, store)` makes its runtime from the same spec.\n */\n limiter(name: string, spec: LimiterSpec): ServiceBuilder;\n readiness(timing: Timing): ServiceBuilder;\n liveness(timing: Timing): ServiceBuilder;\n startup(budget: Quantity): ServiceBuilder;\n couple(coupling: Coupling): ServiceBuilder;\n phase(name: string, cap: Quantity): ServiceBuilder;\n cooperativeWindow(window: Extent): ServiceBuilder;\n /** This method declares the earliest time of the cooperative abort: half the cap of the drain, or no floor. */\n cooperativeFloor(floor: CooperativeFloor): ServiceBuilder;\n /** This method declares what an exit signal does while the shutdown runs: nothing, or an exit at once. */\n onRepeatSignal(policy: RepeatSignal): ServiceBuilder;\n /** This method declares process triggers that start the shutdown, in addition to the exit signals. */\n trigger(...triggers: ProcessTrigger[]): ServiceBuilder;\n /**\n * This method declares a message of the IPC channel that starts the shutdown, as data. With `as`,\n * the message is that exit signal: `svc.trigger(\"ipc-message\", { match: \"shutdown\", as: \"SIGTERM\" })`.\n */\n trigger(trigger: \"ipc-message\", message: MessageTrigger): ServiceBuilder;\n /** This method declares the exit code of a clean shutdown that a trigger starts, in place of 0. */\n exitCode(trigger: ExitTrigger, code: number): ServiceBuilder;\n /** This method declares each field of a profile, as the method of that field does. */\n profile(profile: Profile): ServiceBuilder;\n /** This method gives the service as data, and it starts nothing. */\n describe(): ServiceDescription;\n /**\n * This method closes the composition, starts the health runtime, and gives it after one warm-up\n * sweep of each check. A part that joins after it starts tripped, and it makes the export\n * partial. A second use gives the same runtime.\n */\n start(options?: StartOptions): Promise<Health>;\n /**\n * This method starts the whole lifecycle and gives it when its startup ends: the service operates,\n * or its startup failed and it shuts down. It refuses a declaration that it cannot start: a transport\n * without its implementation, or a stage with work and no declared phase.\n */\n run(options?: RunOptions): Promise<Lifecycle>;\n /**\n * This value is the health runtime from the time that `start()` begins, or null before. Thus the\n * probes can answer during the warm-up sweep: the startup probe fails until the sweep ends.\n */\n readonly health: Health | null;\n /**\n * This value is the lifecycle from the time that `run()` begins, or null before. Its request\n * tracking operates while the transports start, before `run()` gives it.\n */\n readonly lifecycle: Lifecycle | null;\n}\n\nconst isTime = (amount: Extent): boolean => convertible(amount.unit, \"s\");\nconst above = (amount: Extent): boolean =>\n amount.value === \"infinite\" || (isTime(amount) && valueIn(amount as Quantity, \"s\") > 0);\nconst whole = (count: number): boolean => Number.isInteger(count) && count >= 1;\n/** This function copies a check, with its poll and the loops that mark it. */\nconst copyCheck = (check: Check): Check => ({\n ...check,\n poll: { ...check.poll },\n ...(check.marks === undefined ? {} : { marks: { loops: [...check.marks.loops], stall: { ...check.marks.stall } } }),\n});\n/** This function gives the problems of the loops that mark a check. `lint()` compares the stall time with the loops. */\nconst marksProblems = (check: Check): string[] => {\n const marks = check.marks;\n if (marks === undefined) return [];\n const problems: string[] = [];\n if (check.step !== \"progress\")\n problems.push(`check ${check.name} names the loops that mark it, but its step is ${check.step}, not progress`);\n if (marks.loops.length === 0) problems.push(`check ${check.name} names no loop that marks it`);\n // a description from JSON can give a stall time without a bound, which is not a stall time\n if (typeof marks.stall.value !== \"number\" || !above(marks.stall))\n problems.push(`check ${check.name} has a stall time that is not a time above zero`);\n return problems;\n};\n\n/** This function gives the problems of a timing: a zero interval or count fails decoding. */\nconst timingProblems = (policy: Gate, timing: Timing): string[] => {\n if (timing.type === \"debounce\") {\n const problems: string[] = [];\n if (!above(timing.interval)) problems.push(`the ${policy} debounce polls at an interval that is not above zero`);\n if (!whole(timing.failAfter)) problems.push(`the ${policy} debounce fails after ${timing.failAfter} polls, not a whole number above zero`);\n if (!whole(timing.recoverAfter)) problems.push(`the ${policy} debounce recovers after ${timing.recoverAfter} polls, not a whole number above zero`);\n return problems;\n }\n const negative = (amount: Quantity | undefined): boolean =>\n amount !== undefined && (!isTime(amount) || valueIn(amount, \"s\") < 0);\n return negative(timing.failAfter) || negative(timing.recoverAfter)\n ? [`the ${policy} window is not a time of zero or more`]\n : [];\n};\n\n/** This function gives the problems of the rules of the shutdown: an unknown name, or an exit code that a process cannot give. */\nconst shutdownProblems = (\n floor: CooperativeFloor | undefined,\n repeat: RepeatSignal | undefined,\n triggers: readonly ProcessTrigger[],\n exitCodes: ExitCodes,\n messages: readonly MessageTrigger[],\n): string[] => {\n const problems: string[] = [];\n if (floor !== undefined && floor !== \"half\" && floor !== \"none\")\n problems.push(`the cooperative floor ${String(floor)} is not \"half\" or \"none\"`);\n if (repeat !== undefined && repeat !== \"ignore\" && repeat !== \"exit\")\n problems.push(`the policy of a repeat signal ${String(repeat)} is not \"ignore\" or \"exit\"`);\n for (const trigger of triggers)\n if (!PROCESS_TRIGGERS.includes(trigger))\n problems.push(`the trigger ${String(trigger)} is not a process trigger (${PROCESS_TRIGGERS.join(\", \")})`);\n if (triggers.includes(\"ipc-message\") && messages.length === 0)\n problems.push(`the trigger ipc-message has no message to match: declare it with svc.trigger(\"ipc-message\", { match })`);\n for (const message of messages) {\n if (!isMessageShape(message.match))\n problems.push(`the match of a message trigger is not a value of JSON: ${String(message.match)}`);\n if (message.as !== undefined && !isExitSignal(message.as))\n problems.push(`a message trigger stands for ${String(message.as)}, not an exit signal (${EXIT_SIGNALS.join(\", \")})`);\n }\n for (const [trigger, code] of Object.entries(exitCodes)) {\n const known = (EXIT_SIGNALS as readonly string[]).includes(trigger) || triggers.includes(trigger as ProcessTrigger);\n if (!known) problems.push(`the exit code of ${trigger} names no exit signal and no declared trigger`);\n if (code === undefined || !isExitCode(code))\n problems.push(`the exit code of ${trigger} is ${String(code)}, not a whole number from 0 to 255`);\n }\n return problems;\n};\n\n/**\n * This function gives the options with one recorder for the recorder and the logger of the options.\n * Without a logger, it gives the same options.\n */\nconst withLogger = <O extends StartOptions>(options: O, description: ServiceDescription): O => {\n if (options.logger === undefined) return options;\n const given = options.record;\n const log = logEvents(options.logger, description);\n return {\n ...options,\n record: (event) => {\n given?.(event);\n log(event);\n },\n };\n};\n\n/** This function starts the composition of a service. */\nexport const service = (name: string): ServiceBuilder => {\n if (name.trim().length === 0) throw new Error(\"a service needs a name\");\n const transports: Transport[] = [];\n const dependencies: Dependency[] = [];\n const controllers: Array<{\n name: string;\n requires: string[];\n routes: Record<string, Operation>;\n patterns: RoutePattern[];\n }> = [];\n // the function of each route pattern, by controller and by pattern\n const choices = new Map<string, Map<string, OperationOf>>();\n const checks: Check[] = [];\n const runs = new Map<string, CheckFn>();\n const limiters: Limiter[] = [];\n const couplings: Coupling[] = [];\n const phases: Phase[] = [];\n let readiness: Timing | undefined;\n let liveness: Timing | undefined;\n let startup: Quantity | undefined;\n let cooperative: Extent | undefined;\n let floor: CooperativeFloor | undefined;\n let repeat: RepeatSignal | undefined;\n const triggers: ProcessTrigger[] = [];\n const messages: MessageTrigger[] = [];\n const exitCodes: Partial<Record<ExitTrigger, number>> = {};\n let started = false;\n let partial = false;\n let runtime: Promise<Health> | undefined;\n let live: Runtime | undefined;\n let running: Promise<Lifecycle> | undefined;\n let life: Lifecycle | undefined;\n const transportImpls = new Map<string, TransportImpl>();\n const handles = new Map<string, DependencyHandle>();\n const phaseWork = new Map<string, PhaseWork[]>();\n const watchdogs: WatchdogSpec[] = [];\n let probes: HealthServer | null = null;\n\n /** This function stops a change to the shape of the service after the start. */\n const composing = (what: string): void => {\n if (started) throw new Error(`${name} has started: ${what} is declared before svc.start()`);\n };\n const once = (list: ReadonlyArray<{ name: string }>, entry: string, what: string): void => {\n if (list.some((held) => held.name === entry))\n throw new Error(`${name} already has a ${what} named ${entry}`);\n };\n const transport =\n (kind: Transport[\"kind\"]) =>\n (entry: string, knobs: Readonly<Record<string, Extent>>, impl?: TransportImpl) => {\n composing(`a ${kind}`);\n once(transports, entry, \"transport\");\n transports.push({ name: entry, kind, knobs: { ...knobs } });\n if (impl !== undefined) transportImpls.set(entry, impl);\n return builder;\n };\n\n /** This function makes the runtime of the declaration: its checks, and a watchdog for each spec. */\n const makeRuntime = <O extends StartOptions>(\n given: O,\n ): { runtime: Runtime; description: ServiceDescription; stopPollers: () => void; options: O } => {\n const description = builder.describe();\n // the logger is one sink of the stream of the recorder: each machine writes to both\n const options = withLogger(given, description);\n const clock = options.clock ?? realClock;\n const dogs: Watchdog[] = [];\n const all = new Map(runs);\n for (const spec of watchdogs) {\n const dog = watchdog(clock, spec, (from, to, on) =>\n options.record?.({ at: clock.now(), machine: \"watchdog\", instance: spec.name, from, to, on }),\n );\n dogs.push(dog);\n all.set(spec.name, () => dog.check());\n }\n const stopPollers = (): void => {\n for (const dog of dogs) dog.stop();\n };\n let made: Runtime;\n try {\n made = healthRuntime(description, all, options);\n } catch (error) {\n stopPollers();\n throw error;\n }\n // the stop of the health runtime also stops the watchdogs\n const runtime: Runtime = {\n ...made,\n stop: () => {\n made.stop();\n stopPollers();\n },\n };\n return { runtime, description, stopPollers, options };\n };\n\n const builder: ServiceBuilder = {\n name,\n get health() {\n return live ?? null;\n },\n get lifecycle() {\n return life ?? null;\n },\n dependency(entry, spec, handle) {\n once(dependencies, entry, \"dependency\");\n // a dependency that joins after the start has no connection that the lifecycle opens\n if (handle !== undefined && !started) handles.set(entry, handle);\n dependencies.push({\n name: entry,\n ...spec,\n knobs: { ...spec.knobs },\n operations: { ...spec.operations },\n });\n if (started) {\n partial = true;\n live?.addDependency(entry);\n }\n return builder;\n },\n server: transport(\"server\"),\n consumer: transport(\"consumer\"),\n worker: transport(\"worker\"),\n controller(entry) {\n composing(\"a controller\");\n once(controllers, entry, \"controller\");\n const held = {\n name: entry,\n requires: [] as string[],\n routes: {} as Record<string, Operation>,\n patterns: [] as RoutePattern[],\n };\n controllers.push(held);\n const handle: ControllerBuilder = {\n requires(...needed) {\n composing(`what ${entry} requires`);\n held.requires.push(...needed);\n return handle;\n },\n route(served, operation) {\n composing(`${entry}'s routes`);\n if (held.routes[served] !== undefined)\n throw new Error(`${entry} already serves ${served}`);\n held.routes[served] = { ...operation };\n return handle;\n },\n pattern(pattern, operations, operationOf) {\n composing(`${entry}'s route patterns`);\n if (held.patterns.some((each) => each.pattern === pattern))\n throw new Error(`${entry} already has the route pattern ${pattern}`);\n // the function is not data, thus the builder checks it here, and describe() checks the rest\n if (operationOf === undefined && Object.keys(operations).length > 1)\n throw new Error(`${entry}'s pattern ${pattern} has ${Object.keys(operations).length} operations, thus it needs the function that picks one`);\n held.patterns.push({\n pattern,\n operations: Object.fromEntries(Object.entries(operations).map(([name, operation]) => [name, { ...operation }])),\n });\n if (operationOf !== undefined) {\n const mine = choices.get(entry) ?? new Map<string, OperationOf>();\n mine.set(pattern, operationOf);\n choices.set(entry, mine);\n }\n return handle;\n },\n };\n return handle;\n },\n check(check, run) {\n once(checks, check.name, \"check\");\n if (started && run === undefined)\n throw new Error(`check ${check.name} joins after the start, thus it needs its function`);\n checks.push(copyCheck(check));\n if (run !== undefined) runs.set(check.name, run);\n if (started) {\n partial = true;\n live?.addCheck(copyCheck(check), run!);\n }\n return builder;\n },\n limiter(entry, spec) {\n composing(`the limiter ${entry}`);\n once(limiters, entry, \"limiter\");\n // the spec is data: the builder keeps a copy, and describe() checks each part\n const given = (spec ?? {}) as Partial<LimiterSpec>;\n limiters.push({\n name: entry,\n ...given,\n ...(given.policy === undefined ? {} : { policy: { ...given.policy } }),\n ...(given.store === undefined ? {} : { store: { ...given.store } }),\n ...(given.evict === undefined ? {} : { evict: { ...given.evict } }),\n } as Limiter);\n return builder;\n },\n healthServer(server) {\n composing(\"the health server\");\n if (probes !== null) throw new Error(`${name} already has a health server`);\n probes = server;\n return builder;\n },\n onPhase(phase, work) {\n composing(`work for the phase ${phase}`);\n phaseWork.set(phase, [...(phaseWork.get(phase) ?? []), work]);\n return builder;\n },\n watchdog(spec) {\n composing(`the watchdog ${spec.name}`);\n once(checks, spec.name, \"check\");\n // the watchdog is a check on the state of the process itself, on its own connection\n checks.push({\n name: spec.name,\n dependency: null,\n step: \"local-state\",\n ownConnection: true,\n gates: spec.gates,\n poll: { ...spec.poll },\n });\n watchdogs.push(spec);\n return builder;\n },\n readiness(timing) {\n composing(\"readiness\");\n readiness = timing;\n return builder;\n },\n liveness(timing) {\n composing(\"liveness\");\n liveness = timing;\n return builder;\n },\n startup(budget) {\n composing(\"the startup budget\");\n startup = budget;\n return builder;\n },\n couple(coupling) {\n composing(\"a coupling\");\n couplings.push({ ...coupling });\n return builder;\n },\n phase(entry, cap) {\n composing(\"a shutdown phase\");\n once(phases, entry, \"shutdown phase\");\n phases.push({ name: entry, cap });\n return builder;\n },\n cooperativeWindow(window) {\n composing(\"the cooperative window\");\n cooperative = window;\n return builder;\n },\n cooperativeFloor(given) {\n composing(\"the cooperative floor\");\n floor = given;\n return builder;\n },\n onRepeatSignal(policy) {\n composing(\"the policy of a repeat signal\");\n repeat = policy;\n return builder;\n },\n trigger(...given: ReadonlyArray<ProcessTrigger | MessageTrigger>) {\n composing(\"a trigger\");\n const [first, message] = given;\n if (first === \"ipc-message\" && typeof message === \"object\" && message !== null) {\n if (!triggers.includes(\"ipc-message\")) triggers.push(\"ipc-message\");\n messages.push({ ...message });\n return builder;\n }\n for (const each of given) if (typeof each === \"string\" && !triggers.includes(each)) triggers.push(each);\n return builder;\n },\n exitCode(trigger, code) {\n composing(`the exit code of ${trigger}`);\n exitCodes[trigger] = code;\n return builder;\n },\n profile(given) {\n composing(\"a profile\");\n if (given.readiness !== undefined) builder.readiness(given.readiness);\n if (given.liveness !== undefined) builder.liveness(given.liveness);\n if (given.startup !== undefined) builder.startup(given.startup);\n for (const coupling of given.couplings ?? []) builder.couple(coupling);\n for (const each of given.phases ?? []) builder.phase(each.name, each.cap);\n if (given.cooperativeWindow !== undefined) builder.cooperativeWindow(given.cooperativeWindow);\n if (given.cooperativeFloor !== undefined) builder.cooperativeFloor(given.cooperativeFloor);\n if (given.onRepeatSignal !== undefined) builder.onRepeatSignal(given.onRepeatSignal);\n if (given.triggers !== undefined) builder.trigger(...given.triggers);\n for (const message of given.messages ?? []) builder.trigger(\"ipc-message\", message);\n for (const [trigger, code] of Object.entries(given.exitCodes ?? {}))\n if (code !== undefined) builder.exitCode(trigger as ExitTrigger, code);\n return builder;\n },\n describe() {\n const missing: string[] = [];\n if (readiness === undefined) missing.push(\"readiness (svc.readiness)\");\n if (liveness === undefined) missing.push(\"liveness (svc.liveness)\");\n if (startup === undefined) missing.push(\"a startup budget (svc.startup)\");\n if (phases.length === 0) missing.push(\"its shutdown phases (svc.phase)\");\n if (cooperative === undefined)\n missing.push(\"a cooperative window, or no bound (svc.cooperativeWindow)\");\n if (repeat === undefined)\n missing.push(`what a repeat signal does, \"ignore\" or \"exit\" (svc.onRepeatSignal)`);\n if (missing.length > 0)\n throw new Error(\n `${name} does not declare ${missing.join(\"; \")}: the runtime has no defaults`,\n );\n const known = new Set(dependencies.map((entry) => entry.name));\n const problems: string[] = [];\n const policies: Record<Gate, Timing> = { readiness: readiness!, liveness: liveness! };\n for (const gate of [\"readiness\", \"liveness\"] as const)\n problems.push(...timingProblems(gate, policies[gate]));\n for (const check of checks) {\n if (check.dependency !== null && !known.has(check.dependency)) {\n problems.push(\n `check ${check.name} exercises ${check.dependency}, which is not a dependency`,\n );\n }\n if (!isTime(check.poll.interval) || !isTime(check.poll.timeout)) {\n problems.push(`check ${check.name} polls in a unit that is not a time`);\n } else if (!above(check.poll.interval) || !above(check.poll.timeout)) {\n problems.push(`check ${check.name} polls with an interval or a timeout that is not above zero`);\n }\n if (!(check.poll.jitter >= 0 && check.poll.jitter < 1))\n problems.push(`check ${check.name} has a jitter of ${check.poll.jitter}, not a fraction below 1`);\n problems.push(...marksProblems(check));\n // a debounce counts the polls of each check that it gates, thus they poll at its interval\n const timing = check.gates === null ? null : policies[check.gates];\n if (\n timing?.type === \"debounce\" &&\n isTime(check.poll.interval) &&\n above(timing.interval) &&\n valueIn(check.poll.interval, \"s\") !== valueIn(timing.interval, \"s\")\n )\n problems.push(\n `check ${check.name} polls every ${valueIn(check.poll.interval, \"s\")} s, but the ${check.gates} debounce counts polls every ${valueIn(timing.interval, \"s\")} s`,\n );\n }\n for (const controller of controllers) {\n for (const needed of controller.requires) {\n if (!known.has(needed))\n problems.push(\n `controller ${controller.name} requires ${needed}, which is not a dependency`,\n );\n }\n for (const [route, operation] of Object.entries(controller.routes))\n problems.push(...operationProblems(`controller ${controller.name}`, route, operation));\n for (const declared of controller.patterns)\n problems.push(...routePatternProblems(`controller ${controller.name}`, declared));\n }\n for (const limiter of limiters) {\n const { name: entry, ...spec } = limiter;\n problems.push(...limiterProblems(entry, spec));\n if (limiter.store?.kind === \"shared\" && typeof limiter.store.dependency === \"string\" && !known.has(limiter.store.dependency))\n problems.push(`limiter ${entry} keeps its counts in ${limiter.store.dependency}, which is not a dependency`);\n }\n for (const dependency of dependencies)\n for (const [name, operation] of Object.entries(dependency.operations))\n problems.push(...operationProblems(`dependency ${dependency.name}`, name, operation));\n for (const phase of phases)\n if (!isTime(phase.cap)) problems.push(`phase ${phase.name}'s cap is not a time`);\n problems.push(...shutdownProblems(floor, repeat, triggers, exitCodes, messages));\n // the stages of the shutdown keep their sequence: readiness fails first, the health server closes last\n const ranked = phases.map((phase) => phase.name).filter((each) => stageRank(each) >= 0);\n for (let at = 1; at < ranked.length; at += 1)\n if (stageRank(ranked[at]!) < stageRank(ranked[at - 1]!))\n problems.push(\n `the phase \"${ranked[at]!}\" comes after \"${ranked[at - 1]!}\", but the stages go ${STAGES.join(\", \")}`,\n );\n if (problems.length > 0) throw new Error(`${name}: ${problems.join(\"; \")}`);\n const controllersOut: Controller[] = controllers.map((entry) => ({\n name: entry.name,\n requires: [...entry.requires],\n routes: { ...entry.routes },\n ...(entry.patterns.length === 0\n ? {}\n : { patterns: entry.patterns.map((each) => ({ pattern: each.pattern, operations: { ...each.operations } })) }),\n }));\n return {\n format: FORMAT,\n name,\n partial,\n transports: transports.map((entry) => ({ ...entry, knobs: { ...entry.knobs } })),\n dependencies: dependencies.map((entry) => ({\n ...entry,\n knobs: { ...entry.knobs },\n operations: { ...entry.operations },\n })),\n controllers: controllersOut,\n checks: checks.map(copyCheck),\n ...(limiters.length === 0\n ? {}\n : {\n limiters: limiters.map((entry) => ({\n ...entry,\n policy: { ...entry.policy },\n store: { ...entry.store },\n evict: { maxKeys: { ...entry.evict.maxKeys } },\n })),\n }),\n policies: { readiness: readiness!, liveness: liveness!, startup: startup! },\n couplings: couplings.map((entry) => ({ ...entry })),\n shutdown: {\n phases: phases.map((entry) => ({ ...entry })),\n cooperativeWindow: cooperative!,\n ...(floor === undefined ? {} : { cooperativeFloor: floor }),\n onRepeatSignal: repeat!,\n ...(triggers.length === 0 ? {} : { triggers: [...triggers] }),\n ...(messages.length === 0 ? {} : { messages: messages.map((each) => ({ ...each })) }),\n ...(Object.keys(exitCodes).length === 0 ? {} : { exitCodes: { ...exitCodes } }),\n },\n };\n },\n start(options = {}) {\n // the start needs the whole graph: describe() is the check, and the runtime reads it\n if (runtime !== undefined) return runtime;\n if (running !== undefined) return Promise.reject(new Error(`${name} runs its lifecycle: use its health`));\n let made: Runtime;\n try {\n made = makeRuntime(options).runtime;\n } catch (error) {\n return Promise.reject(error);\n }\n started = true;\n live = made;\n runtime = made.warmUp().then(() => made);\n return runtime;\n },\n run(options = {}) {\n if (running !== undefined) return running;\n if (runtime !== undefined) return Promise.reject(new Error(`${name} started its health only: run() starts the whole lifecycle`));\n try {\n const description = builder.describe();\n const components: Components = {\n transports: transportImpls,\n dependencies: handles,\n healthServer: probes,\n phaseWork,\n choices,\n stopPollers: () => {},\n };\n const problems = [...lifecycleProblems(description, components), ...uncaughtProblems(options.uncaught)];\n if (problems.length > 0) throw new Error(`${name}: ${problems.join(\"; \")}`);\n const made = makeRuntime(options);\n started = true;\n live = made.runtime;\n // the builder holds the lifecycle before the first transport starts\n const ran = lifecycle(made.description, made.runtime, { ...components, stopPollers: made.stopPollers }, made.options, (given) => {\n life = given;\n });\n running = ran.started.then(() => ran);\n } catch (error) {\n return Promise.reject(error);\n }\n return running;\n },\n };\n return builder;\n};\n"],"mappings":";;;;;;;;;;;;AAuJA,MAAM,UAAU,WAA4B,YAAY,OAAO,MAAM,GAAG;AACxE,MAAM,SAAS,WACb,OAAO,UAAU,cAAe,OAAO,MAAM,KAAK,QAAQ,QAAoB,GAAG,IAAI;AACvF,MAAM,SAAS,UAA2B,OAAO,UAAU,KAAK,KAAK,SAAS;;AAE9E,MAAM,aAAa,WAAyB;CAC1C,GAAG;CACH,MAAM,EAAE,GAAG,MAAM,KAAK;CACtB,GAAI,MAAM,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO;EAAE,OAAO,CAAC,GAAG,MAAM,MAAM,KAAK;EAAG,OAAO,EAAE,GAAG,MAAM,MAAM,MAAM;CAAE,EAAE;AACnH;;AAEA,MAAM,iBAAiB,UAA2B;CAChD,MAAM,QAAQ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O;EACT;CACF;CACA,OAAO;AACT"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** These are the headers of an incoming call, as `node:http` gives them: the names are in lower case. */
|
|
2
|
-
type IncomingHeaders = Readonly<Record<string, string | readonly string[] | undefined>>;
|
|
2
|
+
export type IncomingHeaders = Readonly<Record<string, string | readonly string[] | undefined>>;
|
|
3
3
|
/** A call context reads the context of an incoming call, and writes the context of an outgoing call. */
|
|
4
|
-
interface CallContext {
|
|
4
|
+
export interface CallContext {
|
|
5
5
|
/**
|
|
6
6
|
* This function runs `fn` in the context of the headers of an incoming call. The context has the
|
|
7
7
|
* trace of `traceparent`. It has the baggage only when `trusted` is true. A call that is not trusted
|
|
@@ -10,5 +10,4 @@ interface CallContext {
|
|
|
10
10
|
run<T>(headers: IncomingHeaders, trusted: boolean, fn: () => T): T;
|
|
11
11
|
/** This function gives the headers of the active context for an outgoing call, for example `traceparent`. */
|
|
12
12
|
headers(): Record<string, string>;
|
|
13
|
-
}
|
|
14
|
-
export { IncomingHeaders as n, CallContext as t };
|
|
13
|
+
}
|
package/build/channel.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Clock } from "./clock.js";
|
|
2
2
|
/** This function gets a failure of the work that a function of this entry started. */
|
|
3
3
|
export type ErrorHandler = (error: unknown) => void;
|
|
4
4
|
/** These options are for a function that starts work and gives an output channel. */
|
|
@@ -1,43 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { Backoff } from "../backoff.js";
|
|
2
|
+
import { ServiceBuilder } from "../builder.js";
|
|
3
|
+
import { Clock } from "../clock.js";
|
|
4
|
+
import { Check, Dependency, Gate, ServiceDescription, Step } from "../description.js";
|
|
5
|
+
import { Recorder } from "../events.js";
|
|
6
|
+
import "../latch.js";
|
|
7
|
+
import { DependencyHandle } from "../lifecycle.js";
|
|
8
|
+
import { Operation } from "../operation.js";
|
|
9
|
+
import { CheckFn } from "../poller.js";
|
|
10
|
+
import { Poll } from "../timing.js";
|
|
11
|
+
import { Meeting } from "./meets.js";
|
|
6
12
|
import { Extent, Quantity } from "@mark1russell7/quantity";
|
|
7
|
-
/** A situation is what the connection did when the failure started: a command in flight, or idle. */
|
|
8
|
-
type Situation = "in flight" | "idle";
|
|
9
|
-
/** A detector is a mechanism that finds a failure, and the most time that it takes. */
|
|
10
|
-
interface Detector {
|
|
11
|
-
/** This name identifies the mechanism: a knob of the declaration, or the kernel. */
|
|
12
|
-
readonly by: string;
|
|
13
|
-
/** This time is the most that the detector takes, after the failure starts. "infinite" tells that it does not find the failure. */
|
|
14
|
-
readonly within: Extent;
|
|
15
|
-
readonly situation: Situation;
|
|
16
|
-
/** This text tells what the detector does, for example that it fails a command without a change of state. */
|
|
17
|
-
readonly effect: string;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* A meeting is a manifestation that the client can meet, and its detectors (E9). The names of the
|
|
21
|
-
* manifestations are the names of the vocabulary of the harness and the corpus. `app-stall` is a
|
|
22
|
-
* server whose process is alive and does not answer, a proposal of the vocabulary.
|
|
23
|
-
*/
|
|
24
|
-
interface Meeting {
|
|
25
|
-
readonly manifestation: string;
|
|
26
|
-
/** This text tells the failure in words. */
|
|
27
|
-
readonly what: string;
|
|
28
|
-
readonly detectors: readonly Detector[];
|
|
29
|
-
}
|
|
30
|
-
/** These are the manifestations that each client gives a meeting for, in this sequence. */
|
|
31
|
-
declare const MANIFESTATIONS: readonly ["rst", "fin", "blackhole", "freeze-host", "freeze-process", "app-stall"];
|
|
32
|
-
/** A manifestation is one name of `MANIFESTATIONS`. */
|
|
33
|
-
type Manifestation = (typeof MANIFESTATIONS)[number];
|
|
34
|
-
/** This function gives the first detector of a manifestation in a situation, or null when no detector has an end (C3). */
|
|
35
|
-
declare const firstDetector: (meeting: Meeting, situation: Situation) => Detector | null;
|
|
36
|
-
/** This function gives each manifestation and situation that no detector of the client finds: the standing rule, as a query (C3, E9). */
|
|
37
|
-
declare const unwatched: (meets: readonly Meeting[]) => Array<{
|
|
38
|
-
readonly manifestation: string;
|
|
39
|
-
readonly situation: Situation;
|
|
40
|
-
}>;
|
|
41
13
|
/**
|
|
42
14
|
* A sent result is the outcome of a call, in three values (C8):
|
|
43
15
|
* - `ok`: the server answered.
|
|
@@ -45,7 +17,7 @@ declare const unwatched: (meets: readonly Meeting[]) => Array<{
|
|
|
45
17
|
* not leave the client.
|
|
46
18
|
* - `indeterminate`: the call can have reached the server, and nothing tells if it applied.
|
|
47
19
|
*/
|
|
48
|
-
type Sent<T> = {
|
|
20
|
+
export type Sent<T> = {
|
|
49
21
|
readonly outcome: "ok";
|
|
50
22
|
readonly value: T;
|
|
51
23
|
readonly attempts: number;
|
|
@@ -60,7 +32,7 @@ type Sent<T> = {
|
|
|
60
32
|
readonly attempts: number;
|
|
61
33
|
};
|
|
62
34
|
/** This type is the outcome of one try of a call, before the core counts the tries. */
|
|
63
|
-
type Attempt<T = unknown> = {
|
|
35
|
+
export type Attempt<T = unknown> = {
|
|
64
36
|
readonly outcome: "ok";
|
|
65
37
|
readonly value: T;
|
|
66
38
|
} | {
|
|
@@ -72,18 +44,18 @@ type Attempt<T = unknown> = {
|
|
|
72
44
|
readonly error: string;
|
|
73
45
|
};
|
|
74
46
|
/** Send options tell how the client sends one call. */
|
|
75
|
-
interface SendOptions {
|
|
47
|
+
export interface SendOptions {
|
|
76
48
|
/** This signal abandons the call. A call that left the client is then indeterminate. */
|
|
77
49
|
readonly signal?: AbortSignal | undefined;
|
|
78
50
|
/** False stops the client: it does not send the call again. A check that must fail at once uses it. */
|
|
79
51
|
readonly reissue?: boolean | undefined;
|
|
80
52
|
}
|
|
81
53
|
/** A dial function opens a new connection to the server, and reads one reply of the protocol. The `dial` check uses it. */
|
|
82
|
-
type DialFn = (host: string, port: number, signal: AbortSignal) => Promise<void>;
|
|
54
|
+
export type DialFn = (host: string, port: number, signal: AbortSignal) => Promise<void>;
|
|
83
55
|
/** The steps of a connection that each client gives a check for (B14). A client can add more steps. */
|
|
84
|
-
type ClientStep = Extract<Step, "dial" | "round-trip" | "local-state">;
|
|
56
|
+
export type ClientStep = Extract<Step, "dial" | "round-trip" | "local-state">;
|
|
85
57
|
/** Check options tell which checks the client gives the health runtime, and which policy each one controls. */
|
|
86
|
-
interface CheckOptions<S extends Step = ClientStep> {
|
|
58
|
+
export interface CheckOptions<S extends Step = ClientStep> {
|
|
87
59
|
readonly poll: Poll;
|
|
88
60
|
/** For each step, the policy that its check controls, or null for a check that only reports. A step that is absent has no check. */
|
|
89
61
|
readonly steps: Partial<Record<S, Gate | null>>;
|
|
@@ -99,7 +71,7 @@ interface CheckOptions<S extends Step = ClientStep> {
|
|
|
99
71
|
* These are the knobs that each client has, by the names of the ordering law. Each driver adds its
|
|
100
72
|
* own knobs. The comments of each driver tell which option of the driver a knob sets.
|
|
101
73
|
*/
|
|
102
|
-
interface ClientKnobs {
|
|
74
|
+
export interface ClientKnobs {
|
|
103
75
|
/** This time bounds a new connection. */
|
|
104
76
|
readonly connect_bound: Quantity;
|
|
105
77
|
/** This time bounds each call on the connection of the application. */
|
|
@@ -117,7 +89,7 @@ interface ClientKnobs {
|
|
|
117
89
|
readonly retrans_giveup_time: Extent;
|
|
118
90
|
}
|
|
119
91
|
/** A client spec is the declaration of one client: where it connects, and its knobs. Each driver adds its own fields. */
|
|
120
|
-
interface ClientSpec<K extends ClientKnobs = ClientKnobs> {
|
|
92
|
+
export interface ClientSpec<K extends ClientKnobs = ClientKnobs> {
|
|
121
93
|
readonly host: string;
|
|
122
94
|
readonly port: number;
|
|
123
95
|
readonly password?: string | undefined;
|
|
@@ -128,9 +100,9 @@ interface ClientSpec<K extends ClientKnobs = ClientKnobs> {
|
|
|
128
100
|
readonly operations?: Readonly<Record<string, Operation>> | undefined;
|
|
129
101
|
}
|
|
130
102
|
/** A factory makes the connection or the pool of a client from the options of its driver. */
|
|
131
|
-
type Factory<O, C> = (options: O) => C | Promise<C>;
|
|
103
|
+
export type Factory<O, C> = (options: O) => C | Promise<C>;
|
|
132
104
|
/** These options make a client. Without them, a client uses its driver, the real clock, and the dial of its protocol. */
|
|
133
|
-
interface ClientOptions<F> {
|
|
105
|
+
export interface ClientOptions<F> {
|
|
134
106
|
readonly create?: F | undefined;
|
|
135
107
|
readonly clock?: Clock | undefined;
|
|
136
108
|
/** This function receives each transition of the client, for the prober (D3). */
|
|
@@ -138,7 +110,7 @@ interface ClientOptions<F> {
|
|
|
138
110
|
readonly dial?: DialFn | undefined;
|
|
139
111
|
}
|
|
140
112
|
/** A client socket is the part of the socket of a connection that the join of the prober and the bounded close read. */
|
|
141
|
-
interface ClientSocket {
|
|
113
|
+
export interface ClientSocket {
|
|
142
114
|
readonly localAddress?: string | undefined;
|
|
143
115
|
readonly localPort?: number | undefined;
|
|
144
116
|
readonly remoteAddress?: string | undefined;
|
|
@@ -150,7 +122,7 @@ interface ClientSocket {
|
|
|
150
122
|
* A client join is one connection, at the time when it can serve (D1, D2). The prober joins its
|
|
151
123
|
* kernel records to the server's view of the connection through it. Each driver adds the server's id of the connection.
|
|
152
124
|
*/
|
|
153
|
-
interface ClientJoin {
|
|
125
|
+
export interface ClientJoin {
|
|
154
126
|
readonly generation: number;
|
|
155
127
|
/** This time is when the connection became ready, in milliseconds on the monotonic clock. */
|
|
156
128
|
readonly at: number;
|
|
@@ -160,7 +132,7 @@ interface ClientJoin {
|
|
|
160
132
|
readonly remotePort: number | null;
|
|
161
133
|
}
|
|
162
134
|
/** A client is a dependency of a service: its declaration, its handle and its checks. Each driver adds the method that sends a call. */
|
|
163
|
-
interface Client<S extends Step = ClientStep, J extends ClientJoin = ClientJoin> {
|
|
135
|
+
export interface Client<S extends Step = ClientStep, J extends ClientJoin = ClientJoin> {
|
|
164
136
|
readonly name: string;
|
|
165
137
|
/** This declaration goes to `svc.dependency(name, declaration, handle)`. */
|
|
166
138
|
readonly declaration: Omit<Dependency, "name">;
|
|
@@ -182,16 +154,16 @@ interface Client<S extends Step = ClientStep, J extends ClientJoin = ClientJoin>
|
|
|
182
154
|
* A ready wait holds the calls that wait for a ready connection before their second try. A client
|
|
183
155
|
* that connects again by itself uses it: Redis and RabbitMQ.
|
|
184
156
|
*/
|
|
185
|
-
interface ReadyWait {
|
|
157
|
+
export interface ReadyWait {
|
|
186
158
|
/** This method waits until the client is ready, for `within` milliseconds at most. It gives true when the client is ready. */
|
|
187
159
|
wait(within: number, signal?: AbortSignal): Promise<boolean>;
|
|
188
160
|
/** This method ends each wait with true. The client uses it when its connection is ready. */
|
|
189
161
|
wake(): void;
|
|
190
162
|
}
|
|
191
163
|
/** This function makes the ready wait of a client. The function `ready` tells if the client is ready. */
|
|
192
|
-
declare const readyWait: (clock: Clock, ready: () => boolean) => ReadyWait;
|
|
164
|
+
export declare const readyWait: (clock: Clock, ready: () => boolean) => ReadyWait;
|
|
193
165
|
/** These are the knobs of a client that connects again by itself, after a delay that doubles. */
|
|
194
|
-
interface RetryKnobs {
|
|
166
|
+
export interface RetryKnobs {
|
|
195
167
|
/** This time is the first delay before a new try to connect. The delay doubles after each try. */
|
|
196
168
|
readonly retry_base: Quantity;
|
|
197
169
|
/** This time is the most that one delay can be, before its jitter. */
|
|
@@ -201,12 +173,12 @@ interface RetryKnobs {
|
|
|
201
173
|
* This function gives the backoff of the tries to connect: from `retry_base`, doubling to
|
|
202
174
|
* `retry_cap`, each with a jitter up to the base. The client rounds each delay to a whole millisecond.
|
|
203
175
|
*/
|
|
204
|
-
declare const retryBackoff: (knobs: RetryKnobs) => Backoff;
|
|
176
|
+
export declare const retryBackoff: (knobs: RetryKnobs) => Backoff;
|
|
205
177
|
/**
|
|
206
178
|
* A retry schedule holds the next try to connect, for a client that connects again by itself. It
|
|
207
179
|
* counts the tries since the last join. Each delay comes from the backoff, rounded to a whole millisecond.
|
|
208
180
|
*/
|
|
209
|
-
interface RetrySchedule {
|
|
181
|
+
export interface RetrySchedule {
|
|
210
182
|
/** This count is the number of tries since the last reset. */
|
|
211
183
|
readonly tries: number;
|
|
212
184
|
/** This method counts one more try, and starts `due` after the delay of that try. It stops a try that waits. */
|
|
@@ -217,13 +189,12 @@ interface RetrySchedule {
|
|
|
217
189
|
reset(): void;
|
|
218
190
|
}
|
|
219
191
|
/** This function makes the retry schedule of a client, from its backoff and its random numbers. RabbitMQ and WebSocket use it. */
|
|
220
|
-
declare const retrySchedule: (clock: Clock, backoff: Backoff, random: () => number) => RetrySchedule;
|
|
192
|
+
export declare const retrySchedule: (clock: Clock, backoff: Backoff, random: () => number) => RetrySchedule;
|
|
221
193
|
/** This function gives the problems of the retry knobs: the cap must not be below the base. */
|
|
222
|
-
declare const retryProblems: (name: string, knobs: RetryKnobs) => string[];
|
|
194
|
+
export declare const retryProblems: (name: string, knobs: RetryKnobs) => string[];
|
|
223
195
|
/**
|
|
224
196
|
* This poll is a poll of the checks to start from: each 5 s with a jitter of 20 %, and a timeout of
|
|
225
197
|
* 4 s (B6, O12). Its slowest poll is 4 s + 5 s × 1.2 = 10 s, the slowest poll of the cells of O13.
|
|
226
198
|
* It does not depend on a driver. The starting knobs of each driver fit it.
|
|
227
199
|
*/
|
|
228
|
-
declare const STARTING_POLL: Poll;
|
|
229
|
-
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 };
|
|
200
|
+
export declare const STARTING_POLL: Poll;
|
|
@@ -1,81 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { retrierOn } from "../retrier.js";
|
|
2
|
+
import { mayReissue } from "../operation.js";
|
|
3
3
|
import { quantity, valueIn } from "@mark1russell7/quantity";
|
|
4
|
-
import { connect } from "node:net";
|
|
5
|
-
// src/client/meets.ts
|
|
6
|
-
/** These are the manifestations that each client gives a meeting for, in this sequence. */
|
|
7
|
-
const MANIFESTATIONS = [
|
|
8
|
-
"rst",
|
|
9
|
-
"fin",
|
|
10
|
-
"blackhole",
|
|
11
|
-
"freeze-host",
|
|
12
|
-
"freeze-process",
|
|
13
|
-
"app-stall"
|
|
14
|
-
];
|
|
15
|
-
/**
|
|
16
|
-
* These words tell each manifestation that does not depend on the driver. The words of `app-stall`
|
|
17
|
-
* name an example, and the example is a fact of each server, thus each client gives them.
|
|
18
|
-
*/
|
|
19
|
-
const WHAT = {
|
|
20
|
-
rst: "the server answers each segment with a reset, and refuses each new connection",
|
|
21
|
-
fin: "the process of the server ends, and its kernel closes the connection",
|
|
22
|
-
blackhole: "the network drops each segment in the two directions",
|
|
23
|
-
"freeze-host": "the host of the server stops, without a close: the death without a close",
|
|
24
|
-
"freeze-process": "the process of the server stops, and its kernel stays up"
|
|
25
|
-
};
|
|
26
|
-
/** This amount is a detector that does not find the failure. */
|
|
27
|
-
const NEVER = {
|
|
28
|
-
value: "infinite",
|
|
29
|
-
unit: "s"
|
|
30
|
-
};
|
|
31
|
-
const s = (value) => quantity(Math.round(value * 1e6) / 1e6, "s");
|
|
32
|
-
const seconds = (amount) => amount.value === "infinite" ? Number.POSITIVE_INFINITY : valueIn(amount, "s");
|
|
33
|
-
/** This function gives the time at which Node's TCP keepalive gives up a silent peer: the idle time, then 10 probes 1 s apart. */
|
|
34
|
-
const keepaliveGiveUp = (idle) => idle.value === "infinite" ? NEVER : s(seconds(idle) + 10);
|
|
35
|
-
/** This detector is a segment that arrives at once: a reset or a FIN. */
|
|
36
|
-
const immediate = (situation, effect) => ({
|
|
37
|
-
by: "the next segment",
|
|
38
|
-
within: s(0),
|
|
39
|
-
situation,
|
|
40
|
-
effect
|
|
41
|
-
});
|
|
42
|
-
/** This detector is TCP keepalive on a silent peer. It gives up after its probes, and the socket closes. */
|
|
43
|
-
const keepaliveSilent = (idle) => ({
|
|
44
|
-
by: "keepalive_idle",
|
|
45
|
-
within: keepaliveGiveUp(idle),
|
|
46
|
-
situation: "idle",
|
|
47
|
-
effect: "TCP keepalive gives up, and the socket closes"
|
|
48
|
-
});
|
|
49
|
-
/** This detector is TCP keepalive on a peer whose kernel stays up. That kernel answers each probe, thus keepalive does not find the failure. */
|
|
50
|
-
const keepaliveAnswered = () => ({
|
|
51
|
-
by: "keepalive_idle",
|
|
52
|
-
within: NEVER,
|
|
53
|
-
situation: "idle",
|
|
54
|
-
effect: "the kernel of the server answers each probe"
|
|
55
|
-
});
|
|
56
|
-
/** This detector is TCP keepalive on a peer that resets: the first probe gets the reset. */
|
|
57
|
-
const keepaliveReset = (idle) => ({
|
|
58
|
-
by: "keepalive_idle",
|
|
59
|
-
within: idle.value === "infinite" ? NEVER : idle,
|
|
60
|
-
situation: "idle",
|
|
61
|
-
effect: "the first probe gets a reset"
|
|
62
|
-
});
|
|
63
|
-
/** This detector is the kernel, which gives up the retransmissions of a segment in flight. A driver can add what follows. */
|
|
64
|
-
const kernelGiveUp = (within, after) => ({
|
|
65
|
-
by: "retrans_giveup_time",
|
|
66
|
-
within,
|
|
67
|
-
situation: "in flight",
|
|
68
|
-
effect: `the kernel gives up the retransmissions and closes the socket${after === void 0 ? "" : `, and ${after}`}`
|
|
69
|
-
});
|
|
70
|
-
/** This function gives the first detector of a manifestation in a situation, or null when no detector has an end (C3). */
|
|
71
|
-
const firstDetector = (meeting, situation) => {
|
|
72
|
-
return meeting.detectors.filter((detector) => detector.situation === situation && detector.within.value !== "infinite").sort((a, b) => seconds(a.within) - seconds(b.within))[0] ?? null;
|
|
73
|
-
};
|
|
74
|
-
/** This function gives each manifestation and situation that no detector of the client finds: the standing rule, as a query (C3, E9). */
|
|
75
|
-
const unwatched = (meets) => meets.flatMap((meeting) => ["in flight", "idle"].flatMap((situation) => firstDetector(meeting, situation) === null ? [{
|
|
76
|
-
manifestation: meeting.manifestation,
|
|
77
|
-
situation
|
|
78
|
-
}] : []));
|
|
79
4
|
// src/client/core.ts
|
|
80
5
|
/** This interval is the poll of a catalog check that gates nothing (B19). */
|
|
81
6
|
const CATALOG_INTERVAL = quantity(30, "s");
|
|
@@ -473,80 +398,6 @@ const STARTING_POLL = {
|
|
|
473
398
|
unit: "s"
|
|
474
399
|
}
|
|
475
400
|
};
|
|
476
|
-
|
|
477
|
-
/**
|
|
478
|
-
* This function makes a dial function. The dial opens a TCP connection, sends `hello`, and reads the
|
|
479
|
-
* answer until `judge` decides. An abort, an error of the socket, and a close before the decision fail the dial.
|
|
480
|
-
* The dial destroys its socket at its end.
|
|
481
|
-
*/
|
|
482
|
-
const helloDial = (hello, judge) => (host, port, signal) => new Promise((resolve, reject) => {
|
|
483
|
-
if (signal.aborted) {
|
|
484
|
-
reject(/* @__PURE__ */ new Error("the dial was aborted"));
|
|
485
|
-
return;
|
|
486
|
-
}
|
|
487
|
-
const socket = connect({
|
|
488
|
-
host,
|
|
489
|
-
port
|
|
490
|
-
});
|
|
491
|
-
let received = Buffer.alloc(0);
|
|
492
|
-
const end = (error) => {
|
|
493
|
-
signal.removeEventListener("abort", onAbort);
|
|
494
|
-
socket.destroy();
|
|
495
|
-
if (error === void 0) resolve();
|
|
496
|
-
else reject(error);
|
|
497
|
-
};
|
|
498
|
-
const onAbort = () => end(/* @__PURE__ */ new Error("the dial was aborted"));
|
|
499
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
500
|
-
socket.once("connect", () => socket.write(hello));
|
|
501
|
-
socket.on("data", (chunk) => {
|
|
502
|
-
received = Buffer.concat([received, chunk]);
|
|
503
|
-
const verdict = judge(received);
|
|
504
|
-
if (verdict === "more") return;
|
|
505
|
-
end(verdict ?? void 0);
|
|
506
|
-
});
|
|
507
|
-
socket.once("error", (error) => end(error));
|
|
508
|
-
socket.once("close", () => end(/* @__PURE__ */ new Error("the server closed the dial")));
|
|
509
|
-
});
|
|
510
|
-
/** This function gives the authority of a host and a port for a Host header. An IPv6 address goes in brackets. */
|
|
511
|
-
const authority = (host, port) => `${host.includes(":") ? `[${host}]` : host}:${port}`;
|
|
512
|
-
/**
|
|
513
|
-
* This function makes a judge of the status line of an HTTP/1.1 answer. The judge waits for the end
|
|
514
|
-
* of the line, in the first 8 KiB. Then `accept` reads the status code, and gives null for a good status or an error.
|
|
515
|
-
* The HTTP client accepts each status. The WebSocket client accepts only 101.
|
|
516
|
-
*/
|
|
517
|
-
const statusLineJudge = (accept) => (received) => {
|
|
518
|
-
const end = received.indexOf("\r\n");
|
|
519
|
-
if (end < 0) return received.length > 8192 ? /* @__PURE__ */ new Error("the answer has no status line in its first 8 KiB") : "more";
|
|
520
|
-
const line = received.toString("latin1", 0, end);
|
|
521
|
-
const status = /^HTTP\/1\.[01] (\d{3})/.exec(line);
|
|
522
|
-
return status === null ? /* @__PURE__ */ new Error(`the answer ${JSON.stringify(line)} is not an HTTP/1.1 status line`) : accept(Number(status[1]), line);
|
|
523
|
-
};
|
|
524
|
-
// src/client/machine.ts
|
|
525
|
-
/** This function gives one transition of a machine document. */
|
|
526
|
-
const transition = (id, from, on, to, extra = {}) => ({
|
|
527
|
-
id,
|
|
528
|
-
from,
|
|
529
|
-
on,
|
|
530
|
-
to,
|
|
531
|
-
...extra
|
|
532
|
-
});
|
|
533
|
-
/** This function gives a knob of a client in a machine document, by the option of the driver that it sets. */
|
|
534
|
-
const clientKnob = (key) => ({
|
|
535
|
-
key,
|
|
536
|
-
scope: "client",
|
|
537
|
-
unit: "s",
|
|
538
|
-
default: null
|
|
539
|
-
});
|
|
540
|
-
/** This timer is the bound of the close. The close request arms it, and the end cancels it. At its end, the driver destroys each socket. */
|
|
541
|
-
const closeTimer = () => ({
|
|
542
|
-
duration: {
|
|
543
|
-
knob: "close_bound",
|
|
544
|
-
unit: "s"
|
|
545
|
-
},
|
|
546
|
-
arms: ["close.request"],
|
|
547
|
-
cancels: ["status.end"],
|
|
548
|
-
fires: "close.bound"
|
|
549
|
-
});
|
|
550
|
-
export { retrySchedule as A, zeroProblems as B, notSent as C, readyWait as D, poolProblems as E, timeProblems as F, immediate as G, NEVER as H, trackWithTimer as I, keepaliveSilent as J, keepaliveAnswered as K, wholeProblems as L, sendWithReissue as M, socketEnds as N, retryBackoff as O, stepChecks as P, withinBound as R, ms as S, orZero as T, WHAT as U, MANIFESTATIONS as V, firstDetector as W, unwatched as X, kernelGiveUp as Y, inFlight as _, helloDial as a, message as b, ageProblems as c, clientProblems as d, clientRecorder as f, idleCloseProblem as g, finiteMs as h, authority as i, roundTripCheck as j, retryProblems as k, attachClient as l, dialCheck as m, closeTimer as n, statusLineJudge as o, deadlineProblem as p, keepaliveReset as q, transition as r, STARTING_POLL as s, clientKnob as t, clientBounds as u, keepaliveOnProblems as v, operationTable as w, missesProblems as x, localStateCheck as y, wrapperTimerProblems as z };
|
|
401
|
+
export { CATALOG_INTERVAL, STARTING_POLL, ageProblems, attachClient, clientBounds, clientProblems, clientRecorder, deadlineProblem, dialCheck, finiteMs, idleCloseProblem, inFlight, keepaliveOnProblems, localStateCheck, message, missesProblems, ms, notSent, operationTable, orZero, passes, poolProblems, readyWait, retryBackoff, retryProblems, retrySchedule, roundTripCheck, sendWithReissue, socketEnds, stepChecks, timeProblems, trackWithTimer, wholeMs, wholeProblems, wholeSeconds, withinBound, wrapperTimerProblems, zeroProblems };
|
|
551
402
|
|
|
552
|
-
//# sourceMappingURL=
|
|
403
|
+
//# sourceMappingURL=core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","names":[],"sources":["../../src/client/core.ts"],"sourcesContent":["// The parts of a client wrapper that do not change from one client to the next. Each client entry\n// (`./redis`, `./pg`, `./http-client`, `./websocket`, and each later client of S1) fills them in with its driver. The core gives\n// the shapes of a client, the outcome of a call in three values, the rule that sends a call again,\n// the record of the calls in flight, the bounded close, the checks of the steps of a connection,\n// and the problems of a spec and of a client in a description. It loads only quantity.\n// The section \"Unified or separate\" of docs/S6.md gives each part, and the reason for each part that stays in a driver.\n\nimport type { Extent, Quantity } from \"@mark1russell7/quantity\";\nimport { quantity, valueIn } from \"@mark1russell7/quantity\";\nimport type { Backoff } from \"../backoff.ts\";\nimport { retrierOn } from \"../retrier.ts\";\nimport type { ServiceBuilder } from \"../builder.ts\";\nimport type { Cancel, Clock } from \"../clock.ts\";\nimport type { Check, Dependency, Gate, ServiceDescription, Step } from \"../description.ts\";\nimport type { Recorder } from \"../events.ts\";\nimport type { Outcome } from \"../latch.ts\";\nimport type { DependencyHandle } from \"../lifecycle.ts\";\nimport type { Operation } from \"../operation.ts\";\nimport { mayReissue } from \"../operation.ts\";\nimport type { CheckFn } from \"../poller.ts\";\nimport type { Poll } from \"../timing.ts\";\nimport type { Meeting } from \"./meets.ts\";\n\n/**\n * A sent result is the outcome of a call, in three values (C8):\n * - `ok`: the server answered.\n * - `error`: the call did not apply. The server answered with an error (`reply`), or the call did\n * not leave the client.\n * - `indeterminate`: the call can have reached the server, and nothing tells if it applied.\n */\nexport type Sent<T> =\n | { readonly outcome: \"ok\"; readonly value: T; readonly attempts: number }\n | { readonly outcome: \"error\"; readonly error: string; readonly reply: boolean; readonly attempts: number }\n | { readonly outcome: \"indeterminate\"; readonly error: string; readonly attempts: number };\n\n/** This type is the outcome of one try of a call, before the core counts the tries. */\nexport type Attempt<T = unknown> =\n | { readonly outcome: \"ok\"; readonly value: T }\n | { readonly outcome: \"error\"; readonly error: string; readonly reply: boolean }\n | { readonly outcome: \"indeterminate\"; readonly error: string };\n\n/** Send options tell how the client sends one call. */\nexport interface SendOptions {\n /** This signal abandons the call. A call that left the client is then indeterminate. */\n readonly signal?: AbortSignal | undefined;\n /** False stops the client: it does not send the call again. A check that must fail at once uses it. */\n readonly reissue?: boolean | undefined;\n}\n\n/** A dial function opens a new connection to the server, and reads one reply of the protocol. The `dial` check uses it. */\nexport type DialFn = (host: string, port: number, signal: AbortSignal) => Promise<void>;\n\n/** The steps of a connection that each client gives a check for (B14). A client can add more steps. */\nexport type ClientStep = Extract<Step, \"dial\" | \"round-trip\" | \"local-state\">;\n\n/** Check options tell which checks the client gives the health runtime, and which policy each one controls. */\nexport interface CheckOptions<S extends Step = ClientStep> {\n readonly poll: Poll;\n /** For each step, the policy that its check controls, or null for a check that only reports. A step that is absent has no check. */\n readonly steps: Partial<Record<S, Gate | null>>;\n /**\n * With a catalog, the client gives a check for each step that it has (B19). The steps of `steps` are\n * the nominated checks. Each other step reports only, and polls at the catalog poll. `true` is a poll\n * of 30 s with the jitter and the timeout of `poll`. A nominated step that the client has no check\n * for then fails the attach. Without a catalog, the client gives only the steps of `steps`.\n */\n readonly catalog?: true | Poll | undefined;\n}\n\n/** This interval is the poll of a catalog check that gates nothing (B19). */\nexport const CATALOG_INTERVAL: Quantity = quantity(30, \"s\");\n\n/** A step check is the function of one step, and if it uses the connection of the application. */\nexport interface StepCheck {\n readonly ownConnection: boolean;\n readonly run: CheckFn;\n}\n\n/** This function gives an amount in milliseconds. \"infinite\" is `Infinity`. */\nexport const ms = (amount: Extent): number =>\n amount.value === \"infinite\" ? Number.POSITIVE_INFINITY : valueIn(amount as Quantity, \"ms\");\n\n/** This function gives an amount in milliseconds, or undefined for \"infinite\". Each driver then writes its own form of \"no timer\". */\nexport const finiteMs = (amount: Extent): number | undefined => {\n const value = ms(amount);\n return Number.isFinite(value) ? value : undefined;\n};\n\n/** This function gives the text of an error. */\nexport const message = (error: unknown): string => (error instanceof Error ? error.message : String(error));\n\n/**\n * These are the knobs that each client has, by the names of the ordering law. Each driver adds its\n * own knobs. The comments of each driver tell which option of the driver a knob sets.\n */\nexport interface ClientKnobs {\n /** This time bounds a new connection. */\n readonly connect_bound: Quantity;\n /** This time bounds each call on the connection of the application. */\n readonly request_timeout: Quantity;\n /** This time is the idle time of TCP keepalive. Node then sends 10 probes 1 s apart. */\n readonly keepalive_idle: Extent;\n /** This time is the age at which the client replaces a connection. */\n readonly max_connection_age: Extent;\n /** This time bounds the close of the client at the shutdown. */\n readonly close_bound: Quantity;\n /**\n * This time is when the kernel gives up a segment that it retransmits. Node cannot set it, thus\n * the declaration states it for the ordering law (O17), from the platform.\n */\n readonly retrans_giveup_time: Extent;\n}\n\n/** A client spec is the declaration of one client: where it connects, and its knobs. Each driver adds its own fields. */\nexport interface ClientSpec<K extends ClientKnobs = ClientKnobs> {\n readonly host: string;\n readonly port: number;\n readonly password?: string | undefined;\n /** This identifier is the component in the corpus, for example `systems.component.redis`, or null. */\n readonly system: string | null;\n readonly knobs: K;\n /** These operations add to the table of the client, or change it. */\n readonly operations?: Readonly<Record<string, Operation>> | undefined;\n}\n\n/** A factory makes the connection or the pool of a client from the options of its driver. */\nexport type Factory<O, C> = (options: O) => C | Promise<C>;\n\n/** These options make a client. Without them, a client uses its driver, the real clock, and the dial of its protocol. */\nexport interface ClientOptions<F> {\n readonly create?: F | undefined;\n readonly clock?: Clock | undefined;\n /** This function receives each transition of the client, for the prober (D3). */\n readonly record?: Recorder | undefined;\n readonly dial?: DialFn | undefined;\n}\n\n/** A client socket is the part of the socket of a connection that the join of the prober and the bounded close read. */\nexport interface ClientSocket {\n readonly localAddress?: string | undefined;\n readonly localPort?: number | undefined;\n readonly remoteAddress?: string | undefined;\n readonly remotePort?: number | undefined;\n /** This method closes the socket at once. A close of the driver only half-closes it, and a silent peer does not answer that. */\n destroy?(): void;\n}\n\n/**\n * A client join is one connection, at the time when it can serve (D1, D2). The prober joins its\n * kernel records to the server's view of the connection through it. Each driver adds the server's id of the connection.\n */\nexport interface ClientJoin {\n readonly generation: number;\n /** This time is when the connection became ready, in milliseconds on the monotonic clock. */\n readonly at: number;\n readonly localAddress: string | null;\n readonly localPort: number | null;\n readonly remoteAddress: string | null;\n readonly remotePort: number | null;\n}\n\n/** This function gives the addresses and the ports of a socket for a join. Each one is null when the socket does not give it. */\nexport const socketEnds = (\n socket: ClientSocket | undefined,\n): Pick<ClientJoin, \"localAddress\" | \"localPort\" | \"remoteAddress\" | \"remotePort\"> => ({\n localAddress: socket?.localAddress ?? null,\n localPort: socket?.localPort ?? null,\n remoteAddress: socket?.remoteAddress ?? null,\n remotePort: socket?.remotePort ?? null,\n});\n\n/** A client is a dependency of a service: its declaration, its handle and its checks. Each driver adds the method that sends a call. */\nexport interface Client<S extends Step = ClientStep, J extends ClientJoin = ClientJoin> {\n readonly name: string;\n /** This declaration goes to `svc.dependency(name, declaration, handle)`. */\n readonly declaration: Omit<Dependency, \"name\">;\n readonly handle: DependencyHandle;\n /** These are the manifestations that the client can meet, and the detectors of each (E9). */\n readonly meets: readonly Meeting[];\n /** This text is the state of the client, as the machine document of the client names it. */\n readonly status: string;\n /** These are the connections of the client, the latest last. */\n readonly joins: readonly J[];\n /** This method gives the checks of the client and their functions, for `svc.check(check, run)`. */\n checks(options: CheckOptions<S>): ReadonlyArray<readonly [Check, CheckFn]>;\n /** This method declares the client in a service: its dependency, its handle and its checks. */\n attach(svc: ServiceBuilder, options: CheckOptions<S>): ServiceBuilder;\n /** This method gives the problems of the client in a description: a close that does not fit in its phase, for example. */\n problems(description: ServiceDescription): string[];\n}\n\n/** This function declares a client in a service: its dependency, its handle, and each of its checks. */\nexport const attachClient = (\n svc: ServiceBuilder,\n name: string,\n declaration: Omit<Dependency, \"name\">,\n handle: DependencyHandle,\n checks: ReadonlyArray<readonly [Check, CheckFn]>,\n): ServiceBuilder => {\n svc.dependency(name, declaration, handle);\n for (const [check, run] of checks) svc.check(check, run);\n return svc;\n};\n\n/** This function gives the table of operations of a client: the defaults of its driver, then the operations of its spec. */\nexport const operationTable = (\n defaults: Readonly<Record<string, Operation>>,\n more: Readonly<Record<string, Operation>> | undefined,\n): Readonly<Record<string, Operation>> => ({ ...defaults, ...more });\n\n/** A client recorder gives one transition of a client to the recorder of the options, for the prober (D3). */\nexport type ClientRecorder = (from: string, to: string, on: string, detail?: string) => void;\n\n/** This function makes the recorder of a client. Each event has the machine \"client\", and the name of the client as its instance. */\nexport const clientRecorder =\n (record: Recorder | undefined, clock: Clock, name: string): ClientRecorder =>\n (from, to, on, detail) =>\n record?.({ at: clock.now(), machine: \"client\", instance: name, from, to, on, ...(detail === undefined ? {} : { detail }) });\n\n/** This function gives the outcome of a call that did not leave the client. It is certain: the call did not apply. */\nexport const notSent = (error: string): Attempt<never> => ({ outcome: \"error\", error, reply: false });\n\n/** A settle function gives the outcome of a call in flight. A driver can give a cause, for example the error that ends a client of a pool. */\nexport type Settle<T = unknown> = (value: Attempt<T>, cause?: Error) => void;\n\n/**\n * This record holds the calls in flight of a client. Each call settles one time. A call that the\n * caller abandons after it left the client is indeterminate, because a sent call cannot be\n * cancelled (principle 9). The close and a closed connection settle each call that stays (C10).\n */\nexport interface InFlight {\n /** This number is the count of the calls in flight. */\n readonly size: number;\n /**\n * This method sends one call, and records it until it settles. `start` sends the call, and gives\n * its outcome to `settle`. `after` operates one time, after the call settles and before its promise resolves.\n */\n track<T>(\n signal: AbortSignal | undefined,\n abandoned: string,\n start: (settle: Settle<T>) => void,\n after?: (value: Attempt<T>, cause: Error | undefined) => void,\n ): Promise<Attempt<T>>;\n /** This method settles each call in flight as indeterminate, with this error. */\n settleAll(error: string): void;\n /** This method resolves when no call is in flight. A close that waits for its calls uses it in its bound. */\n idle(): Promise<void>;\n}\n\n/** This function makes the record of the calls in flight of a client. */\nexport const inFlight = (): InFlight => {\n const closes = new Set<(error: string) => void>();\n const waiters = new Set<() => void>();\n const wake = (): void => {\n if (closes.size > 0) return;\n for (const waiter of [...waiters]) waiter();\n waiters.clear();\n };\n return {\n get size() {\n return closes.size;\n },\n idle: () =>\n new Promise<void>((resolve) => {\n if (closes.size === 0) resolve();\n else waiters.add(resolve);\n }),\n track<T>(\n signal: AbortSignal | undefined,\n abandoned: string,\n start: (settle: Settle<T>) => void,\n after?: (value: Attempt<T>, cause: Error | undefined) => void,\n ): Promise<Attempt<T>> {\n return new Promise<Attempt<T>>((resolve) => {\n let settled = false;\n const settle: Settle<T> = (value, cause) => {\n if (settled) return;\n settled = true;\n closes.delete(close);\n signal?.removeEventListener(\"abort\", aborted);\n after?.(value, cause);\n resolve(value);\n wake();\n };\n const close = (error: string): void => settle({ outcome: \"indeterminate\", error }, new Error(error));\n const aborted = (): void => close(abandoned);\n closes.add(close);\n signal?.addEventListener(\"abort\", aborted, { once: true });\n start(settle);\n });\n },\n settleAll(error) {\n for (const close of [...closes]) close(error);\n },\n };\n};\n\n/**\n * This function sends one call through the record of the calls in flight, with a timer of the\n * wrapper. A driver with no timer for its call uses it: amqplib, and the agent of Node. At `bound`\n * milliseconds the call is indeterminate with the error `timedOut`, because it left the client.\n * The timer stops when the call settles, before `after` operates.\n */\nexport const trackWithTimer = <T>(\n flight: InFlight,\n clock: Clock,\n bound: number,\n signal: AbortSignal | undefined,\n abandoned: string,\n timedOut: string,\n start: (settle: Settle<T>) => void,\n after?: (value: Attempt<T>, cause: Error | undefined) => void,\n): Promise<Attempt<T>> => {\n let stop: Cancel = () => {};\n return flight.track<T>(\n signal,\n abandoned,\n (settle) => {\n stop = clock.after(bound, () => settle({ outcome: \"indeterminate\", error: timedOut }));\n start(settle);\n },\n (value, cause) => {\n stop();\n after?.(value, cause);\n },\n );\n};\n\n/**\n * This function waits for the work of a close, for `bound` milliseconds at most. It gives true when\n * the work ended in its bound, with a success or a failure. It gives false at the bound. The driver\n * then destroys each socket that stays, because a silent server does not close its half.\n */\nexport const withinBound = (clock: Clock, bound: number, work: Promise<unknown>): Promise<boolean> => {\n const done = work.then(\n () => true,\n () => true,\n );\n let cancel: Cancel = () => {};\n const timer = new Promise<boolean>((resolve) => {\n cancel = clock.after(bound, () => resolve(false));\n });\n return Promise.race([done, timer]).then((ended) => {\n cancel();\n return ended;\n });\n};\n\n/**\n * A ready wait holds the calls that wait for a ready connection before their second try. A client\n * that connects again by itself uses it: Redis and RabbitMQ.\n */\nexport interface ReadyWait {\n /** This method waits until the client is ready, for `within` milliseconds at most. It gives true when the client is ready. */\n wait(within: number, signal?: AbortSignal): Promise<boolean>;\n /** This method ends each wait with true. The client uses it when its connection is ready. */\n wake(): void;\n}\n\n/** This function makes the ready wait of a client. The function `ready` tells if the client is ready. */\nexport const readyWait = (clock: Clock, ready: () => boolean): ReadyWait => {\n const waiters = new Set<() => void>();\n return {\n wait: (within, signal) =>\n new Promise((resolve) => {\n if (ready()) {\n resolve(true);\n return;\n }\n let cancel: Cancel = () => {};\n const done = (value: boolean): void => {\n waiters.delete(wake);\n cancel();\n signal?.removeEventListener(\"abort\", aborted);\n resolve(value);\n };\n const wake = (): void => done(true);\n const aborted = (): void => done(false);\n waiters.add(wake);\n cancel = clock.after(within, () => done(ready()));\n signal?.addEventListener(\"abort\", aborted, { once: true });\n }),\n wake() {\n for (const wake of [...waiters]) wake();\n },\n };\n};\n\n/** These are the knobs of a client that connects again by itself, after a delay that doubles. */\nexport interface RetryKnobs {\n /** This time is the first delay before a new try to connect. The delay doubles after each try. */\n readonly retry_base: Quantity;\n /** This time is the most that one delay can be, before its jitter. */\n readonly retry_cap: Quantity;\n}\n\n/**\n * This function gives the backoff of the tries to connect: from `retry_base`, doubling to\n * `retry_cap`, each with a jitter up to the base. The client rounds each delay to a whole millisecond.\n */\nexport const retryBackoff = (knobs: RetryKnobs): Backoff => ({\n base: ms(knobs.retry_base),\n factor: 2,\n cap: ms(knobs.retry_cap),\n jitter: { kind: \"add\", amount: ms(knobs.retry_base) },\n});\n\n/**\n * A retry schedule holds the next try to connect, for a client that connects again by itself. It\n * counts the tries since the last join. Each delay comes from the backoff, rounded to a whole millisecond.\n */\nexport interface RetrySchedule {\n /** This count is the number of tries since the last reset. */\n readonly tries: number;\n /** This method counts one more try, and starts `due` after the delay of that try. It stops a try that waits. */\n schedule(due: () => void): void;\n /** This method stops the try that waits. The close uses it. */\n cancel(): void;\n /** This method sets the count of tries to zero. The client uses it at each join. */\n reset(): void;\n}\n\n/** This function makes the retry schedule of a client, from its backoff and its random numbers. RabbitMQ and WebSocket use it. */\nexport const retrySchedule = (clock: Clock, backoff: Backoff, random: () => number): RetrySchedule => {\n // the public retrier does the same work: the schedule only names its count `tries`\n const retry = retrierOn(clock, backoff, random);\n return {\n get tries() {\n return retry.attempts;\n },\n schedule(due) {\n retry.schedule(due);\n },\n cancel: () => retry.cancel(),\n reset: () => retry.reset(),\n };\n};\n\n/** This function gives the problems of the retry knobs: the cap must not be below the base. */\nexport const retryProblems = (name: string, knobs: RetryKnobs): string[] =>\n ms(knobs.retry_cap) < ms(knobs.retry_base) ? [`${name}'s retry_cap is below its retry_base`] : [];\n\n/**\n * This function gives the problem of a count of misses that is not a whole number above zero. A\n * client that closes its connection after a count of heartbeat misses uses it. `mechanism` names the heartbeat, for example \"watchdog\".\n */\nexport const missesProblems = (name: string, misses: number, mechanism: string): string[] =>\n Number.isInteger(misses) && misses >= 1 ? [] : [`${name}'s ${mechanism} closes the connection after ${misses} misses, not a whole number above zero`];\n\n/** This function gives the problems of the knobs of a spec that each client has: each knob must be a time of zero or more. */\nexport const timeProblems = (name: string, knobs: object): string[] => {\n const problems: string[] = [];\n for (const [knob, amount] of Object.entries(knobs) as Array<[string, Extent]>) {\n if (amount.value !== \"infinite\" && !(ms(amount) >= 0)) problems.push(`${name}'s ${knob} is not a time of zero or more`);\n }\n return problems;\n};\n\n/** This function writes a bound for a driver that reads 0 as no timer: \"infinite\" is 0. */\nexport const orZero = (amount: Extent): number => finiteMs(amount) ?? 0;\n\n/** This function tells if an amount is a whole number of milliseconds. \"infinite\" is whole. */\nexport const wholeMs = (amount: Extent): boolean => amount.value === \"infinite\" || Number.isInteger(ms(amount));\n\n/** This function tells if an amount is a whole number of seconds. \"infinite\" is whole. */\nexport const wholeSeconds = (amount: Extent): boolean =>\n amount.value === \"infinite\" || Number.isInteger(valueIn(amount as Quantity, \"s\"));\n\n/** These are the knobs of a spec that `zeroProblems` and `wholeProblems` examine, by their kind. */\nexport interface KnobKinds {\n /** These knobs must be a finite time above zero, because the driver reads 0 as no bound. */\n readonly bounded?: readonly string[] | undefined;\n /** These knobs can be \"infinite\", which the driver writes as 0. Thus 0 itself is not a bound. */\n readonly open?: readonly string[] | undefined;\n /** These knobs go to the driver in whole milliseconds. */\n readonly millis?: readonly string[] | undefined;\n /** These knobs go to the driver or to Node in whole seconds. */\n readonly seconds?: readonly string[] | undefined;\n}\n\nconst knobOf = (knobs: object, knob: string): Extent => (knobs as Record<string, Extent>)[knob]!;\n\n/**\n * This function gives the problems of the knobs of a driver that reads 0 as no timer. pg and the\n * MongoDB driver read 0 so. A bounded knob must be a finite time above zero. An open knob can be\n * \"infinite\", and 0 is then a mistake.\n */\nexport const zeroProblems = (name: string, driver: string, knobs: object, kinds: KnobKinds): string[] => {\n const problems: string[] = [];\n for (const knob of kinds.bounded ?? []) {\n const value = ms(knobOf(knobs, knob));\n if (!(value > 0) || !Number.isFinite(value)) problems.push(`${name}'s ${knob} is not a finite time above zero: ${driver} reads 0 as no bound`);\n }\n for (const knob of kinds.open ?? []) {\n const amount = knobOf(knobs, knob);\n if (amount.value !== \"infinite\" && !(ms(amount) > 0)) problems.push(`${name}'s ${knob} is zero: give \"infinite\" for no bound`);\n }\n return problems;\n};\n\n/** This function gives the problems of the knobs that a driver takes in whole milliseconds or in whole seconds. */\nexport const wholeProblems = (name: string, knobs: object, kinds: KnobKinds): string[] => [\n ...(kinds.millis ?? []).filter((knob) => !wholeMs(knobOf(knobs, knob))).map((knob) => `${name}'s ${knob} is not a whole number of milliseconds`),\n ...(kinds.seconds ?? []).filter((knob) => !wholeSeconds(knobOf(knobs, knob))).map((knob) => `${name}'s ${knob} is not a whole number of seconds`),\n];\n\n/** This function gives the problems of the sizes of a pool: at most `max` connections, and `min` from 0 to `max`. */\nexport const poolProblems = (name: string, pool: { readonly max: number; readonly min: number }): string[] => {\n const problems: string[] = [];\n if (!Number.isInteger(pool.max) || pool.max < 1) problems.push(`${name}'s pool has a max of ${pool.max}, not a whole number above zero`);\n if (!Number.isInteger(pool.min) || pool.min < 0 || pool.min > pool.max)\n problems.push(`${name}'s pool has a min of ${pool.min}, not a whole number from 0 to its max`);\n return problems;\n};\n\n/**\n * This function gives the problem O07 of a client whose server has a deadline, or null. The client\n * must wait longer than the deadline of the server. Then the server ends a slow call with an error\n * first. Otherwise the client gives up first, and the server goes on with the call. `call` names\n * the call of the server, for example a statement.\n */\nexport const deadlineProblem = (name: string, request: Quantity, deadline: Extent, call: string): string | null =>\n deadline.value !== \"infinite\" && ms(request) <= ms(deadline)\n ? `${name}'s request_timeout is not above its statement_timeout: the server goes on with a ${call} that the client gave up (O07)`\n : null;\n\n/**\n * This function gives the problem O01 of a client pool, or null. The pool must close an idle\n * connection before its server does. Otherwise a request can go on a connection that the server\n * closed. A server that keeps an idle connection with no bound gives no problem. `knob` names the\n * idle time of the client: `pool_idle_expiry` of a pool, or `client_idle_timeout` of a gRPC channel.\n */\nexport const idleCloseProblem = (name: string, expiry: Extent, close: Extent, knob = \"pool_idle_expiry\"): string | null =>\n close.value !== \"infinite\" && !(ms(expiry) < ms(close))\n ? `${name}'s ${knob} is not below the idle close of its server: a request can go on a connection that the server closed (O01)`\n : null;\n\n/**\n * This function gives the problems of the timers that the wrapper has, because its driver has none.\n * Each one must be a finite time above zero. `bounds` gives what each knob bounds, for example \"a call\".\n */\nexport const wrapperTimerProblems = (name: string, knobs: object, bounds: Readonly<Record<string, string>>): string[] =>\n Object.entries(bounds)\n .filter(([knob]) => {\n const value = ms(knobOf(knobs, knob));\n return !(value > 0) || !Number.isFinite(value);\n })\n .map(([knob, what]) => `${name}'s ${knob} is not a finite time above zero: the timer of the wrapper is the only bound of ${what}`);\n\n/** This function gives the problem of a finite connection age, for a client that does not replace a connection at an age. `reason` tells why. */\nexport const ageProblems = (name: string, knobs: Pick<ClientKnobs, \"max_connection_age\">, reason: string): string[] =>\n knobs.max_connection_age.value === \"infinite\" ? [] : [`${name}'s max_connection_age is not \"infinite\": ${reason}`];\n\n/** This function gives the problem of a keepalive that is not a finite time above zero, for a driver that always turns keepalive on. */\nexport const keepaliveOnProblems = (name: string, knobs: Pick<ClientKnobs, \"keepalive_idle\">, driver: string): string[] => {\n const value = ms(knobs.keepalive_idle);\n return value > 0 && Number.isFinite(value) ? [] : [`${name}'s keepalive_idle is not a finite time above zero: ${driver} always turns keepalive on`];\n};\n\n/** These are the parts of one call that the core uses to send it, and to send it again. */\nexport interface Reissue<T> {\n readonly clock: Clock;\n /** This time bounds the call and its second try, in milliseconds from its start. */\n readonly bound: number;\n /** This operation is the declaration of the call, or undefined when the table does not name it. */\n readonly operation: Operation | undefined;\n readonly options: SendOptions;\n /** This function makes one try. Its signal ends the try. */\n readonly attempt: (signal: AbortSignal | undefined) => Promise<Attempt<T>>;\n /** This function operates before the second try, with the time that is left. False stops the second try. */\n readonly beforeAgain?: ((left: number, signal: AbortSignal | undefined) => Promise<boolean>) | undefined;\n /** This function receives the start of a second try, for the record of the client. */\n readonly onReissue: () => void;\n}\n\n/**\n * This function sends a call, and gives its outcome in three values. It sends again only an\n * idempotent operation, one time at most, after an outcome that is not certain. A reply of the\n * server is certain. The second try ends at the bound of the call, not one bound after its own start.\n */\nexport const sendWithReissue = async <T>(call: Reissue<T>): Promise<Sent<T>> => {\n const { clock, bound } = call;\n const { signal } = call.options;\n const operation = call.options.reissue === false ? undefined : call.operation;\n const started = clock.now();\n const first = await call.attempt(signal);\n if (first.outcome === \"ok\") return { outcome: \"ok\", value: first.value, attempts: 1 };\n const again =\n !(first.outcome === \"error\" && first.reply) &&\n operation !== undefined &&\n signal?.aborted !== true &&\n mayReissue(operation, quantity((clock.now() - started) / 1000, \"s\"));\n const left = bound - (clock.now() - started);\n if (!again || left <= 0) return { ...first, attempts: 1 };\n if (call.beforeAgain !== undefined && !(await call.beforeAgain(left, signal))) return { ...first, attempts: 1 };\n call.onReissue();\n const end = new AbortController();\n const stop = clock.after(Math.max(0, bound - (clock.now() - started)), () => end.abort());\n const forward = (): void => end.abort();\n signal?.addEventListener(\"abort\", forward, { once: true });\n const second = await call.attempt(end.signal);\n stop();\n signal?.removeEventListener(\"abort\", forward);\n return second.outcome === \"ok\" ? { outcome: \"ok\", value: second.value, attempts: 2 } : { ...second, attempts: 2 };\n};\n\n/**\n * This function gives the checks of a client, for `svc.check(check, run)`. Without a catalog, it gives\n * a check for each step that the options name, when the client has a function for that step. With a\n * catalog, it gives a check for each step of the client. It then throws for a nominated step that the\n * client does not have (B19). The name of each check is the pair of the component and the step, a\n * public contract.\n */\nexport const stepChecks = <S extends Step>(\n name: string,\n options: CheckOptions<S>,\n runs: Readonly<Partial<Record<S, StepCheck>>>,\n): ReadonlyArray<readonly [Check, CheckFn]> => {\n const has = (Object.entries(runs) as Array<[S, StepCheck | undefined]>).filter(([, run]) => run !== undefined).map(([step]) => step);\n const catalog = options.catalog === true ? { ...options.poll, interval: CATALOG_INTERVAL } : options.catalog;\n if (catalog !== undefined) {\n const missing = Object.keys(options.steps).filter((step) => !has.includes(step as S));\n if (missing.length > 0) {\n throw new Error(`${name}: the nominated checks ${missing.join(\", \")} are not in the catalog of the client (${has.join(\", \")})`);\n }\n }\n const made: Array<readonly [Check, CheckFn]> = [];\n for (const step of has) {\n const run = runs[step] as StepCheck;\n const nominated = step in options.steps;\n if (!nominated && catalog === undefined) continue;\n made.push([\n {\n name: `${name}.${step}`,\n dependency: name,\n step,\n ownConnection: run.ownConnection,\n gates: nominated ? (options.steps[step] ?? null) : null,\n poll: nominated || catalog === undefined ? options.poll : catalog,\n },\n run.run,\n ]);\n }\n return made;\n};\n\n/** This function makes a check outcome from a sent result: only `ok` passes. */\nexport const passes = (sent: Sent<unknown>): Outcome => (sent.outcome === \"ok\" ? \"ok\" : \"error\");\n\n/** This check gives the state of the client, without a round trip. */\nexport const localStateCheck = (ready: () => boolean): StepCheck => ({ ownConnection: true, run: () => (ready() ? \"ok\" : \"error\") });\n\n/**\n * This check sends one call on the connection of the application. A check measures the step at this time.\n * Thus it does not send the call again, and only `ok` passes.\n */\nexport const roundTripCheck = (send: (options: SendOptions) => Promise<Sent<unknown>>): StepCheck => ({\n ownConnection: true,\n run: async (signal) => passes(await send({ signal, reissue: false })),\n});\n\n/**\n * This check opens a new connection each time. It finds a server that refuses connections, but not\n * a stalled connection of the application. A failed dial throws, and the poller counts the throw as an error.\n */\nexport const dialCheck = (dial: DialFn, host: string, port: number): StepCheck => ({\n ownConnection: false,\n run: async (signal) => {\n await dial(host, port, signal);\n return \"ok\" as const;\n },\n});\n\n/** These are the bounds of a client that the core examines in a description. */\nexport interface ClientBounds {\n /** This time bounds the close of the client, in milliseconds. */\n readonly close: number;\n /** This time bounds a call on the connection of the application, in milliseconds. */\n readonly request: number;\n}\n\n/** This function gives the bounds of a client that `clientProblems` examines, from its knobs. */\nexport const clientBounds = (knobs: ClientKnobs): ClientBounds => ({ close: ms(knobs.close_bound), request: ms(knobs.request_timeout) });\n\n/**\n * This function gives the problems of a client in a description:\n * - The client needs the phase \"tear down dependencies\", and its close must fit in the cap of that phase.\n * - A round-trip check must end in one jittered poll (B7, O13).\n */\nexport const clientProblems = (name: string, description: ServiceDescription, bounds: ClientBounds): string[] => {\n const found: string[] = [];\n const teardown = description.shutdown.phases.find((phase) => phase.name === \"tear down dependencies\");\n if (teardown === undefined) found.push(`${name} needs the phase \"tear down dependencies\" to close`);\n else if (bounds.close >= valueIn(teardown.cap, \"ms\"))\n found.push(`${name}'s close_bound of ${bounds.close} ms does not fit in the cap of \"tear down dependencies\"`);\n for (const check of description.checks) {\n if (check.dependency !== name || check.step !== \"round-trip\") continue;\n const slowest = valueIn(check.poll.timeout, \"ms\") + valueIn(check.poll.interval, \"ms\") * (1 + check.poll.jitter);\n if (bounds.request > slowest) found.push(`${name}'s request_timeout outlives one jittered poll of ${check.name} (B7, O13)`);\n }\n return found;\n};\n\n/**\n * This poll is a poll of the checks to start from: each 5 s with a jitter of 20 %, and a timeout of\n * 4 s (B6, O12). Its slowest poll is 4 s + 5 s × 1.2 = 10 s, the slowest poll of the cells of O13.\n * It does not depend on a driver. The starting knobs of each driver fit it.\n */\nexport const STARTING_POLL: Poll = { interval: { value: 5, unit: \"s\" }, jitter: 0.2, timeout: { value: 4, unit: \"s\"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