@platformatic/gateway 3.0.0-alpha.6 → 3.0.0-rc.1
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/config.d.ts +1 -0
- package/lib/capability.js +23 -31
- package/package.json +8 -9
- package/schema.json +12 -1
package/config.d.ts
CHANGED
package/lib/capability.js
CHANGED
|
@@ -8,7 +8,6 @@ const kITC = Symbol.for('plt.runtime.itc')
|
|
|
8
8
|
|
|
9
9
|
export class GatewayCapability extends ServiceCapability {
|
|
10
10
|
#meta
|
|
11
|
-
#dependencies
|
|
12
11
|
|
|
13
12
|
constructor (root, config, context) {
|
|
14
13
|
super(root, config, context)
|
|
@@ -21,24 +20,19 @@ export class GatewayCapability extends ServiceCapability {
|
|
|
21
20
|
this.fastifyOptions.routerOptions.constraints = { notHost: notHostConstraints }
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
async
|
|
25
|
-
|
|
23
|
+
async init () {
|
|
24
|
+
if (this.status) {
|
|
25
|
+
return
|
|
26
|
+
}
|
|
26
27
|
|
|
28
|
+
await ensureApplications(this.applicationId, this.config)
|
|
27
29
|
const composedApplications = this.config.gateway?.applications
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
...(await Promise.all(
|
|
33
|
-
composedApplications.map(async application => {
|
|
34
|
-
return this.#parseDependency(application.id, application.origin)
|
|
35
|
-
})
|
|
36
|
-
))
|
|
37
|
-
)
|
|
38
|
-
}
|
|
30
|
+
.filter(this.#isLocalApplication.bind(this))
|
|
31
|
+
.map(a => a.id)
|
|
32
|
+
|
|
33
|
+
this.dependencies = Array.from(new Set([...this.dependencies, ...composedApplications]))
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
return this.#dependencies
|
|
35
|
+
await super.init()
|
|
42
36
|
}
|
|
43
37
|
|
|
44
38
|
registerMeta (meta) {
|
|
@@ -57,33 +51,31 @@ export class GatewayCapability extends ServiceCapability {
|
|
|
57
51
|
|
|
58
52
|
async isHealthy () {
|
|
59
53
|
// If no dependencies (still booting), assume healthy
|
|
60
|
-
if (this
|
|
61
|
-
const composedApplications = this.#dependencies.map(dep => dep.id)
|
|
54
|
+
if (this.dependencies) {
|
|
62
55
|
const workers = await globalThis[kITC].send('getWorkers')
|
|
63
56
|
|
|
57
|
+
const unstarted = new Set(this.dependencies)
|
|
64
58
|
for (const worker of Object.values(workers)) {
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
return false
|
|
59
|
+
if (worker.status === 'started') {
|
|
60
|
+
unstarted.delete(worker.application)
|
|
68
61
|
}
|
|
69
62
|
}
|
|
63
|
+
|
|
64
|
+
if (unstarted.size > 0) {
|
|
65
|
+
globalThis[kITC].notify('event', { event: 'unhealthy' })
|
|
66
|
+
return false
|
|
67
|
+
}
|
|
70
68
|
}
|
|
71
69
|
|
|
72
70
|
globalThis[kITC].notify('event', { event: 'healthy' })
|
|
73
71
|
return true
|
|
74
72
|
}
|
|
75
73
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (urlString) {
|
|
80
|
-
const remoteUrl = await replaceEnv(urlString, this.config[kMetadata].env)
|
|
81
|
-
|
|
82
|
-
if (remoteUrl) {
|
|
83
|
-
url = remoteUrl
|
|
84
|
-
}
|
|
74
|
+
#isLocalApplication (application) {
|
|
75
|
+
if (!application.origin) {
|
|
76
|
+
return true
|
|
85
77
|
}
|
|
86
78
|
|
|
87
|
-
return
|
|
79
|
+
return replaceEnv(application.origin, this.config[kMetadata].env).endsWith('.plt.local')
|
|
88
80
|
}
|
|
89
81
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/gateway",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-rc.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -32,8 +32,7 @@
|
|
|
32
32
|
"typescript": "^5.5.4",
|
|
33
33
|
"why-is-node-running": "2",
|
|
34
34
|
"ws": "^8.16.0",
|
|
35
|
-
"@platformatic/
|
|
36
|
-
"@platformatic/db": "3.0.0-alpha.6"
|
|
35
|
+
"@platformatic/db": "3.0.0-rc.1"
|
|
37
36
|
},
|
|
38
37
|
"dependencies": {
|
|
39
38
|
"@fastify/error": "^4.0.0",
|
|
@@ -64,11 +63,11 @@
|
|
|
64
63
|
"rfdc": "^1.3.1",
|
|
65
64
|
"semgrator": "^0.3.0",
|
|
66
65
|
"undici": "^7.0.0",
|
|
67
|
-
"@platformatic/basic": "3.0.0-
|
|
68
|
-
"@platformatic/
|
|
69
|
-
"@platformatic/
|
|
70
|
-
"@platformatic/
|
|
71
|
-
"@platformatic/telemetry": "3.0.0-
|
|
66
|
+
"@platformatic/basic": "3.0.0-rc.1",
|
|
67
|
+
"@platformatic/foundation": "^3.0.0-rc.1",
|
|
68
|
+
"@platformatic/scalar-theme": "3.0.0-rc.1",
|
|
69
|
+
"@platformatic/service": "3.0.0-rc.1",
|
|
70
|
+
"@platformatic/telemetry": "3.0.0-rc.1"
|
|
72
71
|
},
|
|
73
72
|
"engines": {
|
|
74
73
|
"node": ">=22.18.0"
|
|
@@ -77,7 +76,7 @@
|
|
|
77
76
|
"test": "node --test --test-reporter=cleaner-spec-reporter --test-concurrency=1 --test-timeout=2000000 test/*.test.js test/**/*.test.js",
|
|
78
77
|
"gen-schema": "node lib/schema.js > schema.json",
|
|
79
78
|
"gen-types": "json2ts > config.d.ts < schema.json",
|
|
80
|
-
"build": "
|
|
79
|
+
"build": "npm run gen-schema && npm run gen-types",
|
|
81
80
|
"lint": "eslint"
|
|
82
81
|
}
|
|
83
82
|
}
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/gateway/3.0.0-
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/gateway/3.0.0-rc.1.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Gateway Config",
|
|
5
5
|
"type": "object",
|
|
@@ -1412,6 +1412,13 @@
|
|
|
1412
1412
|
},
|
|
1413
1413
|
"additionalProperties": false
|
|
1414
1414
|
},
|
|
1415
|
+
"dependencies": {
|
|
1416
|
+
"type": "array",
|
|
1417
|
+
"items": {
|
|
1418
|
+
"type": "string"
|
|
1419
|
+
},
|
|
1420
|
+
"default": []
|
|
1421
|
+
},
|
|
1415
1422
|
"arguments": {
|
|
1416
1423
|
"type": "array",
|
|
1417
1424
|
"items": {
|
|
@@ -1793,6 +1800,10 @@
|
|
|
1793
1800
|
}
|
|
1794
1801
|
]
|
|
1795
1802
|
},
|
|
1803
|
+
"exitOnUnhandledErrors": {
|
|
1804
|
+
"default": true,
|
|
1805
|
+
"type": "boolean"
|
|
1806
|
+
},
|
|
1796
1807
|
"gracefulShutdown": {
|
|
1797
1808
|
"type": "object",
|
|
1798
1809
|
"properties": {
|