@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
package/build/http.d.ts
CHANGED
|
@@ -1,353 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { ListenOptions } from "node:net";
|
|
7
|
-
import { IncomingMessage, Server, ServerEventMap, ServerResponse } from "node:http";
|
|
8
|
-
import { Http2Server } from "node:http2";
|
|
9
|
-
/**
|
|
10
|
-
* These are the knobs of an HTTP transport, by the names of the ordering law. The transport has no
|
|
11
|
-
* defaults, thus each knob is necessary. The declaration of the server gets the same record.
|
|
12
|
-
*/
|
|
13
|
-
interface HttpKnobs {
|
|
14
|
-
/**
|
|
15
|
-
* This time is the real idle close of the server, which O01 compares with the idle time of a
|
|
16
|
-
* client. Node closes an idle connection at `keepAliveTimeout` plus `keepAliveTimeoutBuffer`.
|
|
17
|
-
* Thus the transport sets `keepAliveTimeout` to this time less the buffer of the server.
|
|
18
|
-
* A time without a bound stops the timer. On HTTP/2, the time is the timeout of a session with no
|
|
19
|
-
* frame (`server.setTimeout`). Node then sends GOAWAY and closes the session.
|
|
20
|
-
*/
|
|
21
|
-
readonly server_idle_close: Extent;
|
|
22
|
-
/**
|
|
23
|
-
* This time is the interval of the sweep of idle connections, from the stop of the intake until the
|
|
24
|
-
* close. A time without a bound gives one sweep, at the stop of the intake.
|
|
25
|
-
*/
|
|
26
|
-
readonly server_idle_sweep_interval: Extent;
|
|
27
|
-
/** This time goes in the `Retry-After` of each 503 that the transport gives after its intake stops. */
|
|
28
|
-
readonly server_retry_after: Quantity;
|
|
29
|
-
/**
|
|
30
|
-
* This count is the backlog of listen(2), the limit of the accept queue that the server asks for (SYS-103). The
|
|
31
|
-
* kernel clamps it to `net.core.somaxconn`, and a full queue holds the limit plus one (SYS-63). Without this
|
|
32
|
-
* knob, the transport gives no backlog, and Node asks for 511. The knob needs the listen options of the transport.
|
|
33
|
-
* The knob is 1 or more: Node gives listen(2) 511 for a backlog of 0 (`lib/net.js` of Node 24.21.0, line 2325).
|
|
34
|
-
*/
|
|
35
|
-
readonly server_listen_backlog?: Quantity;
|
|
36
|
-
/** The other knobs of the server go to the declaration. The transport does not read them. */
|
|
37
|
-
readonly [knob: string]: Extent;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* These are the knobs that the transport gives the declaration: the knobs of the caller, and the two
|
|
41
|
-
* times that the transport found. Thus the declaration shows the three times of the idle close.
|
|
42
|
-
*/
|
|
43
|
-
interface HttpTransportKnobs extends HttpKnobs {
|
|
44
|
-
/** This time is the hint that each response sends (`Keep-Alive: timeout=…`), in whole seconds. A time without a bound tells that no hint goes, as on HTTP/2. */
|
|
45
|
-
readonly server_idle_close_hint: Extent;
|
|
46
|
-
/** This time is the `keepAliveTimeoutBuffer` of the server, which Node adds to the timer and not to the hint. A server of HTTP/2 has none: 0 ms. */
|
|
47
|
-
readonly server_idle_close_buffer: Quantity;
|
|
48
|
-
}
|
|
49
|
-
/** A mount stage is the stage of the shutdown at which a mount stops: the stop of the intake, or the close. */
|
|
50
|
-
type MountStage = "stop intake" | "close transports";
|
|
51
|
-
/** A mount context gives each handler the signals of the shutdown, the lifecycle and the time of a retry. */
|
|
52
|
-
interface MountContext {
|
|
53
|
-
/** This signal aborts when the intake stops. A long stream ends in its own protocol at it. */
|
|
54
|
-
readonly intake: AbortSignal;
|
|
55
|
-
/** This signal aborts at the cooperative abort of the drain, or at the close. The work in flight stops at it. */
|
|
56
|
-
readonly signal: AbortSignal;
|
|
57
|
-
/** This lifecycle is the lifecycle that the transport got at its start, or null before the start. */
|
|
58
|
-
readonly life: Lifecycle | null;
|
|
59
|
-
/** This time is the knob `server_retry_after`: the `Retry-After` of each 503 of the handlers. */
|
|
60
|
-
readonly retryAfter: Quantity;
|
|
61
|
-
/**
|
|
62
|
-
* This function tells if a response of a handler can keep its connection open, as the transport
|
|
63
|
-
* decides it. The decision is the option `keepAlive` or `life.keepAlive()`, while the intake is
|
|
64
|
-
* open. Without this function, a handler reads `life.keepAlive()`.
|
|
65
|
-
*/
|
|
66
|
-
readonly keepAlive?: (() => boolean) | undefined;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* A request handler answers a request and gives true, or it gives false and does not touch the
|
|
70
|
-
* response. Then the next handler gets the request. `until` tells when the handler stops.
|
|
71
|
-
*/
|
|
72
|
-
interface RequestHandler {
|
|
73
|
-
(req: IncomingMessage, res: ServerResponse, context: MountContext): boolean | Promise<boolean>;
|
|
74
|
-
readonly until?: MountStage | undefined;
|
|
75
|
-
}
|
|
76
|
-
type UpgradeArgs = ServerEventMap["upgrade"];
|
|
77
|
-
/** An upgrade socket is the stream of an upgraded connection, as the `upgrade` event of Node gives it. */
|
|
78
|
-
type UpgradeSocket = UpgradeArgs[1];
|
|
79
|
-
/** An upgrade handler takes an upgraded connection, for example a WebSocket server in its `noServer` mode. */
|
|
80
|
-
interface UpgradeHandler {
|
|
81
|
-
(req: IncomingMessage, socket: UpgradeSocket, head: UpgradeArgs[2], context: MountContext): void;
|
|
82
|
-
readonly until?: MountStage | undefined;
|
|
83
|
-
}
|
|
84
|
-
/** An upgrade match is a path, without its query, or a function that tells if a handler takes a request. */
|
|
85
|
-
type UpgradeMatch = string | ((req: IncomingMessage) => boolean);
|
|
86
|
-
/** These options change one mount. */
|
|
87
|
-
interface MountOptions {
|
|
88
|
-
/**
|
|
89
|
-
* This stage is when the mount stops. Without it, the stage of the handler applies, and then
|
|
90
|
-
* `stop intake`. A mount until `close transports` keeps the listener open through the drain.
|
|
91
|
-
*/
|
|
92
|
-
readonly until?: MountStage | undefined;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* An edge server is the server of a transport: a server of `node:http`, or a server of `node:http2`
|
|
96
|
-
* without TLS (h2c, from `http2.createServer()`).
|
|
97
|
-
*/
|
|
98
|
-
type EdgeServer = Server | Http2Server;
|
|
99
|
-
/** These options make an HTTP transport. */
|
|
100
|
-
interface HttpTransportOptions<S extends EdgeServer = Server> {
|
|
101
|
-
/**
|
|
102
|
-
* These are the listen options of `start()`, or a function that makes the server listen. Without
|
|
103
|
-
* them, `start()` takes a server that listens already.
|
|
104
|
-
*/
|
|
105
|
-
readonly listen?: ListenOptions | ((server: S) => Promise<void> | void) | undefined;
|
|
106
|
-
/** This clock is the clock of the lifecycle. The deadline of the drain and the sweep use it. */
|
|
107
|
-
readonly clock?: Clock | undefined;
|
|
108
|
-
/**
|
|
109
|
-
* This function tells if a response can keep its connection open. Without it, the transport reads
|
|
110
|
-
* `life.keepAlive()` of the lifecycle of its start. The transport reads it when the headers of
|
|
111
|
-
* each response go. On HTTP/1.1, false gives `Connection: close`. On HTTP/2, false gives a GOAWAY
|
|
112
|
-
* on the session of the response.
|
|
113
|
-
*/
|
|
114
|
-
readonly keepAlive?: (() => boolean) | undefined;
|
|
115
|
-
/** This function receives each error of a handler. The transport then answers 500, or it destroys the response. */
|
|
116
|
-
readonly onError?: ((error: unknown, req: IncomingMessage) => void) | undefined;
|
|
117
|
-
/**
|
|
118
|
-
* With this call context, each handler runs in the context of the headers of its request. The context
|
|
119
|
-
* has the trace of `traceparent`, and the baggage of a trusted request. `callContext` of the entry `/otel` gives one.
|
|
120
|
-
*/
|
|
121
|
-
readonly callContext?: CallContext | undefined;
|
|
122
|
-
/**
|
|
123
|
-
* This function tells if the baggage of a request is trusted, for example after a token check. The
|
|
124
|
-
* default trusts no request: each request joins the trace of its caller, and its baggage is dropped.
|
|
125
|
-
*/
|
|
126
|
-
readonly trustBaggage?: ((req: IncomingMessage) => boolean) | undefined;
|
|
127
|
-
}
|
|
128
|
-
/** An HTTP transport is a server of `node:http` or `node:http2` as a transport of the lifecycle, with a list of mounts on its listener. */
|
|
129
|
-
interface HttpTransport<S extends EdgeServer = Server> extends TransportImpl {
|
|
130
|
-
readonly server: S;
|
|
131
|
-
/** These knobs go to the declaration of the server: the knobs of the caller, the hint and the buffer. */
|
|
132
|
-
readonly knobs: HttpTransportKnobs;
|
|
133
|
-
/** This method adds a request handler at the end of the list, and gives the function that removes it. */
|
|
134
|
-
mount(handler: RequestHandler, options?: MountOptions): () => void;
|
|
135
|
-
/** This method adds an upgrade handler for a path, and gives the function that removes it. A server of HTTP/2 has no upgrade, thus it refuses the handler. */
|
|
136
|
-
upgrade(match: UpgradeMatch, handler: UpgradeHandler, options?: MountOptions): () => void;
|
|
137
|
-
/** This count is the number of open connections, idle connections and upgraded connections too. On HTTP/2, a connection is the socket of a session. */
|
|
138
|
-
readonly connections: number;
|
|
139
|
-
/** This flag tells if the transport stopped its intake. */
|
|
140
|
-
readonly intakeStopped: boolean;
|
|
141
|
-
}
|
|
142
|
-
/** This function gives the path of a request target, without its query and fragment. */
|
|
143
|
-
export declare const pathOf: (url: string | undefined) => string;
|
|
144
|
-
/**
|
|
145
|
-
* This function makes a server of `node:http` or `node:http2` a transport of the lifecycle (S6 A8 and
|
|
146
|
-
* A13). It is not a framework: it has no routes, no body parser and no middleware.
|
|
147
|
-
* - The count of work in flight comes from events: each response until its `close`, and each upgraded
|
|
148
|
-
* connection until its `close`.
|
|
149
|
-
* - `stopIntake` closes the listener, and new connections get a refusal. It closes the idle connections
|
|
150
|
-
* at once and at each `server_idle_sweep_interval`. Each later response gets `Connection: close`.
|
|
151
|
-
* A connection is not idle while the bytes of its answer go (SYS-33).
|
|
152
|
-
* - `drain` waits until no work is in flight, or until the deadline. It gives the cooperative abort to
|
|
153
|
-
* the handlers through their context. At the deadline, it also waits for each answer that is to come
|
|
154
|
-
* or to go out (SYS-29). The cap of the phase bounds that wait. Answers that did not go out by the
|
|
155
|
-
* cap are not a failure of the phase. A stream outside the lifecycle of the transport does not hold it.
|
|
156
|
-
* - `close` destroys each connection. A second close gives the same promise.
|
|
157
|
-
* - The mounts share one port. The first request handler that gives true answers. After the stop of
|
|
158
|
-
* the intake, only the mounts until `close transports` answer, and each other request gets a 503.
|
|
159
|
-
* - HTTP/2 has no `Connection` header (RFC 9113, section 8.2.2). Thus a close of a connection is a
|
|
160
|
-
* GOAWAY on its session. Each handler gets the request and the response of the compatibility API of
|
|
161
|
-
* `node:http2`. They have the parts of the API that the handlers of this entry use. A handler that
|
|
162
|
-
* gives `Connection: close` gets a GOAWAY. The stop of the intake sends GOAWAY on each session, and
|
|
163
|
-
* the close destroys each session.
|
|
164
|
-
*/
|
|
165
|
-
export declare const httpTransport: <S extends EdgeServer = Server>(edge: S, knobs: HttpKnobs, options?: HttpTransportOptions<S>) => HttpTransport<S>;
|
|
166
|
-
/** A probe response is the status, the headers and the body of one probe, for any HTTP framework or none. */
|
|
167
|
-
interface ProbeResponse {
|
|
168
|
-
readonly status: number;
|
|
169
|
-
readonly headers: Readonly<Record<string, string>>;
|
|
170
|
-
readonly body: string;
|
|
171
|
-
}
|
|
172
|
-
/** A health source is the health runtime, or a function that gives it when it exists. */
|
|
173
|
-
type HealthSource = Health | (() => Health | null | undefined);
|
|
174
|
-
/**
|
|
175
|
-
* These are the four probe kinds, in the sequence of their paths. A probe server and a probe handler
|
|
176
|
-
* answer all four, unless their option `kinds` names fewer.
|
|
177
|
-
*/
|
|
178
|
-
export declare const PROBE_KINDS: readonly ProbeKind[];
|
|
179
|
-
/**
|
|
180
|
-
* Probe paths are more paths for each probe kind, for example `{ liveness: ["/livez", "/healthz"] }`.
|
|
181
|
-
* Each path is a whole path, and the prefix does not go before it. The paths of `PROBE_KINDS` still answer.
|
|
182
|
-
*/
|
|
183
|
-
type ProbePaths = Partial<Readonly<Record<ProbeKind, readonly string[]>>>;
|
|
184
|
-
/**
|
|
185
|
-
* This function gives the response of a probe path from the cache of the health runtime. For a path
|
|
186
|
-
* that is not a probe, it gives null. The paths are `/startup`, `/readiness`, `/liveness` and
|
|
187
|
-
* `/report` after the prefix. `/readiness/<controller>` gives the readiness of one controller.
|
|
188
|
-
* `kinds` names the probes that answer. The path of a kind that it does not name is not a probe.
|
|
189
|
-
*
|
|
190
|
-
* `aliases` gives the probe kind of each more path. A more path of readiness has no controller.
|
|
191
|
-
*/
|
|
192
|
-
export declare const probeResponse: (health: Health | null | undefined, method: string | undefined, path: string, prefix?: string, kinds?: readonly ProbeKind[], aliases?: ReadonlyMap<string, ProbeKind>) => ProbeResponse | null;
|
|
193
|
-
/** These options mount the probes on the port of the application. */
|
|
194
|
-
interface ProbeHandlerOptions {
|
|
195
|
-
/** This path goes before each probe path, for example `/health`. It starts with `/`, or it is empty. */
|
|
196
|
-
readonly prefix: string;
|
|
197
|
-
/**
|
|
198
|
-
* These are the probes that the handler answers. The default is all four of `PROBE_KINDS`. The
|
|
199
|
-
* path of a kind that the list does not name goes to the next handler.
|
|
200
|
-
*/
|
|
201
|
-
readonly kinds?: readonly ProbeKind[] | undefined;
|
|
202
|
-
/**
|
|
203
|
-
* These are more paths for each probe kind, for example `{ liveness: ["/livez", "/healthz"] }`. Each is
|
|
204
|
-
* a whole path, with no prefix. Without them, the handler answers only the paths of `PROBE_KINDS`.
|
|
205
|
-
*/
|
|
206
|
-
readonly paths?: ProbePaths | undefined;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* This function gives a request handler that answers the probes on the port of the application. It
|
|
210
|
-
* answers until `close transports`, thus its mount keeps the listener open through the drain. A path
|
|
211
|
-
* that is not a probe goes to the next handler. Each 503 gets the `Retry-After` of the context.
|
|
212
|
-
*/
|
|
213
|
-
export declare const probeHandler: (health: HealthSource, options: ProbeHandlerOptions) => RequestHandler;
|
|
214
|
-
/** These options make a probe server: the listen options of its port, the prefix of its paths, and the time of a retry. */
|
|
215
|
-
interface ProbeServerOptions extends ListenOptions {
|
|
216
|
-
/**
|
|
217
|
-
* This time goes in the `Retry-After` of each 503 of a probe, as on the port of the application.
|
|
218
|
-
* The probe server has no defaults, thus the knob is necessary.
|
|
219
|
-
*/
|
|
220
|
-
readonly server_retry_after: Quantity;
|
|
221
|
-
/** This path goes before each probe path. The default is no prefix, because the port has only the probes. */
|
|
222
|
-
readonly prefix?: string | undefined;
|
|
223
|
-
/** This server answers the probes. Without it, the probe server makes a server of `node:http`. */
|
|
224
|
-
readonly server?: Server | undefined;
|
|
225
|
-
/**
|
|
226
|
-
* These are the probes that the server answers. The default is all four of `PROBE_KINDS`. The path
|
|
227
|
-
* of a kind that the list does not name gets 404, as each other path.
|
|
228
|
-
*/
|
|
229
|
-
readonly kinds?: readonly ProbeKind[] | undefined;
|
|
230
|
-
/** These are more paths for each probe kind, as the option `paths` of `probeHandler`. */
|
|
231
|
-
readonly paths?: ProbePaths | undefined;
|
|
232
|
-
}
|
|
233
|
-
/** A probe server is a health server on its own port. Its server is visible for the address of the port. */
|
|
234
|
-
interface ProbeServer extends HealthServer {
|
|
235
|
-
readonly server: Server;
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* This function makes a health server on a port of its own (S6 decision D5). It starts first and
|
|
239
|
-
* closes last, thus the probes answer through the whole drain. Each probe answers from the cache, and
|
|
240
|
-
* each 503 gets the `Retry-After` of `server_retry_after`.
|
|
241
|
-
*/
|
|
242
|
-
export declare const probeServer: (options: ProbeServerOptions) => ProbeServer;
|
|
243
|
-
/** An outcome response is the status, the headers and the body of a request, for any HTTP framework or none. */
|
|
244
|
-
interface OutcomeResponse {
|
|
245
|
-
readonly status: number;
|
|
246
|
-
readonly headers: Readonly<Record<string, string>>;
|
|
247
|
-
readonly body: string | Uint8Array;
|
|
248
|
-
}
|
|
249
|
-
/** A response part is what a hook gives for one value or one failure. The parts that it does not give keep the values of the mapping. */
|
|
250
|
-
interface ResponsePart {
|
|
251
|
-
readonly status?: number | undefined;
|
|
252
|
-
readonly headers?: Readonly<Record<string, string>> | undefined;
|
|
253
|
-
readonly body?: string | Uint8Array | undefined;
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* A stream format writes the items of a stream and its end in the body, as they come. An end after
|
|
257
|
-
* the first item goes in the body, because the status went with the first item.
|
|
258
|
-
*/
|
|
259
|
-
interface StreamFormat<T = unknown> {
|
|
260
|
-
readonly contentType: string;
|
|
261
|
-
/** This function gives the bytes of one item. */
|
|
262
|
-
item(value: T): string | Uint8Array;
|
|
263
|
-
/** This function gives the bytes of the end, the last part of the body. */
|
|
264
|
-
end(end: RequestEnd): string | Uint8Array;
|
|
265
|
-
}
|
|
266
|
-
/** These options map a request to a response. */
|
|
267
|
-
interface OutcomeOptions<T> {
|
|
268
|
-
/**
|
|
269
|
-
* This value tells if the response can keep its connection open, as `life.keepAlive()` does. False
|
|
270
|
-
* gives `Connection: close`. A function is read when the headers go.
|
|
271
|
-
*/
|
|
272
|
-
readonly keepAlive: boolean | (() => boolean);
|
|
273
|
-
/** This time goes in the `Retry-After` of each 503, in whole seconds, rounded up. It is the knob `server_retry_after`. */
|
|
274
|
-
readonly retryAfter: Quantity;
|
|
275
|
-
/**
|
|
276
|
-
* This function gives the response of the value of a unary request. Without it, the mapping gives
|
|
277
|
-
* 200 and the value as JSON, or 204 for no value.
|
|
278
|
-
*/
|
|
279
|
-
readonly done?: ((value: T) => ResponsePart) | undefined;
|
|
280
|
-
/**
|
|
281
|
-
* This function gives the response of a failure of the route before the first byte. Without it,
|
|
282
|
-
* the mapping gives 500 with no detail, because an error can hold private data.
|
|
283
|
-
*/
|
|
284
|
-
readonly failed?: ((error: unknown) => ResponsePart) | undefined;
|
|
285
|
-
/**
|
|
286
|
-
* This format makes the response a stream: the status and each item go as they come, and the end
|
|
287
|
-
* goes in the body. Without it, the response is unary: one status and the one value.
|
|
288
|
-
*/
|
|
289
|
-
readonly stream?: StreamFormat<T> | undefined;
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* This function gives an end as a record for a body: its kind and the count of its items. A cut and
|
|
293
|
-
* a refusal also give their cause, and if the caller can send the request again. A failure gives
|
|
294
|
-
* no detail.
|
|
295
|
-
*/
|
|
296
|
-
export declare const endRecord: (end: RequestEnd) => Readonly<Record<string, unknown>>;
|
|
297
|
-
/** This format writes each item and the end as one line of JSON (NDJSON). */
|
|
298
|
-
export declare const ndjson: StreamFormat;
|
|
299
|
-
/** This format writes each item as an event of server-sent events, and the end as the event `end`. */
|
|
300
|
-
export declare const sse: StreamFormat;
|
|
301
|
-
/**
|
|
302
|
-
* This function maps a unary request to its response, from its items and its end (S6 A12 and A13).
|
|
303
|
-
* - One value and the end `done`: 200 with the value, or the response of the `done` hook.
|
|
304
|
-
* - No value and the end `done`: 204. More than one value: 500, because the route is not a stream.
|
|
305
|
-
* - `refused`: 503. The work did not start, thus the caller can send it again. The service did not
|
|
306
|
-
* start, it stopped its intake, or a controller is not ready.
|
|
307
|
-
* - `cut`: 503 for a route whose callers can send it again (S6 A12), and 500 for each other route.
|
|
308
|
-
* - `failed`: 500 with no detail, or the response of the `failed` hook. A failure of the route is not a 503.
|
|
309
|
-
*
|
|
310
|
-
* Each 503 gets `Retry-After` (RFC 9110), and a 500 gets none. Each response gets `Connection: close`
|
|
311
|
-
* while the service cannot keep the connection.
|
|
312
|
-
*/
|
|
313
|
-
export declare const outcomeResponse: <T>(items: readonly T[], end: RequestEnd, options: OutcomeOptions<T>) => OutcomeResponse;
|
|
314
|
-
/**
|
|
315
|
-
* This function gives the response of a take that a keyed limiter refused. The work did not start.
|
|
316
|
-
* - A wait refusal (`limit`, `cap` or `store`) gives 429 (RFC 6585), with `Retry-After` in whole
|
|
317
|
-
* seconds, rounded up (RFC 9110). The body tells the cause and the same whole seconds, but not the
|
|
318
|
-
* failure of a store. The caller can send the request again.
|
|
319
|
-
* - A capacity refusal gives 413 (RFC 9110) with no `Retry-After`, because no wait lets the take in.
|
|
320
|
-
* The body tells the units and the capacity, thus the caller can split the request into parts.
|
|
321
|
-
*/
|
|
322
|
-
export declare const limitedResponse: (refused: Refused) => OutcomeResponse;
|
|
323
|
-
/**
|
|
324
|
-
* This function writes the stream of a request to a response of `node:http`, and gives its end. It
|
|
325
|
-
* gives null when the client closed the connection first. Then the work stops through `return()`.
|
|
326
|
-
* - Unary (no format): it waits for the end, and it writes the status and the body of `outcomeResponse`.
|
|
327
|
-
* - Stream: the status 200 goes with the first item, then each item goes as it comes, then the end
|
|
328
|
-
* goes in the body (in-band). The next item waits until the client reads, thus a slow client
|
|
329
|
-
* slows the work. An end before the first item gets a status, as a unary end does.
|
|
330
|
-
* - The answer to come: until it writes the end, the response holds the drain of `httpTransport` past
|
|
331
|
-
* its deadline. The cut of the drain gives that end, and the drain waits until the end goes out.
|
|
332
|
-
* Only a stream of `life.request` of the lifecycle of the transport holds the drain.
|
|
333
|
-
*/
|
|
334
|
-
export declare const writeOutcome: <T>(res: ServerResponse, stream: RequestStream<T>, options: OutcomeOptions<T>) => Promise<RequestEnd | null>;
|
|
335
|
-
/** A route of a handler is the name of the route that a controller declares, or a function that gives it from the request. */
|
|
336
|
-
type HandledRoute = string | ((req: IncomingMessage) => string | null);
|
|
337
|
-
/** A handled work does the work of one request of `node:http`. Its signal aborts when the shutdown or the client stops the request. */
|
|
338
|
-
type HandledWork<T> = (req: IncomingMessage, signal: AbortSignal) => RequestWork<T>;
|
|
339
|
-
/** These options bind a request of `node:http` to the request tracking of the service. */
|
|
340
|
-
interface HandleOptions<T> extends Omit<OutcomeOptions<T>, "keepAlive" | "retryAfter"> {
|
|
341
|
-
/** This function gives the detail of a request, for the function of a route pattern. */
|
|
342
|
-
readonly detail?: ((req: IncomingMessage) => unknown) | undefined;
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* This function gives a request handler that does each request of a route through `life.request`
|
|
346
|
-
* (S6 A12 and A13). The transport gives the lifecycle and `server_retry_after` through the context.
|
|
347
|
-
* - A route name takes a request whose method and path are that name, for example `POST /orders`.
|
|
348
|
-
* A function gives the name of a route or of a pattern, or null for a request of another handler.
|
|
349
|
-
* - Before the start of the transport, each request gets a retryable 503.
|
|
350
|
-
* - The response is unary, or a stream with the option `stream`, as `writeOutcome` writes it.
|
|
351
|
-
*/
|
|
352
|
-
export declare const handle: <T>(controller: string, route: HandledRoute, work: HandledWork<T>, options?: HandleOptions<T>) => RequestHandler;
|
|
353
|
-
export type { EdgeServer, HandleOptions, HandledRoute, HandledWork, HealthSource, HttpKnobs, HttpTransport, HttpTransportKnobs, HttpTransportOptions, MountContext, MountOptions, MountStage, OutcomeOptions, OutcomeResponse, ProbeHandlerOptions, ProbeKind, ProbePaths, ProbeResponse, ProbeServer, ProbeServerOptions, RequestHandler, ResponsePart, StreamFormat, UpgradeHandler, UpgradeMatch, UpgradeSocket };
|
|
1
|
+
import { EdgeServer, HttpKnobs, HttpTransport, HttpTransportKnobs, HttpTransportOptions, MountContext, MountOptions, MountStage, RequestHandler, UpgradeHandler, UpgradeMatch, UpgradeSocket, httpTransport, pathOf } from "./http/transport.js";
|
|
2
|
+
import { ProbeKind } from "./health.js";
|
|
3
|
+
import { HealthSource, PROBE_KINDS, ProbeHandlerOptions, ProbePaths, ProbeResponse, ProbeServer, ProbeServerOptions, probeHandler, probeResponse, probeServer } from "./http/probes.js";
|
|
4
|
+
import { HandleOptions, HandledRoute, HandledWork, OutcomeOptions, OutcomeResponse, ResponsePart, StreamFormat, endRecord, handle, limitedResponse, ndjson, outcomeResponse, sse, writeOutcome } from "./http/outcome.js";
|
|
5
|
+
export { type EdgeServer, type HandleOptions, type HandledRoute, type HandledWork, type HealthSource, type HttpKnobs, type HttpTransport, type HttpTransportKnobs, type HttpTransportOptions, type MountContext, type MountOptions, type MountStage, type OutcomeOptions, type OutcomeResponse, PROBE_KINDS, type ProbeHandlerOptions, type ProbeKind, type ProbePaths, type ProbeResponse, type ProbeServer, type ProbeServerOptions, type RequestHandler, type ResponsePart, type StreamFormat, type UpgradeHandler, type UpgradeMatch, type UpgradeSocket, endRecord, handle, httpTransport, limitedResponse, ndjson, outcomeResponse, pathOf, probeHandler, probeResponse, probeServer, sse, writeOutcome };
|