@spine-event-engine/delivery-server 2.0.0-snapshot.10
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/LICENSE +201 -0
- package/README.md +106 -0
- package/REFERENCE.md +75 -0
- package/dist/admin/admin-service.d.ts +47 -0
- package/dist/admin/admin-service.d.ts.map +1 -0
- package/dist/admin/admin-service.js +188 -0
- package/dist/admin/admin-service.js.map +1 -0
- package/dist/bin/spine-delivery-server.d.ts +3 -0
- package/dist/bin/spine-delivery-server.d.ts.map +1 -0
- package/dist/bin/spine-delivery-server.js +54 -0
- package/dist/bin/spine-delivery-server.js.map +1 -0
- package/dist/core/in-memory-delivery-core.d.ts +56 -0
- package/dist/core/in-memory-delivery-core.d.ts.map +1 -0
- package/dist/core/in-memory-delivery-core.js +44 -0
- package/dist/core/in-memory-delivery-core.js.map +1 -0
- package/dist/core/in-memory-delivery-state.d.ts +86 -0
- package/dist/core/in-memory-delivery-state.d.ts.map +1 -0
- package/dist/core/in-memory-delivery-state.js +214 -0
- package/dist/core/in-memory-delivery-state.js.map +1 -0
- package/dist/core/inbox-service.d.ts +20 -0
- package/dist/core/inbox-service.d.ts.map +1 -0
- package/dist/core/inbox-service.js +212 -0
- package/dist/core/inbox-service.js.map +1 -0
- package/dist/core/limits.d.ts +64 -0
- package/dist/core/limits.d.ts.map +1 -0
- package/dist/core/limits.js +73 -0
- package/dist/core/limits.js.map +1 -0
- package/dist/core/mutation-admission.d.ts +18 -0
- package/dist/core/mutation-admission.d.ts.map +1 -0
- package/dist/core/mutation-admission.js +78 -0
- package/dist/core/mutation-admission.js.map +1 -0
- package/dist/core/shard-service.d.ts +22 -0
- package/dist/core/shard-service.d.ts.map +1 -0
- package/dist/core/shard-service.js +189 -0
- package/dist/core/shard-service.js.map +1 -0
- package/dist/core/wire-values.d.ts +22 -0
- package/dist/core/wire-values.d.ts.map +1 -0
- package/dist/core/wire-values.js +66 -0
- package/dist/core/wire-values.js.map +1 -0
- package/dist/health/health-service.d.ts +9 -0
- package/dist/health/health-service.d.ts.map +1 -0
- package/dist/health/health-service.js +47 -0
- package/dist/health/health-service.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/server/assembly.d.ts +41 -0
- package/dist/server/assembly.d.ts.map +1 -0
- package/dist/server/assembly.js +49 -0
- package/dist/server/assembly.js.map +1 -0
- package/dist/server/config.d.ts +57 -0
- package/dist/server/config.d.ts.map +1 -0
- package/dist/server/config.js +52 -0
- package/dist/server/config.js.map +1 -0
- package/dist/server/delivery-server-log.d.ts +11 -0
- package/dist/server/delivery-server-log.d.ts.map +1 -0
- package/dist/server/delivery-server-log.js +44 -0
- package/dist/server/delivery-server-log.js.map +1 -0
- package/dist/server/delivery-server.d.ts +103 -0
- package/dist/server/delivery-server.d.ts.map +1 -0
- package/dist/server/delivery-server.js +201 -0
- package/dist/server/delivery-server.js.map +1 -0
- package/dist/server/shutdown.d.ts +36 -0
- package/dist/server/shutdown.d.ts.map +1 -0
- package/dist/server/shutdown.js +25 -0
- package/dist/server/shutdown.js.map +1 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +18 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +41 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, CodeMatters. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
|
5
|
+
* in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
10
|
+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
11
|
+
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
|
+
* the License.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Records a contained delivery-listener error without changing listener failure semantics.
|
|
16
|
+
*
|
|
17
|
+
* @param logger Receives the contained record when supplied.
|
|
18
|
+
*/
|
|
19
|
+
export const deliveryServerLog = Object.freeze({
|
|
20
|
+
error(logger) {
|
|
21
|
+
if (logger === undefined)
|
|
22
|
+
return;
|
|
23
|
+
try {
|
|
24
|
+
const record = logger.withMetadata({
|
|
25
|
+
operation: "delivery.listener.start",
|
|
26
|
+
reasonCode: "failed",
|
|
27
|
+
});
|
|
28
|
+
const emit = record.error.bind(record);
|
|
29
|
+
const emitted = emit("delivery.listener.start_failed");
|
|
30
|
+
if (deliveryServerLog.isPromiseLike(emitted))
|
|
31
|
+
void Promise.resolve(emitted).catch(() => undefined);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// Logging must not affect the containing runtime outcome.
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
isPromiseLike(value) {
|
|
38
|
+
return ((typeof value === "object" || typeof value === "function") &&
|
|
39
|
+
value !== null &&
|
|
40
|
+
"then" in value &&
|
|
41
|
+
typeof value.then === "function");
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=delivery-server-log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delivery-server-log.js","sourceRoot":"","sources":["../../src/server/delivery-server-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAGzB,MAAM,CAAC,MAAM,CAAC;IACjB,KAAK,CAAC,MAA6B;QACjC,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO;QACjC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC;gBACjC,SAAS,EAAE,yBAAyB;gBACpC,UAAU,EAAE,QAAQ;aACrB,CAAC,CAAC;YACH,MAAM,IAAI,GAA+B,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACnE,MAAM,OAAO,GAAG,IAAI,CAAC,gCAAgC,CAAC,CAAC;YACvD,IAAI,iBAAiB,CAAC,aAAa,CAAC,OAAO,CAAC;gBAC1C,KAAK,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACzD,CAAC;QAAC,MAAM,CAAC;YACP,0DAA0D;QAC5D,CAAC;IACH,CAAC;IAED,aAAa,CAAC,KAAc;QAC1B,OAAO,CACL,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC;YAC1D,KAAK,KAAK,IAAI;YACd,MAAM,IAAI,KAAK;YACf,OAAQ,KAA4B,CAAC,IAAI,KAAK,UAAU,CACzD,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { ILogLayer } from "loglayer";
|
|
2
|
+
/**
|
|
3
|
+
* Construction-time configuration for {@link DeliveryServer}.
|
|
4
|
+
*/
|
|
5
|
+
export interface DeliveryServerOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Listener host. The explicit option overrides `HOST`; the default is the
|
|
8
|
+
* local-only address `127.0.0.1`. Blank values are rejected.
|
|
9
|
+
*/
|
|
10
|
+
readonly host?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Listener port. The explicit option overrides `PORT`; the default is `8484`.
|
|
13
|
+
* Accepts integers from `0` through `65535`; zero requests an ephemeral port.
|
|
14
|
+
*/
|
|
15
|
+
readonly port?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Maximum inbound RPC message size in bytes. The explicit option overrides
|
|
18
|
+
* `MAX_INBOUND_MESSAGE_SIZE`; the default is 4 MiB (`4_194_304`). Accepts
|
|
19
|
+
* positive integers through `2_147_483_647`.
|
|
20
|
+
*/
|
|
21
|
+
readonly maxInboundMessageBytes?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Automatic stale-pickup timeout in seconds. The explicit option overrides
|
|
24
|
+
* `SHARD_PROCESSING_TIMEOUT`; the default is zero (disabled). Accepts
|
|
25
|
+
* non-negative integers through `2_147_483_647`.
|
|
26
|
+
*/
|
|
27
|
+
readonly processingTimeoutSeconds?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Maximum retained Inbox records. The explicit option overrides
|
|
30
|
+
* `MAX_RETAINED_MESSAGES`; the default is `10_000`. Accepts integers from 1
|
|
31
|
+
* through `2_147_483_647`.
|
|
32
|
+
*/
|
|
33
|
+
readonly maxRetainedMessages?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Maximum serialized bytes retained across Inbox records. The explicit option
|
|
36
|
+
* overrides `MAX_RETAINED_BYTES`; the default is 32 MiB (`33_554_432`).
|
|
37
|
+
* Accepts integers from 1 through `2_147_483_647`.
|
|
38
|
+
*/
|
|
39
|
+
readonly maxRetainedBytes?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Maximum distinct shards retained by messages or pickup sessions. The
|
|
42
|
+
* explicit option overrides `MAX_TRACKED_SHARDS`; the default is `1_000`.
|
|
43
|
+
* Accepts integers from 1 through `1_000`.
|
|
44
|
+
*/
|
|
45
|
+
readonly maxTrackedShards?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Application-owned logger reserved for component-local records. The component
|
|
48
|
+
* does not retain or close the supplied logger.
|
|
49
|
+
*/
|
|
50
|
+
readonly logger?: ILogLayer;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A small in-memory Connect listener for the frozen delivery simple-server API.
|
|
54
|
+
*/
|
|
55
|
+
export declare class DeliveryServer {
|
|
56
|
+
#private;
|
|
57
|
+
/**
|
|
58
|
+
* Configured listener host, resolved and validated during construction.
|
|
59
|
+
*/
|
|
60
|
+
readonly host: string;
|
|
61
|
+
/**
|
|
62
|
+
* Creates a terminal-lifecycle server and resolves configuration exactly once.
|
|
63
|
+
*
|
|
64
|
+
* Invalid options or environment values fail synchronously before any listener
|
|
65
|
+
* is created or bound.
|
|
66
|
+
*
|
|
67
|
+
* @param options Holds explicit listener and retained-state options.
|
|
68
|
+
*/
|
|
69
|
+
constructor(options?: DeliveryServerOptions);
|
|
70
|
+
/**
|
|
71
|
+
* Returns the configured port before startup or the bound port after a successful
|
|
72
|
+
* ephemeral (`0`) bind.
|
|
73
|
+
*
|
|
74
|
+
* @returns The configured or bound listener port.
|
|
75
|
+
*/
|
|
76
|
+
get port(): number;
|
|
77
|
+
/**
|
|
78
|
+
* Returns the HTTP base URL of the running cleartext HTTP/2 listener.
|
|
79
|
+
*
|
|
80
|
+
* @returns The configured listener base URL.
|
|
81
|
+
* @throws If read before startup completes successfully.
|
|
82
|
+
*/
|
|
83
|
+
get baseUrl(): string;
|
|
84
|
+
/**
|
|
85
|
+
* Starts the listener once.
|
|
86
|
+
*
|
|
87
|
+
* Concurrent and repeated calls share the same promise and listener. A failed
|
|
88
|
+
* or closed instance is terminal and cannot retry startup.
|
|
89
|
+
*
|
|
90
|
+
* @returns The shared startup promise.
|
|
91
|
+
*/
|
|
92
|
+
start(): Promise<this>;
|
|
93
|
+
/**
|
|
94
|
+
* Closes ordered terminal resources once.
|
|
95
|
+
*
|
|
96
|
+
* Concurrent and repeated calls share one promise. Closing before startup
|
|
97
|
+
* prevents binding; closing during startup waits for reached-resource cleanup.
|
|
98
|
+
*
|
|
99
|
+
* @returns Completes after terminal resources close.
|
|
100
|
+
*/
|
|
101
|
+
close(): Promise<void>;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=delivery-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delivery-server.d.ts","sourceRoot":"","sources":["../../src/server/delivery-server.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAc1C;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAGpC;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,QAAQ,CAAC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEzC;;;;OAIG;IACH,QAAQ,CAAC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAE3C;;;;OAIG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAEtC;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAEnC;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAEnC;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;CAC7B;AAED;;GAEG;AACH,qBAAa,cAAc;;IAGzB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAYtB;;;;;;;OAOG;gBACS,OAAO,GAAE,qBAA0B;IAO/C;;;;;OAKG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;;OAKG;IACH,IAAI,OAAO,IAAI,MAAM,CAGpB;IAED;;;;;;;OAOG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAOtB;;;;;;;OAOG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAuGvB"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, CodeMatters. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
|
5
|
+
* in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
10
|
+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
11
|
+
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
|
+
* the License.
|
|
13
|
+
*/
|
|
14
|
+
import * as http2 from "node:http2";
|
|
15
|
+
import { connectNodeAdapter } from "@connectrpc/connect-node";
|
|
16
|
+
import { AdminService, Health, InboxService, ShardService, } from "@spine-event-engine/proto/delivery-server";
|
|
17
|
+
import { HealthHandlers } from "../health/health-service.js";
|
|
18
|
+
import { DeliveryAssembly } from "./assembly.js";
|
|
19
|
+
import { DeliveryConfig } from "./config.js";
|
|
20
|
+
import { DeliveryShutdown } from "./shutdown.js";
|
|
21
|
+
import { deliveryServerLog } from "./delivery-server-log.js";
|
|
22
|
+
/**
|
|
23
|
+
* A small in-memory Connect listener for the frozen delivery simple-server API.
|
|
24
|
+
*/
|
|
25
|
+
export class DeliveryServer {
|
|
26
|
+
// prettier-ignore
|
|
27
|
+
/**
|
|
28
|
+
* Configured listener host, resolved and validated during construction.
|
|
29
|
+
*/
|
|
30
|
+
host;
|
|
31
|
+
#port;
|
|
32
|
+
#configuration;
|
|
33
|
+
#logger;
|
|
34
|
+
#server;
|
|
35
|
+
#start;
|
|
36
|
+
#close;
|
|
37
|
+
#started = false;
|
|
38
|
+
#serving = true;
|
|
39
|
+
#assembly;
|
|
40
|
+
#sessions = new Set();
|
|
41
|
+
/**
|
|
42
|
+
* Creates a terminal-lifecycle server and resolves configuration exactly once.
|
|
43
|
+
*
|
|
44
|
+
* Invalid options or environment values fail synchronously before any listener
|
|
45
|
+
* is created or bound.
|
|
46
|
+
*
|
|
47
|
+
* @param options Holds explicit listener and retained-state options.
|
|
48
|
+
*/
|
|
49
|
+
constructor(options = {}) {
|
|
50
|
+
this.#configuration = DeliveryConfig.resolve(options);
|
|
51
|
+
this.host = this.#configuration.host;
|
|
52
|
+
this.#port = this.#configuration.port;
|
|
53
|
+
this.#logger = options.logger;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Returns the configured port before startup or the bound port after a successful
|
|
57
|
+
* ephemeral (`0`) bind.
|
|
58
|
+
*
|
|
59
|
+
* @returns The configured or bound listener port.
|
|
60
|
+
*/
|
|
61
|
+
get port() {
|
|
62
|
+
return this.#port;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Returns the HTTP base URL of the running cleartext HTTP/2 listener.
|
|
66
|
+
*
|
|
67
|
+
* @returns The configured listener base URL.
|
|
68
|
+
* @throws If read before startup completes successfully.
|
|
69
|
+
*/
|
|
70
|
+
get baseUrl() {
|
|
71
|
+
if (!this.#started)
|
|
72
|
+
throw new Error("Delivery server has not started.");
|
|
73
|
+
return `http://${this.host.includes(":") ? `[${this.host}]` : this.host}:${String(this.#port)}`;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Starts the listener once.
|
|
77
|
+
*
|
|
78
|
+
* Concurrent and repeated calls share the same promise and listener. A failed
|
|
79
|
+
* or closed instance is terminal and cannot retry startup.
|
|
80
|
+
*
|
|
81
|
+
* @returns The shared startup promise.
|
|
82
|
+
*/
|
|
83
|
+
start() {
|
|
84
|
+
if (this.#close !== undefined)
|
|
85
|
+
return Promise.reject(new Error("Delivery server is closed."));
|
|
86
|
+
if (this.#start !== undefined)
|
|
87
|
+
return this.#start;
|
|
88
|
+
this.#start = this.#startOnce();
|
|
89
|
+
return this.#start;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Closes ordered terminal resources once.
|
|
93
|
+
*
|
|
94
|
+
* Concurrent and repeated calls share one promise. Closing before startup
|
|
95
|
+
* prevents binding; closing during startup waits for reached-resource cleanup.
|
|
96
|
+
*
|
|
97
|
+
* @returns Completes after terminal resources close.
|
|
98
|
+
*/
|
|
99
|
+
close() {
|
|
100
|
+
if (this.#close !== undefined)
|
|
101
|
+
return this.#close;
|
|
102
|
+
this.#close = DeliveryShutdown.run({
|
|
103
|
+
markNotServing: () => {
|
|
104
|
+
this.#serving = false;
|
|
105
|
+
},
|
|
106
|
+
closeAdmission: () => {
|
|
107
|
+
this.#assembly?.closeAdmission();
|
|
108
|
+
},
|
|
109
|
+
closeAdmin: () => {
|
|
110
|
+
this.#assembly?.closeAdmin();
|
|
111
|
+
},
|
|
112
|
+
closeNetwork: async () => {
|
|
113
|
+
try {
|
|
114
|
+
await this.#start;
|
|
115
|
+
// spine-log-boundary: delivery_server.listener_start_close
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
// A failed listener has already reached its terminal state.
|
|
119
|
+
}
|
|
120
|
+
const server = this.#server;
|
|
121
|
+
if (server?.listening) {
|
|
122
|
+
const closing = this.#closeListener(server);
|
|
123
|
+
for (const session of this.#sessions)
|
|
124
|
+
session.close();
|
|
125
|
+
await closing;
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
return this.#close;
|
|
130
|
+
}
|
|
131
|
+
async #startOnce() {
|
|
132
|
+
const core = DeliveryAssembly.create(this.#configuration);
|
|
133
|
+
this.#assembly = core;
|
|
134
|
+
const server = http2.createServer(connectNodeAdapter({
|
|
135
|
+
routes: (router) => {
|
|
136
|
+
router.service(InboxService, core.inbox);
|
|
137
|
+
router.service(ShardService, core.shards);
|
|
138
|
+
router.service(AdminService, core.admin);
|
|
139
|
+
router.service(Health, HealthHandlers.create(() => this.#serving));
|
|
140
|
+
},
|
|
141
|
+
readMaxBytes: this.#configuration.maxInboundMessageBytes,
|
|
142
|
+
}));
|
|
143
|
+
server.on("session", (session) => {
|
|
144
|
+
this.#sessions.add(session);
|
|
145
|
+
session.on("close", () => this.#sessions.delete(session));
|
|
146
|
+
});
|
|
147
|
+
this.#server = server;
|
|
148
|
+
try {
|
|
149
|
+
const address = await this.#listen(server, this.host, this.#port);
|
|
150
|
+
this.#port = address.port;
|
|
151
|
+
this.#started = true;
|
|
152
|
+
return this;
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
// spine-log-boundary: delivery_server.listener_start
|
|
156
|
+
deliveryServerLog.error(this.#logger);
|
|
157
|
+
await this.#closeListener(server);
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Waits for a cleartext HTTP/2 listener to bind and reports its address.
|
|
163
|
+
*/
|
|
164
|
+
#listen(server, host, port) {
|
|
165
|
+
return new Promise((resolve, reject) => {
|
|
166
|
+
const done = () => {
|
|
167
|
+
server.off("error", fail);
|
|
168
|
+
server.off("listening", ready);
|
|
169
|
+
};
|
|
170
|
+
const fail = (error) => {
|
|
171
|
+
done();
|
|
172
|
+
reject(error);
|
|
173
|
+
};
|
|
174
|
+
const ready = () => {
|
|
175
|
+
done();
|
|
176
|
+
resolve(server.address());
|
|
177
|
+
};
|
|
178
|
+
server.once("error", fail);
|
|
179
|
+
server.once("listening", ready);
|
|
180
|
+
server.listen(port, host);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Closes a bound cleartext HTTP/2 listener without changing terminal state.
|
|
185
|
+
*/
|
|
186
|
+
#closeListener(server) {
|
|
187
|
+
return new Promise((resolve, reject) => {
|
|
188
|
+
if (!server.listening) {
|
|
189
|
+
resolve();
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
server.close((error) => {
|
|
193
|
+
if (error === undefined)
|
|
194
|
+
resolve();
|
|
195
|
+
else
|
|
196
|
+
reject(error);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=delivery-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delivery-server.js","sourceRoot":"","sources":["../../src/server/delivery-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAGpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BA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AAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,cAAc,CAAC,MAAyB;QACtC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;gBACtB,OAAO,EAAE,CAAC;gBACV,OAAO;YACT,CAAC;YACD,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBACrB,IAAI,KAAK,KAAK,SAAS;oBAAE,OAAO,EAAE,CAAC;;oBAC9B,MAAM,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Describes the ordered resources closed during delivery-server shutdown.
|
|
3
|
+
*/
|
|
4
|
+
export interface DeliveryServerShutdownResources {
|
|
5
|
+
/**
|
|
6
|
+
* Sets Health to no longer serving.
|
|
7
|
+
*/
|
|
8
|
+
readonly markNotServing: () => void;
|
|
9
|
+
/**
|
|
10
|
+
* Closes the shared mutation-admission boundary.
|
|
11
|
+
*/
|
|
12
|
+
readonly closeAdmission: () => void;
|
|
13
|
+
/**
|
|
14
|
+
* Closes Admin subscribers and publishing.
|
|
15
|
+
*/
|
|
16
|
+
readonly closeAdmin: () => void;
|
|
17
|
+
/**
|
|
18
|
+
* Closes the listener and active HTTP/2 sessions.
|
|
19
|
+
*
|
|
20
|
+
* @returns Completes after the listener closes.
|
|
21
|
+
*/
|
|
22
|
+
readonly closeNetwork: () => Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Provides the delivery-server terminal shutdown sequence.
|
|
26
|
+
*/
|
|
27
|
+
export declare const DeliveryShutdown: Readonly<{
|
|
28
|
+
/**
|
|
29
|
+
* Runs the required Health, admission, Admin, listener, and session shutdown order.
|
|
30
|
+
*
|
|
31
|
+
* @param resources Holds the shutdown resources in their required phases.
|
|
32
|
+
* @returns A promise that resolves after network shutdown completes.
|
|
33
|
+
*/
|
|
34
|
+
run: (resources: DeliveryServerShutdownResources) => Promise<void>;
|
|
35
|
+
}>;
|
|
36
|
+
//# sourceMappingURL=shutdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shutdown.d.ts","sourceRoot":"","sources":["../../src/server/shutdown.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAG9C;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,IAAI,CAAC;IAEpC;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,IAAI,CAAC;IAEpC;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,IAAI,CAAC;IAEhC;;;;OAIG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC;IAGtC;;;;;OAKG;IACH,GAAG,EAAE,CAAC,SAAS,EAAE,+BAA+B,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACpE,CAOC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, CodeMatters. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
|
5
|
+
* in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
10
|
+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
11
|
+
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
|
+
* the License.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Provides the delivery-server terminal shutdown sequence.
|
|
16
|
+
*/
|
|
17
|
+
export const DeliveryShutdown = Object.freeze({
|
|
18
|
+
run: async (resources) => {
|
|
19
|
+
resources.markNotServing();
|
|
20
|
+
resources.closeAdmission();
|
|
21
|
+
resources.closeAdmin();
|
|
22
|
+
await resources.closeNetwork();
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=shutdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shutdown.js","sourceRoot":"","sources":["../../src/server/shutdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA+BH;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAUxB,MAAM,CAAC,MAAM,CAAC;IACjB,GAAG,EAAE,KAAK,EAAE,SAA0C,EAAiB,EAAE;QACvE,SAAS,CAAC,cAAc,EAAE,CAAC;QAC3B,SAAS,CAAC,cAAc,EAAE,CAAC;QAC3B,SAAS,CAAC,UAAU,EAAE,CAAC;QACvB,MAAM,SAAS,CAAC,YAAY,EAAE,CAAC;IACjC,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, CodeMatters. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
|
5
|
+
* in compliance with the License. You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
10
|
+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
11
|
+
* or implied. See the License for the specific language governing permissions and limitations under
|
|
12
|
+
* the License.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Exports test support for applications that host a Delivery server assembly in-process.
|
|
16
|
+
*/
|
|
17
|
+
export { DeliveryAssembly } from "../server/assembly.js";
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|