@platformatic/runtime 3.18.0 → 3.19.0
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/prom-server.js +4 -4
- package/lib/runtime.js +24 -10
- package/lib/worker/itc.js +24 -1
- package/package.json +15 -15
- package/schema.json +12 -1
package/config.d.ts
CHANGED
package/lib/prom-server.js
CHANGED
|
@@ -68,7 +68,7 @@ async function checkLiveness (runtime) {
|
|
|
68
68
|
return check
|
|
69
69
|
} else if (typeof check === 'object') {
|
|
70
70
|
response = check
|
|
71
|
-
return check.status
|
|
71
|
+
return check.status || false
|
|
72
72
|
}
|
|
73
73
|
return false
|
|
74
74
|
})
|
|
@@ -85,7 +85,7 @@ export async function startPrometheusServer (runtime, opts) {
|
|
|
85
85
|
const metricsEndpoint = opts.endpoint ?? DEFAULT_METRICS_ENDPOINT
|
|
86
86
|
const auth = opts.auth ?? null
|
|
87
87
|
|
|
88
|
-
const promServer = fastify({ name: 'Prometheus server' })
|
|
88
|
+
const promServer = fastify({ name: 'Prometheus server', loggerInstance: runtime.logger })
|
|
89
89
|
promServer.register(fastifyAccepts)
|
|
90
90
|
|
|
91
91
|
let onRequestHook
|
|
@@ -151,7 +151,7 @@ export async function startPrometheusServer (runtime, opts) {
|
|
|
151
151
|
url: readinessEndpoint,
|
|
152
152
|
method: 'GET',
|
|
153
153
|
logLevel: 'warn',
|
|
154
|
-
handler: async (
|
|
154
|
+
handler: async (_req, reply) => {
|
|
155
155
|
reply.type('text/plain')
|
|
156
156
|
|
|
157
157
|
const { status, response } = await checkReadiness(runtime)
|
|
@@ -190,7 +190,7 @@ export async function startPrometheusServer (runtime, opts) {
|
|
|
190
190
|
url: livenessEndpoint,
|
|
191
191
|
method: 'GET',
|
|
192
192
|
logLevel: 'warn',
|
|
193
|
-
handler: async (
|
|
193
|
+
handler: async (_req, reply) => {
|
|
194
194
|
reply.type('text/plain')
|
|
195
195
|
|
|
196
196
|
const { status, response, readiness } = await checkLiveness(runtime)
|
package/lib/runtime.js
CHANGED
|
@@ -46,7 +46,7 @@ import { startScheduler } from './scheduler.js'
|
|
|
46
46
|
import { createSharedStore } from './shared-http-cache.js'
|
|
47
47
|
import { version } from './version.js'
|
|
48
48
|
import { HealthSignalsQueue } from './worker/health-signals.js'
|
|
49
|
-
import { sendViaITC, waitEventFromITC } from './worker/itc.js'
|
|
49
|
+
import { sendMultipleViaITC, sendViaITC, waitEventFromITC } from './worker/itc.js'
|
|
50
50
|
import { RoundRobinMap } from './worker/round-robin-map.js'
|
|
51
51
|
import {
|
|
52
52
|
kApplicationId,
|
|
@@ -945,31 +945,45 @@ export class Runtime extends EventEmitter {
|
|
|
945
945
|
}
|
|
946
946
|
|
|
947
947
|
async getCustomHealthChecks () {
|
|
948
|
-
const
|
|
948
|
+
const invocations = []
|
|
949
949
|
|
|
950
950
|
for (const id of this.#applications.keys()) {
|
|
951
951
|
const workersIds = this.#workers.getKeys(id)
|
|
952
952
|
for (const workerId of workersIds) {
|
|
953
|
-
|
|
954
|
-
status[workerId] = await sendViaITC(worker, 'getCustomHealthCheck')
|
|
953
|
+
invocations.push([workerId, this.#workers.get(workerId)])
|
|
955
954
|
}
|
|
956
955
|
}
|
|
957
956
|
|
|
958
|
-
return
|
|
957
|
+
return sendMultipleViaITC(
|
|
958
|
+
invocations,
|
|
959
|
+
'getCustomHealthCheck',
|
|
960
|
+
undefined,
|
|
961
|
+
[],
|
|
962
|
+
this.#concurrency,
|
|
963
|
+
this.#config.metrics.healthChecksTimeout,
|
|
964
|
+
{}
|
|
965
|
+
)
|
|
959
966
|
}
|
|
960
967
|
|
|
961
968
|
async getCustomReadinessChecks () {
|
|
962
|
-
const
|
|
969
|
+
const invocations = []
|
|
963
970
|
|
|
964
971
|
for (const id of this.#applications.keys()) {
|
|
965
972
|
const workersIds = this.#workers.getKeys(id)
|
|
966
973
|
for (const workerId of workersIds) {
|
|
967
|
-
|
|
968
|
-
status[workerId] = await sendViaITC(worker, 'getCustomReadinessCheck')
|
|
974
|
+
invocations.push([workerId, this.#workers.get(workerId)])
|
|
969
975
|
}
|
|
970
976
|
}
|
|
971
977
|
|
|
972
|
-
return
|
|
978
|
+
return sendMultipleViaITC(
|
|
979
|
+
invocations,
|
|
980
|
+
'getCustomReadinessCheck',
|
|
981
|
+
undefined,
|
|
982
|
+
[],
|
|
983
|
+
this.#concurrency,
|
|
984
|
+
this.#config.metrics.healthChecksTimeout,
|
|
985
|
+
{}
|
|
986
|
+
)
|
|
973
987
|
}
|
|
974
988
|
|
|
975
989
|
async getMetrics (format = 'json') {
|
|
@@ -1745,7 +1759,7 @@ export class Runtime extends EventEmitter {
|
|
|
1745
1759
|
const memoryUsage = health.heapUsed / maxHeapTotal
|
|
1746
1760
|
const unhealthy = health.elu > maxELU || memoryUsage > maxHeapUsed
|
|
1747
1761
|
|
|
1748
|
-
this.
|
|
1762
|
+
this.emit('application:worker:health', {
|
|
1749
1763
|
id: worker[kId],
|
|
1750
1764
|
application: id,
|
|
1751
1765
|
worker: index,
|
package/lib/worker/itc.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ensureLoggableError } from '@platformatic/foundation'
|
|
1
|
+
import { ensureLoggableError, executeInParallel, executeWithTimeout, kTimeout } from '@platformatic/foundation'
|
|
2
2
|
import { ITC } from '@platformatic/itc'
|
|
3
3
|
import { Unpromise } from '@watchable/unpromise'
|
|
4
4
|
import { once } from 'node:events'
|
|
@@ -65,6 +65,29 @@ export async function sendViaITC (worker, name, message, transferList) {
|
|
|
65
65
|
return safeHandleInITC(worker, () => worker[kITC].send(name, message, { transferList }))
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
export async function sendMultipleViaITC (
|
|
69
|
+
idsAndWorkerPairs,
|
|
70
|
+
name,
|
|
71
|
+
message,
|
|
72
|
+
transferList,
|
|
73
|
+
concurrency,
|
|
74
|
+
timeout = 5000,
|
|
75
|
+
timeoutFallbackValue = kTimeout
|
|
76
|
+
) {
|
|
77
|
+
const results = await executeInParallel(
|
|
78
|
+
async (id, worker) => {
|
|
79
|
+
return [
|
|
80
|
+
id,
|
|
81
|
+
await executeWithTimeout(sendViaITC(worker, name, message, transferList), timeout, timeoutFallbackValue)
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
idsAndWorkerPairs,
|
|
85
|
+
concurrency
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
return Object.fromEntries(results)
|
|
89
|
+
}
|
|
90
|
+
|
|
68
91
|
export async function waitEventFromITC (worker, event) {
|
|
69
92
|
return safeHandleInITC(worker, () => once(worker[kITC], event))
|
|
70
93
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/runtime",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.19.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
"typescript": "^5.5.4",
|
|
36
36
|
"undici-oidc-interceptor": "^0.5.0",
|
|
37
37
|
"why-is-node-running": "^2.2.2",
|
|
38
|
-
"@platformatic/composer": "3.
|
|
39
|
-
"@platformatic/
|
|
40
|
-
"@platformatic/gateway": "3.
|
|
41
|
-
"@platformatic/
|
|
42
|
-
"@platformatic/
|
|
43
|
-
"@platformatic/sql-mapper": "3.
|
|
44
|
-
"@platformatic/
|
|
45
|
-
"@platformatic/
|
|
38
|
+
"@platformatic/composer": "3.19.0",
|
|
39
|
+
"@platformatic/db": "3.19.0",
|
|
40
|
+
"@platformatic/gateway": "3.19.0",
|
|
41
|
+
"@platformatic/node": "3.19.0",
|
|
42
|
+
"@platformatic/service": "3.19.0",
|
|
43
|
+
"@platformatic/sql-mapper": "3.19.0",
|
|
44
|
+
"@platformatic/sql-graphql": "3.19.0",
|
|
45
|
+
"@platformatic/wattpm-pprof-capture": "3.19.0"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@fastify/accepts": "^5.0.0",
|
|
@@ -71,12 +71,12 @@
|
|
|
71
71
|
"undici": "^7.0.0",
|
|
72
72
|
"undici-thread-interceptor": "^0.15.0",
|
|
73
73
|
"ws": "^8.16.0",
|
|
74
|
-
"@platformatic/basic": "3.
|
|
75
|
-
"@platformatic/generators": "3.
|
|
76
|
-
"@platformatic/foundation": "3.
|
|
77
|
-
"@platformatic/
|
|
78
|
-
"@platformatic/
|
|
79
|
-
"@platformatic/
|
|
74
|
+
"@platformatic/basic": "3.19.0",
|
|
75
|
+
"@platformatic/generators": "3.19.0",
|
|
76
|
+
"@platformatic/foundation": "3.19.0",
|
|
77
|
+
"@platformatic/telemetry": "3.19.0",
|
|
78
|
+
"@platformatic/itc": "3.19.0",
|
|
79
|
+
"@platformatic/metrics": "3.19.0"
|
|
80
80
|
},
|
|
81
81
|
"engines": {
|
|
82
82
|
"node": ">=22.19.0"
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/runtime/3.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/runtime/3.19.0.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Runtime Config",
|
|
5
5
|
"type": "object",
|
|
@@ -1953,6 +1953,17 @@
|
|
|
1953
1953
|
}
|
|
1954
1954
|
]
|
|
1955
1955
|
},
|
|
1956
|
+
"healthChecksTimeouts": {
|
|
1957
|
+
"anyOf": [
|
|
1958
|
+
{
|
|
1959
|
+
"type": "integer"
|
|
1960
|
+
},
|
|
1961
|
+
{
|
|
1962
|
+
"type": "string"
|
|
1963
|
+
}
|
|
1964
|
+
],
|
|
1965
|
+
"default": 5000
|
|
1966
|
+
},
|
|
1956
1967
|
"plugins": {
|
|
1957
1968
|
"type": "array",
|
|
1958
1969
|
"items": {
|