@platformatic/gateway 3.13.0 → 3.14.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 +62 -3
- package/lib/capability.js +28 -0
- package/package.json +7 -7
- package/schema.json +126 -16
package/config.d.ts
CHANGED
|
@@ -388,7 +388,20 @@ export interface PlatformaticGatewayConfig {
|
|
|
388
388
|
services?: {
|
|
389
389
|
[k: string]: unknown;
|
|
390
390
|
}[];
|
|
391
|
-
workers?:
|
|
391
|
+
workers?:
|
|
392
|
+
| number
|
|
393
|
+
| string
|
|
394
|
+
| {
|
|
395
|
+
static?: number;
|
|
396
|
+
dynamic?: boolean;
|
|
397
|
+
minimum?: number;
|
|
398
|
+
maximum?: number;
|
|
399
|
+
total?: number;
|
|
400
|
+
maxMemory?: number;
|
|
401
|
+
cooldown?: number;
|
|
402
|
+
gracePeriod?: number;
|
|
403
|
+
[k: string]: unknown;
|
|
404
|
+
};
|
|
392
405
|
workersRestartDelay?: number | string;
|
|
393
406
|
logger?: {
|
|
394
407
|
level: (
|
|
@@ -596,6 +609,37 @@ export interface PlatformaticGatewayConfig {
|
|
|
596
609
|
};
|
|
597
610
|
plugins?: string[];
|
|
598
611
|
timeout?: number | string;
|
|
612
|
+
/**
|
|
613
|
+
* Configuration for exporting metrics to an OTLP endpoint
|
|
614
|
+
*/
|
|
615
|
+
otlpExporter?: {
|
|
616
|
+
/**
|
|
617
|
+
* Enable or disable OTLP metrics export
|
|
618
|
+
*/
|
|
619
|
+
enabled?: boolean | string;
|
|
620
|
+
/**
|
|
621
|
+
* OTLP endpoint URL (e.g., http://collector:4318/v1/metrics)
|
|
622
|
+
*/
|
|
623
|
+
endpoint: string;
|
|
624
|
+
/**
|
|
625
|
+
* Interval in milliseconds between metric pushes
|
|
626
|
+
*/
|
|
627
|
+
interval?: number | string;
|
|
628
|
+
/**
|
|
629
|
+
* Additional HTTP headers for authentication
|
|
630
|
+
*/
|
|
631
|
+
headers?: {
|
|
632
|
+
[k: string]: string;
|
|
633
|
+
};
|
|
634
|
+
/**
|
|
635
|
+
* Service name for OTLP resource attributes
|
|
636
|
+
*/
|
|
637
|
+
serviceName?: string;
|
|
638
|
+
/**
|
|
639
|
+
* Service version for OTLP resource attributes
|
|
640
|
+
*/
|
|
641
|
+
serviceVersion?: string;
|
|
642
|
+
};
|
|
599
643
|
};
|
|
600
644
|
telemetry?: {
|
|
601
645
|
enabled?: boolean | string;
|
|
@@ -679,13 +723,28 @@ export interface PlatformaticGatewayConfig {
|
|
|
679
723
|
maxTotalMemory?: number;
|
|
680
724
|
minWorkers?: number;
|
|
681
725
|
maxWorkers?: number;
|
|
726
|
+
cooldownSec?: number;
|
|
727
|
+
gracePeriod?: number;
|
|
728
|
+
/**
|
|
729
|
+
* @deprecated
|
|
730
|
+
*/
|
|
682
731
|
scaleUpELU?: number;
|
|
732
|
+
/**
|
|
733
|
+
* @deprecated
|
|
734
|
+
*/
|
|
683
735
|
scaleDownELU?: number;
|
|
736
|
+
/**
|
|
737
|
+
* @deprecated
|
|
738
|
+
*/
|
|
684
739
|
timeWindowSec?: number;
|
|
740
|
+
/**
|
|
741
|
+
* @deprecated
|
|
742
|
+
*/
|
|
685
743
|
scaleDownTimeWindowSec?: number;
|
|
686
|
-
|
|
744
|
+
/**
|
|
745
|
+
* @deprecated
|
|
746
|
+
*/
|
|
687
747
|
scaleIntervalSec?: number;
|
|
688
|
-
gracePeriod?: number;
|
|
689
748
|
};
|
|
690
749
|
inspectorOptions?: {
|
|
691
750
|
host?: string;
|
package/lib/capability.js
CHANGED
|
@@ -8,6 +8,7 @@ const kITC = Symbol.for('plt.runtime.itc')
|
|
|
8
8
|
|
|
9
9
|
export class GatewayCapability extends ServiceCapability {
|
|
10
10
|
#meta
|
|
11
|
+
#runtimeEventHandler
|
|
11
12
|
|
|
12
13
|
constructor (root, config, context) {
|
|
13
14
|
super(root, config, context)
|
|
@@ -35,6 +36,27 @@ export class GatewayCapability extends ServiceCapability {
|
|
|
35
36
|
await super.init()
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
start () {
|
|
40
|
+
if (this.url) {
|
|
41
|
+
return this.url
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const url = super.start()
|
|
45
|
+
|
|
46
|
+
this.#runtimeEventHandler = this.#handleRuntimeEvent.bind(this)
|
|
47
|
+
globalThis[kITC]?.on('runtime:event', this.#runtimeEventHandler)
|
|
48
|
+
|
|
49
|
+
return url
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
stop () {
|
|
53
|
+
if (this.#runtimeEventHandler) {
|
|
54
|
+
globalThis[kITC]?.removeListener('runtime:event', this.#runtimeEventHandler)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return super.stop()
|
|
58
|
+
}
|
|
59
|
+
|
|
38
60
|
registerMeta (meta) {
|
|
39
61
|
this.#meta = Object.assign(this.#meta ?? {}, meta)
|
|
40
62
|
}
|
|
@@ -78,4 +100,10 @@ export class GatewayCapability extends ServiceCapability {
|
|
|
78
100
|
|
|
79
101
|
return replaceEnv(application.origin, this.config[kMetadata].env).endsWith('.plt.local')
|
|
80
102
|
}
|
|
103
|
+
|
|
104
|
+
#handleRuntimeEvent ({ event }) {
|
|
105
|
+
if (event === 'application:added' || event === 'application:removed') {
|
|
106
|
+
globalThis[kITC].notify('request:restart')
|
|
107
|
+
}
|
|
108
|
+
}
|
|
81
109
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/gateway",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.14.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"typescript": "^5.5.4",
|
|
34
34
|
"why-is-node-running": "2",
|
|
35
35
|
"ws": "^8.16.0",
|
|
36
|
-
"@platformatic/db": "3.
|
|
36
|
+
"@platformatic/db": "3.14.0"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@fastify/error": "^4.0.0",
|
|
@@ -64,11 +64,11 @@
|
|
|
64
64
|
"rfdc": "^1.3.1",
|
|
65
65
|
"semgrator": "^0.3.0",
|
|
66
66
|
"undici": "^7.0.0",
|
|
67
|
-
"@platformatic/basic": "3.
|
|
68
|
-
"@platformatic/
|
|
69
|
-
"@platformatic/
|
|
70
|
-
"@platformatic/
|
|
71
|
-
"@platformatic/
|
|
67
|
+
"@platformatic/basic": "3.14.0",
|
|
68
|
+
"@platformatic/foundation": "^3.14.0",
|
|
69
|
+
"@platformatic/service": "3.14.0",
|
|
70
|
+
"@platformatic/telemetry": "3.14.0",
|
|
71
|
+
"@platformatic/scalar-theme": "3.14.0"
|
|
72
72
|
},
|
|
73
73
|
"engines": {
|
|
74
74
|
"node": ">=22.19.0"
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/gateway/3.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/gateway/3.14.0.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Gateway Config",
|
|
5
5
|
"type": "object",
|
|
@@ -1319,11 +1319,27 @@
|
|
|
1319
1319
|
"workers": {
|
|
1320
1320
|
"anyOf": [
|
|
1321
1321
|
{
|
|
1322
|
-
"type": "number"
|
|
1323
|
-
"minimum": 1
|
|
1322
|
+
"type": "number"
|
|
1324
1323
|
},
|
|
1325
1324
|
{
|
|
1326
1325
|
"type": "string"
|
|
1326
|
+
},
|
|
1327
|
+
{
|
|
1328
|
+
"type": "object",
|
|
1329
|
+
"properties": {
|
|
1330
|
+
"static": {
|
|
1331
|
+
"type": "number",
|
|
1332
|
+
"minimum": 1
|
|
1333
|
+
},
|
|
1334
|
+
"minimum": {
|
|
1335
|
+
"type": "number",
|
|
1336
|
+
"minimum": 1
|
|
1337
|
+
},
|
|
1338
|
+
"maximum": {
|
|
1339
|
+
"type": "number",
|
|
1340
|
+
"minimum": 0
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1327
1343
|
}
|
|
1328
1344
|
]
|
|
1329
1345
|
},
|
|
@@ -1544,6 +1560,43 @@
|
|
|
1544
1560
|
},
|
|
1545
1561
|
{
|
|
1546
1562
|
"type": "string"
|
|
1563
|
+
},
|
|
1564
|
+
{
|
|
1565
|
+
"type": "object",
|
|
1566
|
+
"properties": {
|
|
1567
|
+
"static": {
|
|
1568
|
+
"type": "number",
|
|
1569
|
+
"minimum": 1
|
|
1570
|
+
},
|
|
1571
|
+
"dynamic": {
|
|
1572
|
+
"type": "boolean",
|
|
1573
|
+
"default": false
|
|
1574
|
+
},
|
|
1575
|
+
"minimum": {
|
|
1576
|
+
"type": "number",
|
|
1577
|
+
"minimum": 1
|
|
1578
|
+
},
|
|
1579
|
+
"maximum": {
|
|
1580
|
+
"type": "number",
|
|
1581
|
+
"minimum": 0
|
|
1582
|
+
},
|
|
1583
|
+
"total": {
|
|
1584
|
+
"type": "number",
|
|
1585
|
+
"minimum": 1
|
|
1586
|
+
},
|
|
1587
|
+
"maxMemory": {
|
|
1588
|
+
"type": "number",
|
|
1589
|
+
"minimum": 0
|
|
1590
|
+
},
|
|
1591
|
+
"cooldown": {
|
|
1592
|
+
"type": "number",
|
|
1593
|
+
"minimum": 0
|
|
1594
|
+
},
|
|
1595
|
+
"gracePeriod": {
|
|
1596
|
+
"type": "number",
|
|
1597
|
+
"minimum": 0
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1547
1600
|
}
|
|
1548
1601
|
]
|
|
1549
1602
|
},
|
|
@@ -2320,6 +2373,58 @@
|
|
|
2320
2373
|
}
|
|
2321
2374
|
],
|
|
2322
2375
|
"default": 10000
|
|
2376
|
+
},
|
|
2377
|
+
"otlpExporter": {
|
|
2378
|
+
"type": "object",
|
|
2379
|
+
"description": "Configuration for exporting metrics to an OTLP endpoint",
|
|
2380
|
+
"properties": {
|
|
2381
|
+
"enabled": {
|
|
2382
|
+
"anyOf": [
|
|
2383
|
+
{
|
|
2384
|
+
"type": "boolean"
|
|
2385
|
+
},
|
|
2386
|
+
{
|
|
2387
|
+
"type": "string"
|
|
2388
|
+
}
|
|
2389
|
+
],
|
|
2390
|
+
"description": "Enable or disable OTLP metrics export"
|
|
2391
|
+
},
|
|
2392
|
+
"endpoint": {
|
|
2393
|
+
"type": "string",
|
|
2394
|
+
"description": "OTLP endpoint URL (e.g., http://collector:4318/v1/metrics)"
|
|
2395
|
+
},
|
|
2396
|
+
"interval": {
|
|
2397
|
+
"anyOf": [
|
|
2398
|
+
{
|
|
2399
|
+
"type": "integer"
|
|
2400
|
+
},
|
|
2401
|
+
{
|
|
2402
|
+
"type": "string"
|
|
2403
|
+
}
|
|
2404
|
+
],
|
|
2405
|
+
"default": 60000,
|
|
2406
|
+
"description": "Interval in milliseconds between metric pushes"
|
|
2407
|
+
},
|
|
2408
|
+
"headers": {
|
|
2409
|
+
"type": "object",
|
|
2410
|
+
"additionalProperties": {
|
|
2411
|
+
"type": "string"
|
|
2412
|
+
},
|
|
2413
|
+
"description": "Additional HTTP headers for authentication"
|
|
2414
|
+
},
|
|
2415
|
+
"serviceName": {
|
|
2416
|
+
"type": "string",
|
|
2417
|
+
"description": "Service name for OTLP resource attributes"
|
|
2418
|
+
},
|
|
2419
|
+
"serviceVersion": {
|
|
2420
|
+
"type": "string",
|
|
2421
|
+
"description": "Service version for OTLP resource attributes"
|
|
2422
|
+
}
|
|
2423
|
+
},
|
|
2424
|
+
"required": [
|
|
2425
|
+
"endpoint"
|
|
2426
|
+
],
|
|
2427
|
+
"additionalProperties": false
|
|
2323
2428
|
}
|
|
2324
2429
|
},
|
|
2325
2430
|
"additionalProperties": false
|
|
@@ -2479,35 +2584,40 @@
|
|
|
2479
2584
|
"type": "number",
|
|
2480
2585
|
"minimum": 1
|
|
2481
2586
|
},
|
|
2587
|
+
"cooldownSec": {
|
|
2588
|
+
"type": "number",
|
|
2589
|
+
"minimum": 0
|
|
2590
|
+
},
|
|
2591
|
+
"gracePeriod": {
|
|
2592
|
+
"type": "number",
|
|
2593
|
+
"minimum": 0
|
|
2594
|
+
},
|
|
2482
2595
|
"scaleUpELU": {
|
|
2483
2596
|
"type": "number",
|
|
2484
2597
|
"minimum": 0,
|
|
2485
|
-
"maximum": 1
|
|
2598
|
+
"maximum": 1,
|
|
2599
|
+
"deprecated": true
|
|
2486
2600
|
},
|
|
2487
2601
|
"scaleDownELU": {
|
|
2488
2602
|
"type": "number",
|
|
2489
2603
|
"minimum": 0,
|
|
2490
|
-
"maximum": 1
|
|
2604
|
+
"maximum": 1,
|
|
2605
|
+
"deprecated": true
|
|
2491
2606
|
},
|
|
2492
2607
|
"timeWindowSec": {
|
|
2493
2608
|
"type": "number",
|
|
2494
|
-
"minimum": 0
|
|
2609
|
+
"minimum": 0,
|
|
2610
|
+
"deprecated": true
|
|
2495
2611
|
},
|
|
2496
2612
|
"scaleDownTimeWindowSec": {
|
|
2497
2613
|
"type": "number",
|
|
2498
|
-
"minimum": 0
|
|
2499
|
-
|
|
2500
|
-
"cooldownSec": {
|
|
2501
|
-
"type": "number",
|
|
2502
|
-
"minimum": 0
|
|
2614
|
+
"minimum": 0,
|
|
2615
|
+
"deprecated": true
|
|
2503
2616
|
},
|
|
2504
2617
|
"scaleIntervalSec": {
|
|
2505
2618
|
"type": "number",
|
|
2506
|
-
"minimum": 0
|
|
2507
|
-
|
|
2508
|
-
"gracePeriod": {
|
|
2509
|
-
"type": "number",
|
|
2510
|
-
"minimum": 0
|
|
2619
|
+
"minimum": 0,
|
|
2620
|
+
"deprecated": true
|
|
2511
2621
|
}
|
|
2512
2622
|
},
|
|
2513
2623
|
"additionalProperties": false
|