@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.
- package/LICENSE +201 -0
- package/README.md +336 -0
- package/REFERENCE.md +93 -0
- package/dist/discovery/gce-node-discovery.d.ts +56 -0
- package/dist/discovery/gce-node-discovery.d.ts.map +1 -0
- package/dist/discovery/gce-node-discovery.js +78 -0
- package/dist/discovery/gce-node-discovery.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/metadata/gce-metadata-service.d.ts +47 -0
- package/dist/metadata/gce-metadata-service.d.ts.map +1 -0
- package/dist/metadata/gce-metadata-service.js +65 -0
- package/dist/metadata/gce-metadata-service.js.map +1 -0
- package/dist/node/application-node.d.ts +35 -0
- package/dist/node/application-node.d.ts.map +1 -0
- package/dist/node/application-node.js +46 -0
- package/dist/node/application-node.js.map +1 -0
- package/dist/registrar/gce-registrar-log.d.ts +11 -0
- package/dist/registrar/gce-registrar-log.d.ts.map +1 -0
- package/dist/registrar/gce-registrar-log.js +44 -0
- package/dist/registrar/gce-registrar-log.js.map +1 -0
- package/dist/registrar/gce-registrar.d.ts +90 -0
- package/dist/registrar/gce-registrar.d.ts.map +1 -0
- package/dist/registrar/gce-registrar.js +167 -0
- package/dist/registrar/gce-registrar.js.map +1 -0
- package/dist/registrar/operations.d.ts +61 -0
- package/dist/registrar/operations.d.ts.map +1 -0
- package/dist/registrar/operations.js +96 -0
- package/dist/registrar/operations.js.map +1 -0
- package/dist/registry/gce-registry-reader.d.ts +23 -0
- package/dist/registry/gce-registry-reader.d.ts.map +1 -0
- package/dist/registry/gce-registry-reader.js +42 -0
- package/dist/registry/gce-registry-reader.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/examples/application.ts +208 -0
- package/examples/deployment-settings.ts +119 -0
- package/examples/gateway.ts +85 -0
- package/package.json +41 -0
- package/terraform/.terraform.lock.hcl +22 -0
- package/terraform/main.tf +402 -0
- package/terraform/terraform.tfvars.example +57 -0
- package/terraform/variables.tf +319 -0
- package/terraform/versions.tf +15 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type ApplicationNode, type LeasedNodeRegistry, type NodeDiscovery, type NodeScheduler } from "@spine-event-engine/deployment";
|
|
2
|
+
import type { ILogLayer } from "loglayer";
|
|
3
|
+
/**
|
|
4
|
+
* Publishes GCE registry membership and closes its owned registry on stop.
|
|
5
|
+
*/
|
|
6
|
+
export declare class GceNodeDiscovery implements NodeDiscovery {
|
|
7
|
+
#private;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a registry-backed GCE discovery owner.
|
|
10
|
+
*
|
|
11
|
+
* @param options Supplies the registry this owner closes and optional deterministic refresh seams.
|
|
12
|
+
*/
|
|
13
|
+
constructor(options: GceNodeDiscoveryOptions);
|
|
14
|
+
/**
|
|
15
|
+
* Starts complete registry snapshot delivery.
|
|
16
|
+
*
|
|
17
|
+
* @param onSnapshot Receives each complete live-node snapshot.
|
|
18
|
+
* @returns Stops discovery and closes the owned registry.
|
|
19
|
+
*/
|
|
20
|
+
watch(onSnapshot: (nodes: readonly ApplicationNode[]) => void): () => Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Stops discovery before closing the owned registry.
|
|
23
|
+
*
|
|
24
|
+
* @returns Completes after both owned resources settle.
|
|
25
|
+
*/
|
|
26
|
+
close(): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Configures one GCE registry-backed discovery owner.
|
|
30
|
+
*/
|
|
31
|
+
export interface GceNodeDiscoveryOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Supplies the owned leased registry.
|
|
34
|
+
*/
|
|
35
|
+
readonly registry: LeasedNodeRegistry;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the clock time used to evaluate registry lease expiry.
|
|
38
|
+
*
|
|
39
|
+
* @returns The current Unix time in milliseconds.
|
|
40
|
+
*/
|
|
41
|
+
readonly now?: () => number;
|
|
42
|
+
/**
|
|
43
|
+
* Supplies the refresh scheduler for deterministic tests.
|
|
44
|
+
*/
|
|
45
|
+
readonly scheduler?: NodeScheduler;
|
|
46
|
+
/**
|
|
47
|
+
* Supplies the refresh interval in milliseconds.
|
|
48
|
+
*/
|
|
49
|
+
readonly intervalMs?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Application-owned logger reserved for component-local records. The component
|
|
52
|
+
* does not retain or close the supplied logger.
|
|
53
|
+
*/
|
|
54
|
+
readonly logger?: ILogLayer;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=gce-node-discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gce-node-discovery.d.ts","sourceRoot":"","sources":["../../src/discovery/gce-node-discovery.ts"],"names":[],"mappings":"AAcA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAI1C;;GAEG;AACH,qBAAa,gBAAiB,YAAW,aAAa;;IAKpD;;;;OAIG;gBACS,OAAO,EAAE,uBAAuB;IAS5C;;;;;OAKG;IACH,KAAK,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,SAAS,eAAe,EAAE,KAAK,IAAI,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC;IAKnF;;;;OAIG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CA4BvB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IAGtC;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IAEtC;;;;OAIG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC;IAEnC;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE7B;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;CAC7B"}
|
|
@@ -0,0 +1,78 @@
|
|
|
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 { ScheduledNodeDiscovery, } from "@spine-event-engine/deployment";
|
|
15
|
+
import { GceRegistryReader } from "../registry/gce-registry-reader.js";
|
|
16
|
+
/**
|
|
17
|
+
* Publishes GCE registry membership and closes its owned registry on stop.
|
|
18
|
+
*/
|
|
19
|
+
export class GceNodeDiscovery {
|
|
20
|
+
#registry;
|
|
21
|
+
#discovery;
|
|
22
|
+
#closing;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a registry-backed GCE discovery owner.
|
|
25
|
+
*
|
|
26
|
+
* @param options Supplies the registry this owner closes and optional deterministic refresh seams.
|
|
27
|
+
*/
|
|
28
|
+
constructor(options) {
|
|
29
|
+
this.#registry = options.registry;
|
|
30
|
+
this.#discovery = new ScheduledNodeDiscovery({
|
|
31
|
+
reader: new GceRegistryReader(options.registry, options.now),
|
|
32
|
+
...(options.scheduler === undefined ? {} : { scheduler: options.scheduler }),
|
|
33
|
+
...(options.intervalMs === undefined ? {} : { intervalMs: options.intervalMs }),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Starts complete registry snapshot delivery.
|
|
38
|
+
*
|
|
39
|
+
* @param onSnapshot Receives each complete live-node snapshot.
|
|
40
|
+
* @returns Stops discovery and closes the owned registry.
|
|
41
|
+
*/
|
|
42
|
+
watch(onSnapshot) {
|
|
43
|
+
this.#discovery.watch(onSnapshot);
|
|
44
|
+
return () => this.close();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Stops discovery before closing the owned registry.
|
|
48
|
+
*
|
|
49
|
+
* @returns Completes after both owned resources settle.
|
|
50
|
+
*/
|
|
51
|
+
close() {
|
|
52
|
+
this.#closing ??= this.#close();
|
|
53
|
+
return this.#closing;
|
|
54
|
+
}
|
|
55
|
+
async #close() {
|
|
56
|
+
let discoveryError;
|
|
57
|
+
try {
|
|
58
|
+
await this.#discovery.close();
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
discoveryError = error;
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
await this.#registry.close();
|
|
65
|
+
}
|
|
66
|
+
catch (registryError) {
|
|
67
|
+
if (discoveryError !== undefined)
|
|
68
|
+
throw new AggregateError([this.#error(discoveryError), this.#error(registryError)], "GCE discovery and registry close both failed.");
|
|
69
|
+
throw this.#error(registryError);
|
|
70
|
+
}
|
|
71
|
+
if (discoveryError !== undefined)
|
|
72
|
+
throw this.#error(discoveryError);
|
|
73
|
+
}
|
|
74
|
+
#error(value) {
|
|
75
|
+
return value instanceof Error ? value : new Error(String(value));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=gce-node-discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gce-node-discovery.js","sourceRoot":"","sources":["../../src/discovery/gce-node-discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,sBAAsB,GAKvB,MAAM,gCAAgC,CAAC;AAGxC,O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CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QAC/B,CAAC;QAAC,OAAO,aAAsB,EAAE,CAAC;YAChC,IAAI,cAAc,KAAK,SAAS;gBAC9B,MAAM,IAAI,cAAc,CACtB,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,EACzD,+CAA+C,CAChD,CAAC;YACJ,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QACnC,CAAC;QACD,IAAI,cAAc,KAAK,SAAS;YAAE,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IACtE,CAAC;IAED,MAAM,CAAC,KAAc;QACnB,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACnE,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { GceMetadataService, type GceMetadata, type GceMetadataProvider, } from "./metadata/gce-metadata-service.js";
|
|
2
|
+
export { GceApplicationNode, type GceApplicationNodeOptions } from "./node/application-node.js";
|
|
3
|
+
export { GceNodeDiscovery, type GceNodeDiscoveryOptions } from "./discovery/gce-node-discovery.js";
|
|
4
|
+
export { type GceDeadlineFactory, type GceScheduler } from "./registrar/operations.js";
|
|
5
|
+
export { GceRegistrar, type GceRegistrarLifecycle, type GceRegistrarOptions, } from "./registrar/gce-registrar.js";
|
|
6
|
+
export { GceRegistryReader } from "./registry/gce-registry-reader.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,kBAAkB,EAClB,KAAK,WAAW,EAChB,KAAK,mBAAmB,GACzB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAAE,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AACnG,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EACL,YAAY,EACZ,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,GACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
export { GceMetadataService, } from "./metadata/gce-metadata-service.js";
|
|
15
|
+
export { GceApplicationNode } from "./node/application-node.js";
|
|
16
|
+
export { GceNodeDiscovery } from "./discovery/gce-node-discovery.js";
|
|
17
|
+
export {} from "./registrar/operations.js";
|
|
18
|
+
export { GceRegistrar, } from "./registrar/gce-registrar.js";
|
|
19
|
+
export { GceRegistryReader } from "./registry/gce-registry-reader.js";
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,kBAAkB,GAGnB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAkC,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAAE,gBAAgB,EAAgC,MAAM,mCAAmC,CAAC;AACnG,OAAO,EAA8C,MAAM,2BAA2B,CAAC;AACvF,OAAO,EACL,YAAY,GAGb,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supplies the trusted GCE metadata used to derive one stable application node.
|
|
3
|
+
*/
|
|
4
|
+
export interface GceMetadata {
|
|
5
|
+
/**
|
|
6
|
+
* Identifies the Google Cloud project containing the instance.
|
|
7
|
+
*/
|
|
8
|
+
readonly projectId: string;
|
|
9
|
+
/**
|
|
10
|
+
* Identifies the GCE zone containing the instance.
|
|
11
|
+
*/
|
|
12
|
+
readonly zone: string;
|
|
13
|
+
/**
|
|
14
|
+
* Identifies the numeric GCE instance.
|
|
15
|
+
*/
|
|
16
|
+
readonly instanceId: string;
|
|
17
|
+
/**
|
|
18
|
+
* Supplies the instance's private IPv4 or IPv6 address.
|
|
19
|
+
*/
|
|
20
|
+
readonly privateAddress: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Retrieves trusted instance metadata from the GCE metadata service.
|
|
24
|
+
*/
|
|
25
|
+
export interface GceMetadataProvider {
|
|
26
|
+
/**
|
|
27
|
+
* Reads the identity and private address of the current instance.
|
|
28
|
+
*
|
|
29
|
+
* @param signal Cancels the metadata request during registrar shutdown.
|
|
30
|
+
* @returns The validated metadata values.
|
|
31
|
+
*/
|
|
32
|
+
read(signal: AbortSignal): Promise<GceMetadata>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Reads GCE metadata using the required metadata-service request header.
|
|
36
|
+
*/
|
|
37
|
+
export declare class GceMetadataService implements GceMetadataProvider {
|
|
38
|
+
/**
|
|
39
|
+
* Reads and validates the instance identity and private address.
|
|
40
|
+
*
|
|
41
|
+
* @param signal Cancels all four metadata-service reads.
|
|
42
|
+
* @returns The normalized GCE metadata.
|
|
43
|
+
* @throws Error When a response is unsuccessful or contains invalid identity data.
|
|
44
|
+
*/
|
|
45
|
+
read(signal: AbortSignal): Promise<GceMetadata>;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=gce-metadata-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gce-metadata-service.d.ts","sourceRoot":"","sources":["../../src/metadata/gce-metadata-service.ts"],"names":[],"mappings":"AAcA;;GAEG;AACH,MAAM,WAAW,WAAW;IAG1B;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAGlC;;;;;OAKG;IACH,IAAI,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CACjD;AAED;;GAEG;AACH,qBAAa,kBAAmB,YAAW,mBAAmB;IAG5D;;;;;;OAMG;IACG,IAAI,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;CAuCtD"}
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
* Reads GCE metadata using the required metadata-service request header.
|
|
16
|
+
*/
|
|
17
|
+
export class GceMetadataService {
|
|
18
|
+
// prettier-ignore
|
|
19
|
+
/**
|
|
20
|
+
* Reads and validates the instance identity and private address.
|
|
21
|
+
*
|
|
22
|
+
* @param signal Cancels all four metadata-service reads.
|
|
23
|
+
* @returns The normalized GCE metadata.
|
|
24
|
+
* @throws Error When a response is unsuccessful or contains invalid identity data.
|
|
25
|
+
*/
|
|
26
|
+
async read(signal) {
|
|
27
|
+
const root = "http://metadata.google.internal/computeMetadata/v1";
|
|
28
|
+
const requests = new AbortController();
|
|
29
|
+
const requestSignal = AbortSignal.any([signal, requests.signal]);
|
|
30
|
+
const get = async (path) => {
|
|
31
|
+
const response = await fetch(`${root}/${path}`, {
|
|
32
|
+
signal: requestSignal,
|
|
33
|
+
headers: { "Metadata-Flavor": "Google" },
|
|
34
|
+
});
|
|
35
|
+
if (!response.ok)
|
|
36
|
+
throw new Error("GCE metadata request failed.");
|
|
37
|
+
return response.text();
|
|
38
|
+
};
|
|
39
|
+
const [projectId, zonePath, instanceId, privateAddress] = await Promise.all([
|
|
40
|
+
get("project/project-id"),
|
|
41
|
+
get("instance/zone"),
|
|
42
|
+
get("instance/id"),
|
|
43
|
+
get("instance/network-interfaces/0/ip"),
|
|
44
|
+
]).catch((error) => {
|
|
45
|
+
requests.abort();
|
|
46
|
+
throw error;
|
|
47
|
+
});
|
|
48
|
+
const normalizedProjectId = projectId.trim();
|
|
49
|
+
const zone = (zonePath.split("/").at(-1) ?? "").trim();
|
|
50
|
+
const normalizedInstanceId = instanceId.trim();
|
|
51
|
+
const normalizedPrivateAddress = privateAddress.trim();
|
|
52
|
+
if (!normalizedProjectId ||
|
|
53
|
+
!zone ||
|
|
54
|
+
!/^\d+$/.test(normalizedInstanceId) ||
|
|
55
|
+
!normalizedPrivateAddress)
|
|
56
|
+
throw new Error("GCE metadata response is invalid.");
|
|
57
|
+
return {
|
|
58
|
+
projectId: normalizedProjectId,
|
|
59
|
+
zone,
|
|
60
|
+
instanceId: normalizedInstanceId,
|
|
61
|
+
privateAddress: normalizedPrivateAddress,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=gce-metadata-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gce-metadata-service.js","sourceRoot":"","sources":["../../src/metadata/gce-metadata-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA4CH;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAC7B,kBAAkB;IAElB;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,CAAC,MAAmB;QAC5B,MAAM,IAAI,GAAG,oDAAoD,CAAC;QAClE,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;QACvC,MAAM,aAAa,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;QACjE,MAAM,GAAG,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;YACjC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,EAAE;gBAC9C,MAAM,EAAE,aAAa;gBACrB,OAAO,EAAE,EAAE,iBAAiB,EAAE,QAAQ,EAAE;aACzC,CAAC,CAAC;YACH,IAAI,CAAC,QAAQ,CAAC,EAAE;gBAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;YAClE,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;QACzB,CAAC,CAAC;QACF,MAAM,CAAC,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YAC1E,GAAG,CAAC,oBAAoB,CAAC;YACzB,GAAG,CAAC,eAAe,CAAC;YACpB,GAAG,CAAC,aAAa,CAAC;YAClB,GAAG,CAAC,kCAAkC,CAAC;SACxC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YAC1B,QAAQ,CAAC,KAAK,EAAE,CAAC;YACjB,MAAM,KAAK,CAAC;QACd,CAAC,CAAC,CAAC;QACH,MAAM,mBAAmB,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;QAC7C,MAAM,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QACvD,MAAM,oBAAoB,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC;QAC/C,MAAM,wBAAwB,GAAG,cAAc,CAAC,IAAI,EAAE,CAAC;QACvD,IACE,CAAC,mBAAmB;YACpB,CAAC,IAAI;YACL,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC;YACnC,CAAC,wBAAwB;YAEzB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvD,OAAO;YACL,SAAS,EAAE,mBAAmB;YAC9B,IAAI;YACJ,UAAU,EAAE,oBAAoB;YAChC,cAAc,EAAE,wBAAwB;SACzC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ApplicationNode } from "@spine-event-engine/deployment";
|
|
2
|
+
import type { GceMetadata } from "../metadata/gce-metadata-service.js";
|
|
3
|
+
/**
|
|
4
|
+
* Configures the reachable application endpoint derived from GCE metadata.
|
|
5
|
+
*/
|
|
6
|
+
export interface GceApplicationNodeOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Supplies the reachable gRPC TCP port.
|
|
9
|
+
*/
|
|
10
|
+
readonly port: number;
|
|
11
|
+
/**
|
|
12
|
+
* Overrides the default private HTTP origin for private DNS or a proxy.
|
|
13
|
+
*/
|
|
14
|
+
readonly endpoint?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Supplies the TLS authority required by an HTTPS endpoint.
|
|
17
|
+
*/
|
|
18
|
+
readonly tlsServerName?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Builds one canonical application node from trusted GCE metadata.
|
|
22
|
+
*/
|
|
23
|
+
export declare class GceApplicationNode {
|
|
24
|
+
/**
|
|
25
|
+
* Creates a stable GCE node using the private HTTP address by default.
|
|
26
|
+
*
|
|
27
|
+
* @param metadata Supplies trusted project, zone, numeric instance ID, and private address.
|
|
28
|
+
* @param options Supplies the port and optional canonical endpoint/TLS override.
|
|
29
|
+
* @returns A canonical application node whose ID is `gce/<project>/<zone>/<instance>`.
|
|
30
|
+
* @throws Error When metadata identity or endpoint/TLS values are invalid.
|
|
31
|
+
*/
|
|
32
|
+
static create(metadata: GceMetadata, options: GceApplicationNodeOptions): ApplicationNode;
|
|
33
|
+
private static host;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=application-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application-node.d.ts","sourceRoot":"","sources":["../../src/node/application-node.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,yBAAyB;IAGxC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAED;;GAEG;AAEH,qBAAa,kBAAkB;IAG7B;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,yBAAyB,GAAG,eAAe;IAezF,OAAO,CAAC,MAAM,CAAC,IAAI;CAGpB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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 { ApplicationNode } from "@spine-event-engine/deployment";
|
|
15
|
+
/**
|
|
16
|
+
* Builds one canonical application node from trusted GCE metadata.
|
|
17
|
+
*/
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
19
|
+
export class GceApplicationNode {
|
|
20
|
+
// prettier-ignore
|
|
21
|
+
/**
|
|
22
|
+
* Creates a stable GCE node using the private HTTP address by default.
|
|
23
|
+
*
|
|
24
|
+
* @param metadata Supplies trusted project, zone, numeric instance ID, and private address.
|
|
25
|
+
* @param options Supplies the port and optional canonical endpoint/TLS override.
|
|
26
|
+
* @returns A canonical application node whose ID is `gce/<project>/<zone>/<instance>`.
|
|
27
|
+
* @throws Error When metadata identity or endpoint/TLS values are invalid.
|
|
28
|
+
*/
|
|
29
|
+
static create(metadata, options) {
|
|
30
|
+
if (!metadata.projectId.trim() || !metadata.zone.trim() || !/^\d+$/.test(metadata.instanceId))
|
|
31
|
+
throw new Error("GCE metadata identity is invalid.");
|
|
32
|
+
if (!Number.isSafeInteger(options.port) || options.port < 1 || options.port > 65_535)
|
|
33
|
+
throw new RangeError("GCE node port must be a valid TCP port.");
|
|
34
|
+
const endpoint = options.endpoint ??
|
|
35
|
+
`http://${GceApplicationNode.host(metadata.privateAddress)}:${String(options.port)}`;
|
|
36
|
+
return new ApplicationNode({
|
|
37
|
+
id: `gce/${metadata.projectId}/${metadata.zone}/${metadata.instanceId}`,
|
|
38
|
+
endpoint,
|
|
39
|
+
...(options.tlsServerName === undefined ? {} : { tlsServerName: options.tlsServerName }),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
static host(address) {
|
|
43
|
+
return address.includes(":") ? `[${address}]` : address;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=application-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"application-node.js","sourceRoot":"","sources":["../../src/node/application-node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AA0BjE;;GAEG;AACH,kEAAkE;AAClE,MAAM,OAAO,kBAAkB;IAC7B,kBAAkB;IAElB;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,CAAC,QAAqB,EAAE,OAAkC;QACrE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;YAC3F,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,GAAG,CAAC,IAAI,OAAO,CAAC,IAAI,GAAG,MAAM;YAClF,MAAM,IAAI,UAAU,CAAC,yCAAyC,CAAC,CAAC;QAClE,MAAM,QAAQ,GACZ,OAAO,CAAC,QAAQ;YAChB,UAAU,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACvF,OAAO,IAAI,eAAe,CAAC;YACzB,EAAE,EAAE,OAAO,QAAQ,CAAC,SAAS,IAAI,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,UAAU,EAAE;YACvE,QAAQ;YACR,GAAG,CAAC,OAAO,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC;SACzF,CAAC,CAAC;IACL,CAAC;IAEO,MAAM,CAAC,IAAI,CAAC,OAAe;QACjC,OAAO,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC;IAC1D,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ILogLayer } from "loglayer";
|
|
2
|
+
/**
|
|
3
|
+
* Records a contained GCE renewal warning without changing registrar outcomes.
|
|
4
|
+
*
|
|
5
|
+
* @param logger Receives the contained record when supplied.
|
|
6
|
+
*/
|
|
7
|
+
export declare const gceRegistrarLog: Readonly<{
|
|
8
|
+
warnRenewal(logger: ILogLayer | undefined): void;
|
|
9
|
+
isPromiseLike(value: unknown): value is PromiseLike<unknown>;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=gce-registrar-log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gce-registrar-log.d.ts","sourceRoot":"","sources":["../../src/registrar/gce-registrar-log.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC;IACrC,WAAW,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,CAAC;IACjD,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;CAC9D,CAyBC,CAAC"}
|
|
@@ -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 GCE renewal warning without changing registrar outcomes.
|
|
16
|
+
*
|
|
17
|
+
* @param logger Receives the contained record when supplied.
|
|
18
|
+
*/
|
|
19
|
+
export const gceRegistrarLog = Object.freeze({
|
|
20
|
+
warnRenewal(logger) {
|
|
21
|
+
if (logger === undefined)
|
|
22
|
+
return;
|
|
23
|
+
try {
|
|
24
|
+
const record = logger.withMetadata({
|
|
25
|
+
operation: "deployment.gce.registrar.renew",
|
|
26
|
+
reasonCode: "failed",
|
|
27
|
+
});
|
|
28
|
+
const emit = record.warn.bind(record);
|
|
29
|
+
const emitted = emit("deployment.gce.registrar.renew_failed");
|
|
30
|
+
if (gceRegistrarLog.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=gce-registrar-log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gce-registrar-log.js","sourceRoot":"","sources":["../../src/registrar/gce-registrar-log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAGvB,MAAM,CAAC,MAAM,CAAC;IACjB,WAAW,CAAC,MAA6B;QACvC,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO;QACjC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC;gBACjC,SAAS,EAAE,gCAAgC;gBAC3C,UAAU,EAAE,QAAQ;aACrB,CAAC,CAAC;YACH,MAAM,IAAI,GAA+B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAClE,MAAM,OAAO,GAAG,IAAI,CAAC,uCAAuC,CAAC,CAAC;YAC9D,IAAI,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC;gBACxC,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,90 @@
|
|
|
1
|
+
import { type ApplicationNode, type LeasedNodeRegistry } from "@spine-event-engine/deployment";
|
|
2
|
+
import type { ILogLayer } from "loglayer";
|
|
3
|
+
import { type GceMetadataProvider } from "../metadata/gce-metadata-service.js";
|
|
4
|
+
import { type GceDeadlineFactory, type GceScheduler } from "./operations.js";
|
|
5
|
+
interface GceRegistrarBaseOptions {
|
|
6
|
+
readonly registry: LeasedNodeRegistry;
|
|
7
|
+
readonly identity?: string;
|
|
8
|
+
readonly scheduler?: GceScheduler;
|
|
9
|
+
readonly now?: () => number;
|
|
10
|
+
readonly deadlines?: GceDeadlineFactory;
|
|
11
|
+
readonly operationTimeoutMs?: number;
|
|
12
|
+
}
|
|
13
|
+
interface ExplicitRegistrarOptions extends GceRegistrarBaseOptions {
|
|
14
|
+
readonly node: ApplicationNode;
|
|
15
|
+
readonly metadata?: never;
|
|
16
|
+
readonly port?: never;
|
|
17
|
+
}
|
|
18
|
+
interface MetadataRegistrarOptions extends GceRegistrarBaseOptions {
|
|
19
|
+
readonly node?: undefined;
|
|
20
|
+
readonly metadata?: GceMetadataProvider;
|
|
21
|
+
readonly port: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Configures a ready-node registrar and its deterministic test seams.
|
|
25
|
+
*
|
|
26
|
+
* Supply either an explicit node or a metadata-derived node with its port.
|
|
27
|
+
*/
|
|
28
|
+
export type GceRegistrarOptions = (ExplicitRegistrarOptions & {
|
|
29
|
+
/**
|
|
30
|
+
* Application-owned logger reserved for component-local records. The registrar
|
|
31
|
+
* does not retain or close the supplied logger.
|
|
32
|
+
*/
|
|
33
|
+
readonly logger?: ILogLayer;
|
|
34
|
+
}) | (MetadataRegistrarOptions & {
|
|
35
|
+
/**
|
|
36
|
+
* Application-owned logger reserved for component-local records. The registrar
|
|
37
|
+
* does not retain or close the supplied logger.
|
|
38
|
+
*/
|
|
39
|
+
readonly logger?: ILogLayer;
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* Couples registrar lifecycle work to an application listener lifecycle.
|
|
43
|
+
*/
|
|
44
|
+
export interface GceRegistrarLifecycle {
|
|
45
|
+
/**
|
|
46
|
+
* Starts registration only after the listener is reachable.
|
|
47
|
+
*
|
|
48
|
+
* @returns Completes after the initial registration attempt settles.
|
|
49
|
+
*/
|
|
50
|
+
start(): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Removes the owned lease before listener network shutdown.
|
|
53
|
+
*
|
|
54
|
+
* @returns Completes after all admitted work and removal settle.
|
|
55
|
+
*/
|
|
56
|
+
close(): Promise<void>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Registers one ready GCE node and renews its lease.
|
|
60
|
+
*/
|
|
61
|
+
export declare class GceRegistrar {
|
|
62
|
+
#private;
|
|
63
|
+
/**
|
|
64
|
+
* Creates a registrar with twenty-second renewal and sixty-second leases by default.
|
|
65
|
+
*
|
|
66
|
+
* @param options Supplies registry ownership, node derivation, and deterministic seams.
|
|
67
|
+
*/
|
|
68
|
+
constructor(options: GceRegistrarOptions);
|
|
69
|
+
/**
|
|
70
|
+
* Starts initial registration after the listener is ready.
|
|
71
|
+
*
|
|
72
|
+
* @returns Completes after the first registration attempt has settled.
|
|
73
|
+
* @throws Error When this registrar has already closed.
|
|
74
|
+
*/
|
|
75
|
+
start(): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Removes this registrar's lease after fencing scheduled work.
|
|
78
|
+
*
|
|
79
|
+
* @returns Completes after admitted work settles and owned-row removal is attempted.
|
|
80
|
+
*/
|
|
81
|
+
close(): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Exposes listener-ready start and pre-network-close removal to a server assembly.
|
|
84
|
+
*
|
|
85
|
+
* @returns The lifecycle callbacks accepted by `Server.addListenerLifecycle()`.
|
|
86
|
+
*/
|
|
87
|
+
lifecycle(): GceRegistrarLifecycle;
|
|
88
|
+
}
|
|
89
|
+
export {};
|
|
90
|
+
//# sourceMappingURL=gce-registrar.d.ts.map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