@spine-event-engine/deployment-gce 2.0.0-snapshot.2

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.
Files changed (45) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +336 -0
  3. package/REFERENCE.md +93 -0
  4. package/dist/discovery/gce-node-discovery.d.ts +56 -0
  5. package/dist/discovery/gce-node-discovery.d.ts.map +1 -0
  6. package/dist/discovery/gce-node-discovery.js +78 -0
  7. package/dist/discovery/gce-node-discovery.js.map +1 -0
  8. package/dist/index.d.ts +7 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +20 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/metadata/gce-metadata-service.d.ts +47 -0
  13. package/dist/metadata/gce-metadata-service.d.ts.map +1 -0
  14. package/dist/metadata/gce-metadata-service.js +65 -0
  15. package/dist/metadata/gce-metadata-service.js.map +1 -0
  16. package/dist/node/application-node.d.ts +35 -0
  17. package/dist/node/application-node.d.ts.map +1 -0
  18. package/dist/node/application-node.js +46 -0
  19. package/dist/node/application-node.js.map +1 -0
  20. package/dist/registrar/gce-registrar-log.d.ts +11 -0
  21. package/dist/registrar/gce-registrar-log.d.ts.map +1 -0
  22. package/dist/registrar/gce-registrar-log.js +44 -0
  23. package/dist/registrar/gce-registrar-log.js.map +1 -0
  24. package/dist/registrar/gce-registrar.d.ts +90 -0
  25. package/dist/registrar/gce-registrar.d.ts.map +1 -0
  26. package/dist/registrar/gce-registrar.js +167 -0
  27. package/dist/registrar/gce-registrar.js.map +1 -0
  28. package/dist/registrar/operations.d.ts +61 -0
  29. package/dist/registrar/operations.d.ts.map +1 -0
  30. package/dist/registrar/operations.js +96 -0
  31. package/dist/registrar/operations.js.map +1 -0
  32. package/dist/registry/gce-registry-reader.d.ts +23 -0
  33. package/dist/registry/gce-registry-reader.d.ts.map +1 -0
  34. package/dist/registry/gce-registry-reader.js +42 -0
  35. package/dist/registry/gce-registry-reader.js.map +1 -0
  36. package/dist/tsconfig.tsbuildinfo +1 -0
  37. package/examples/application.ts +208 -0
  38. package/examples/deployment-settings.ts +119 -0
  39. package/examples/gateway.ts +85 -0
  40. package/package.json +41 -0
  41. package/terraform/.terraform.lock.hcl +22 -0
  42. package/terraform/main.tf +402 -0
  43. package/terraform/terraform.tfvars.example +57 -0
  44. package/terraform/variables.tf +319 -0
  45. package/terraform/versions.tf +15 -0
@@ -0,0 +1,167 @@
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 {} from "@spine-event-engine/deployment";
15
+ import { randomUUID } from "node:crypto";
16
+ import { GceMetadataService } from "../metadata/gce-metadata-service.js";
17
+ import { gceRegistrarLog } from "./gce-registrar-log.js";
18
+ import { GceApplicationNode } from "../node/application-node.js";
19
+ import { GceOperationRunner, systemGceDeadlines, systemGceScheduler, } from "./operations.js";
20
+ /**
21
+ * Registers one ready GCE node and renews its lease.
22
+ */
23
+ export class GceRegistrar {
24
+ #registry;
25
+ #node;
26
+ #metadata;
27
+ #port;
28
+ #identity;
29
+ #scheduler;
30
+ #now;
31
+ #deadlines;
32
+ #operationTimeoutMs;
33
+ #operations;
34
+ #logger;
35
+ #cancel;
36
+ #closed = false;
37
+ #started = false;
38
+ #confirmed = false;
39
+ #work = Promise.resolve();
40
+ #abort = new AbortController();
41
+ /**
42
+ * Creates a registrar with twenty-second renewal and sixty-second leases by default.
43
+ *
44
+ * @param options Supplies registry ownership, node derivation, and deterministic seams.
45
+ */
46
+ constructor(options) {
47
+ this.#registry = options.registry;
48
+ if (options.node === undefined && options.port === undefined)
49
+ throw new Error("GCE registrar requires a node or a metadata port.");
50
+ this.#node = options.node;
51
+ this.#metadata =
52
+ options.metadata ?? (options.node === undefined ? new GceMetadataService() : undefined);
53
+ this.#port = options.port;
54
+ this.#identity = options.identity ?? randomUUID();
55
+ this.#scheduler = options.scheduler ?? systemGceScheduler;
56
+ this.#now = options.now ?? Date.now;
57
+ this.#deadlines = options.deadlines ?? systemGceDeadlines;
58
+ if (options.operationTimeoutMs !== undefined &&
59
+ (!Number.isSafeInteger(options.operationTimeoutMs) || options.operationTimeoutMs < 1))
60
+ throw new RangeError("GCE registrar operation timeout must be a positive safe integer.");
61
+ this.#operationTimeoutMs = options.operationTimeoutMs ?? 20_000;
62
+ this.#operations = new GceOperationRunner(this.#deadlines, this.#operationTimeoutMs, this.#abort.signal);
63
+ this.#logger = options.logger;
64
+ }
65
+ /**
66
+ * Starts initial registration after the listener is ready.
67
+ *
68
+ * @returns Completes after the first registration attempt has settled.
69
+ * @throws Error When this registrar has already closed.
70
+ */
71
+ async start() {
72
+ if (this.#closed)
73
+ throw new Error("GCE registrar is closed.");
74
+ if (this.#started)
75
+ return;
76
+ this.#started = true;
77
+ // spine-log-boundary: deployment_gce.registrar_initial_result
78
+ const registered = await this.#enqueue(async () => {
79
+ await this.#resolveNode();
80
+ const node = this.#node;
81
+ if (node === undefined)
82
+ throw new Error("GCE registrar has no resolved node.");
83
+ return this.#operation((signal) => this.#registry.register({ node, registrationId: this.#identity, expiresAt: this.#now() + 60_000 }, signal));
84
+ }).catch(() => false);
85
+ this.#schedule();
86
+ this.#confirmed = registered;
87
+ }
88
+ /**
89
+ * Removes this registrar's lease after fencing scheduled work.
90
+ *
91
+ * @returns Completes after admitted work settles and owned-row removal is attempted.
92
+ */
93
+ async close() {
94
+ if (this.#closed)
95
+ return;
96
+ this.#closed = true;
97
+ this.#abort.abort();
98
+ this.#cancel?.();
99
+ await this.#work;
100
+ const node = this.#node;
101
+ if (node !== undefined)
102
+ await this.#operation((signal) => this.#registry.remove(node.id, this.#identity, signal), false);
103
+ }
104
+ /**
105
+ * Exposes listener-ready start and pre-network-close removal to a server assembly.
106
+ *
107
+ * @returns The lifecycle callbacks accepted by `Server.addListenerLifecycle()`.
108
+ */
109
+ lifecycle() {
110
+ return { start: () => this.start(), close: () => this.close() };
111
+ }
112
+ #schedule() {
113
+ if (this.#closed)
114
+ return;
115
+ this.#cancel = this.#scheduler.schedule(20_000, () => {
116
+ // spine-log-boundary: deployment_gce.registrar_renew
117
+ void this.#enqueue(() => this.#renew()).catch(() => {
118
+ if (!this.#closed)
119
+ gceRegistrarLog.warnRenewal(this.#logger);
120
+ });
121
+ });
122
+ }
123
+ async #renew() {
124
+ if (this.#closed)
125
+ return;
126
+ try {
127
+ await this.#resolveNode();
128
+ const node = this.#node;
129
+ if (node === undefined)
130
+ return;
131
+ if (this.#confirmed)
132
+ this.#confirmed = await this.#operation((signal) => this.#registry.renew(node.id, this.#identity, this.#now() + 60_000, signal));
133
+ else {
134
+ const existing = await this.#operation((signal) => this.#registry.lookup(node.id, this.#now(), signal));
135
+ this.#confirmed = existing?.registrationId === this.#identity;
136
+ if (!this.#confirmed)
137
+ this.#confirmed = await this.#operation((signal) => this.#registry.register({ node, registrationId: this.#identity, expiresAt: this.#now() + 60_000 }, signal));
138
+ }
139
+ await this.#operation((signal) => this.#registry.cleanup(this.#now(), signal));
140
+ }
141
+ finally {
142
+ // A concurrent close may fence renewal while its registry operation is pending.
143
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
144
+ if (!this.#closed)
145
+ this.#schedule();
146
+ }
147
+ }
148
+ #enqueue(operation) {
149
+ const next = this.#work.then(operation, operation);
150
+ // spine-log-boundary: deployment_gce.registrar_work_tail
151
+ this.#work = next.then(() => undefined, () => undefined);
152
+ return next;
153
+ }
154
+ #operation(operation, includeShutdown = true) {
155
+ return this.#operations.run(operation, includeShutdown);
156
+ }
157
+ async #resolveNode() {
158
+ if (this.#node !== undefined)
159
+ return;
160
+ const metadata = this.#metadata;
161
+ const port = this.#port;
162
+ if (metadata === undefined || port === undefined)
163
+ throw new Error("GCE registrar has no node source.");
164
+ this.#node = GceApplicationNode.create(await this.#operations.run((signal) => metadata.read(signal)), { port });
165
+ }
166
+ }
167
+ //# sourceMappingURL=gce-registrar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gce-registrar.js","sourceRoot":"","sources":["../../src/registrar/gce-registrar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAiD,MAAM,gCAAgC,CAAC;AAC/F,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,kBAAkB,EAA4B,MAAM,qCAAqC,CAAC;AACnG,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,GAGnB,MAAM,iBAAiB,CAAC;AAqEzB;;GAEG;AACH,MAAM,OAAO,YAAY;IACd,SAAS,CAAqB;IACvC,KAAK,CAA8B;IAC1B,SAAS,CAAkC;IAC3C,KAAK,CAAqB;IAC1B,SAAS,CAAS;IAClB,UAAU,CAAe;IACzB,IAAI,CAAe;IACnB,UAAU,CAAqB;IAC/B,mBAAmB,CAAS;IAC5B,WAAW,CAAqB;IAChC,OAAO,CAAwB;IACxC,OAAO,CAA2B;IAClC,OAAO,GAAG,KAAK,CAAC;IAChB,QAAQ,GAAG,KAAK,CAAC;IACjB,UAAU,GAAG,KAAK,CAAC;IACnB,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAC1B,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IAE/B;;;;OAIG;IACH,YAAY,OAA4B;QACtC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;QAClC,IAAI,OAAO,CAAC,IAAI,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C,GAAG,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS;YAAE,OAAO;QACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,QAAQ,KAAK,SAAS,IAAI,IAAI,KAAK,SAAS;YAC9C,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvD,IAAI,CAAC,KAAK,GAAG,kBAAkB,CAAC,MAAM,CACpC,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAC7D,EAAE,IAAI,EAAE,CACT,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Schedules deterministic registrar renewal work.
3
+ */
4
+ export interface GceScheduler {
5
+ /**
6
+ * Schedules one renewal callback.
7
+ *
8
+ * @param delayMs Supplies a positive delay in milliseconds.
9
+ * @param onTick Receives the callback to run once after the delay.
10
+ * @returns Cancels the scheduled callback.
11
+ */
12
+ schedule(delayMs: number, onTick: () => void): () => void;
13
+ }
14
+ /**
15
+ * Creates one cancellable deadline for cooperative registrar operations.
16
+ */
17
+ export interface GceDeadlineFactory {
18
+ /**
19
+ * Creates an operation deadline.
20
+ *
21
+ * @param timeoutMs Supplies a positive timeout in milliseconds.
22
+ * @returns An abort signal and an operation that releases the deadline handle.
23
+ */
24
+ create(timeoutMs: number): {
25
+ readonly signal: AbortSignal;
26
+ close(): void;
27
+ };
28
+ }
29
+ /**
30
+ * Supplies production renewal scheduling with unreferenced Node.js timer handles.
31
+ */
32
+ export declare const systemGceScheduler: GceScheduler;
33
+ /**
34
+ * Supplies production deadlines with unreferenced Node.js timer handles.
35
+ */
36
+ export declare const systemGceDeadlines: GceDeadlineFactory;
37
+ /**
38
+ * Runs registrar work under its deadline and optional shutdown signal.
39
+ */
40
+ export declare class GceOperationRunner {
41
+ private readonly deadlines;
42
+ private readonly timeoutMs;
43
+ private readonly shutdown;
44
+ /**
45
+ * Creates an operation owner for one registrar lifecycle.
46
+ *
47
+ * @param deadlines Supplies the deadline factory.
48
+ * @param timeoutMs Supplies the operation timeout.
49
+ * @param shutdown Supplies the registrar shutdown signal.
50
+ */
51
+ constructor(deadlines: GceDeadlineFactory, timeoutMs: number, shutdown: AbortSignal);
52
+ /**
53
+ * Executes one registrar mutation and always releases its deadline handle.
54
+ *
55
+ * @param operation Receives the composed cancellation signal.
56
+ * @param includeShutdown Selects whether registrar shutdown cancels this operation.
57
+ * @returns The operation result.
58
+ */
59
+ run<Result>(operation: (signal: AbortSignal) => Promise<Result>, includeShutdown?: boolean): Promise<Result>;
60
+ }
61
+ //# sourceMappingURL=operations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/registrar/operations.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,MAAM,WAAW,YAAY;IAG3B;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CAC3D;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAGjC;;;;;OAKG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG;QAAE,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;QAAC,KAAK,IAAI,IAAI,CAAA;KAAE,CAAC;CAC5E;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,YAiBhC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAsBhC,CAAC;AAEF;;GAEG;AACH,qBAAa,kBAAkB;IAW3B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAV3B;;;;;;OAMG;gBAEgB,SAAS,EAAE,kBAAkB,EAC7B,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,WAAW;IAGxC;;;;;;OAMG;IACG,GAAG,CAAC,MAAM,EACd,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,EACnD,eAAe,UAAO,GACrB,OAAO,CAAC,MAAM,CAAC;CAUnB"}
@@ -0,0 +1,96 @@
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
+ * Supplies production renewal scheduling with unreferenced Node.js timer handles.
16
+ */
17
+ export const systemGceScheduler = {
18
+ // prettier-ignore
19
+ /**
20
+ * Schedules one unreferenced renewal callback.
21
+ *
22
+ * @param delayMs Supplies the renewal delay in milliseconds.
23
+ * @param onTick Receives the callback to run once after the delay.
24
+ * @returns Cancels the scheduled callback.
25
+ */
26
+ schedule: (delayMs, onTick) => {
27
+ const timer = setTimeout(onTick, delayMs);
28
+ timer.unref();
29
+ return () => {
30
+ clearTimeout(timer);
31
+ };
32
+ },
33
+ };
34
+ /**
35
+ * Supplies production deadlines with unreferenced Node.js timer handles.
36
+ */
37
+ export const systemGceDeadlines = {
38
+ // prettier-ignore
39
+ /**
40
+ * Creates one unreferenced operation deadline.
41
+ *
42
+ * @param timeoutMs Supplies the deadline duration in milliseconds.
43
+ * @returns The signal and its deadline-handle closer.
44
+ */
45
+ create(timeoutMs) {
46
+ const controller = new AbortController();
47
+ const timer = setTimeout(() => {
48
+ controller.abort();
49
+ }, timeoutMs);
50
+ timer.unref();
51
+ return {
52
+ signal: controller.signal,
53
+ close: () => {
54
+ clearTimeout(timer);
55
+ },
56
+ };
57
+ },
58
+ };
59
+ /**
60
+ * Runs registrar work under its deadline and optional shutdown signal.
61
+ */
62
+ export class GceOperationRunner {
63
+ deadlines;
64
+ timeoutMs;
65
+ shutdown;
66
+ // prettier-ignore
67
+ /**
68
+ * Creates an operation owner for one registrar lifecycle.
69
+ *
70
+ * @param deadlines Supplies the deadline factory.
71
+ * @param timeoutMs Supplies the operation timeout.
72
+ * @param shutdown Supplies the registrar shutdown signal.
73
+ */
74
+ constructor(deadlines, timeoutMs, shutdown) {
75
+ this.deadlines = deadlines;
76
+ this.timeoutMs = timeoutMs;
77
+ this.shutdown = shutdown;
78
+ }
79
+ /**
80
+ * Executes one registrar mutation and always releases its deadline handle.
81
+ *
82
+ * @param operation Receives the composed cancellation signal.
83
+ * @param includeShutdown Selects whether registrar shutdown cancels this operation.
84
+ * @returns The operation result.
85
+ */
86
+ async run(operation, includeShutdown = true) {
87
+ const deadline = this.deadlines.create(this.timeoutMs);
88
+ try {
89
+ return await operation(includeShutdown ? AbortSignal.any([this.shutdown, deadline.signal]) : deadline.signal);
90
+ }
91
+ finally {
92
+ deadline.close();
93
+ }
94
+ }
95
+ }
96
+ //# sourceMappingURL=operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.js","sourceRoot":"","sources":["../../src/registrar/operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAiCH;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAiB;IAC9C,kBAAkB;IAElB;;;;;;OAMG;IACH,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC5B,MAAM,KAAK,GAAG,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC1C,KAAK,CAAC,KAAK,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Q,CAAC,KAAK,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,23 @@
1
+ import { type ApplicationNode, type LeasedNodeRegistry, type NodeSnapshotReader } from "@spine-event-engine/deployment";
2
+ /**
3
+ * Reads complete live-node snapshots from the leased registry.
4
+ */
5
+ export declare class GceRegistryReader implements NodeSnapshotReader {
6
+ private readonly registry;
7
+ private readonly now;
8
+ /**
9
+ * Creates a reader using an injected clock for deterministic expiry evaluation.
10
+ *
11
+ * @param registry Supplies the leased registry to read.
12
+ * @param now Supplies the current epoch time used for exact expiry filtering; defaults to `Date.now`.
13
+ */
14
+ constructor(registry: LeasedNodeRegistry, now?: () => number);
15
+ /**
16
+ * Reads every currently live node.
17
+ *
18
+ * @param signal Cancels the registry read during discovery close.
19
+ * @returns The complete live application-node snapshot.
20
+ */
21
+ read(signal: AbortSignal): Promise<readonly ApplicationNode[]>;
22
+ }
23
+ //# sourceMappingURL=gce-registry-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gce-registry-reader.d.ts","sourceRoot":"","sources":["../../src/registry/gce-registry-reader.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACxB,MAAM,gCAAgC,CAAC;AAExC;;GAEG;AACH,qBAAa,iBAAkB,YAAW,kBAAkB;IAUxD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,GAAG;IARtB;;;;;OAKG;gBAEgB,QAAQ,EAAE,kBAAkB,EAC5B,GAAG,GAAE,MAAM,MAAiB;IAG/C;;;;;OAKG;IACH,IAAI,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC;CAG/D"}
@@ -0,0 +1,42 @@
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 {} from "@spine-event-engine/deployment";
15
+ /**
16
+ * Reads complete live-node snapshots from the leased registry.
17
+ */
18
+ export class GceRegistryReader {
19
+ registry;
20
+ now;
21
+ // prettier-ignore
22
+ /**
23
+ * Creates a reader using an injected clock for deterministic expiry evaluation.
24
+ *
25
+ * @param registry Supplies the leased registry to read.
26
+ * @param now Supplies the current epoch time used for exact expiry filtering; defaults to `Date.now`.
27
+ */
28
+ constructor(registry, now = Date.now) {
29
+ this.registry = registry;
30
+ this.now = now;
31
+ }
32
+ /**
33
+ * Reads every currently live node.
34
+ *
35
+ * @param signal Cancels the registry read during discovery close.
36
+ * @returns The complete live application-node snapshot.
37
+ */
38
+ read(signal) {
39
+ return this.registry.read(this.now(), signal);
40
+ }
41
+ }
42
+ //# sourceMappingURL=gce-registry-reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gce-registry-reader.js","sourceRoot":"","sources":["../../src/registry/gce-registry-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAIN,MAAM,gCAAgC,CAAC;AAExC;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAUT;IACA;IAVnB,kBAAkB;IAElB;;;;;OAKG;IACH,YACmB,QAA4B,EAC5B,MAAoB,IAAI,CAAC,GAAG;QAD5B,aAAQ,GAAR,QAAQ,CAAoB;QAC5B,QAAG,GAAH,GAAG,CAAyB;IAC5C,CAAC;IAEJ;;;;;OAKG;IACH,IAAI,CAAC,MAAmB;QACtB,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;CACF"}