@platformatic/gateway 3.13.1 → 3.15.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 CHANGED
@@ -388,7 +388,20 @@ export interface PlatformaticGatewayConfig {
388
388
  services?: {
389
389
  [k: string]: unknown;
390
390
  }[];
391
- workers?: number | string;
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: (
@@ -472,6 +485,7 @@ export interface PlatformaticGatewayConfig {
472
485
  rejectUnauthorized?: boolean;
473
486
  };
474
487
  };
488
+ reuseTcpPorts?: boolean;
475
489
  startTimeout?: number;
476
490
  restartOnError?: boolean | number;
477
491
  exitOnUnhandledErrors?: boolean;
@@ -596,6 +610,37 @@ export interface PlatformaticGatewayConfig {
596
610
  };
597
611
  plugins?: string[];
598
612
  timeout?: number | string;
613
+ /**
614
+ * Configuration for exporting metrics to an OTLP endpoint
615
+ */
616
+ otlpExporter?: {
617
+ /**
618
+ * Enable or disable OTLP metrics export
619
+ */
620
+ enabled?: boolean | string;
621
+ /**
622
+ * OTLP endpoint URL (e.g., http://collector:4318/v1/metrics)
623
+ */
624
+ endpoint: string;
625
+ /**
626
+ * Interval in milliseconds between metric pushes
627
+ */
628
+ interval?: number | string;
629
+ /**
630
+ * Additional HTTP headers for authentication
631
+ */
632
+ headers?: {
633
+ [k: string]: string;
634
+ };
635
+ /**
636
+ * Service name for OTLP resource attributes
637
+ */
638
+ serviceName?: string;
639
+ /**
640
+ * Service version for OTLP resource attributes
641
+ */
642
+ serviceVersion?: string;
643
+ };
599
644
  };
600
645
  telemetry?: {
601
646
  enabled?: boolean | string;
@@ -679,13 +724,28 @@ export interface PlatformaticGatewayConfig {
679
724
  maxTotalMemory?: number;
680
725
  minWorkers?: number;
681
726
  maxWorkers?: number;
727
+ cooldownSec?: number;
728
+ gracePeriod?: number;
729
+ /**
730
+ * @deprecated
731
+ */
682
732
  scaleUpELU?: number;
733
+ /**
734
+ * @deprecated
735
+ */
683
736
  scaleDownELU?: number;
737
+ /**
738
+ * @deprecated
739
+ */
684
740
  timeWindowSec?: number;
741
+ /**
742
+ * @deprecated
743
+ */
685
744
  scaleDownTimeWindowSec?: number;
686
- cooldownSec?: number;
745
+ /**
746
+ * @deprecated
747
+ */
687
748
  scaleIntervalSec?: number;
688
- gracePeriod?: number;
689
749
  };
690
750
  inspectorOptions?: {
691
751
  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,28 @@ export class GatewayCapability extends ServiceCapability {
35
36
  await super.init()
36
37
  }
37
38
 
39
+ async start () {
40
+ if (this.url) {
41
+ return this.url
42
+ }
43
+
44
+ await super._start()
45
+ const url = await super.start()
46
+
47
+ this.#runtimeEventHandler = this.#handleRuntimeEvent.bind(this)
48
+ globalThis[kITC]?.on('runtime:event', this.#runtimeEventHandler)
49
+
50
+ return url
51
+ }
52
+
53
+ stop () {
54
+ if (this.#runtimeEventHandler) {
55
+ globalThis[kITC]?.removeListener('runtime:event', this.#runtimeEventHandler)
56
+ }
57
+
58
+ return super.stop()
59
+ }
60
+
38
61
  registerMeta (meta) {
39
62
  this.#meta = Object.assign(this.#meta ?? {}, meta)
40
63
  }
@@ -78,4 +101,10 @@ export class GatewayCapability extends ServiceCapability {
78
101
 
79
102
  return replaceEnv(application.origin, this.config[kMetadata].env).endsWith('.plt.local')
80
103
  }
104
+
105
+ #handleRuntimeEvent ({ event }) {
106
+ if (event === 'application:added' || event === 'application:removed') {
107
+ globalThis[kITC].notify('request:restart')
108
+ }
109
+ }
81
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/gateway",
3
- "version": "3.13.1",
3
+ "version": "3.15.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.13.1"
36
+ "@platformatic/db": "3.15.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.13.1",
68
- "@platformatic/foundation": "^3.13.1",
69
- "@platformatic/scalar-theme": "3.13.1",
70
- "@platformatic/service": "3.13.1",
71
- "@platformatic/telemetry": "3.13.1"
67
+ "@platformatic/foundation": "^3.15.0",
68
+ "@platformatic/basic": "3.15.0",
69
+ "@platformatic/scalar-theme": "3.15.0",
70
+ "@platformatic/service": "3.15.0",
71
+ "@platformatic/telemetry": "3.15.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.13.1.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/gateway/3.15.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Gateway Config",
5
5
  "type": "object",
@@ -1316,14 +1316,34 @@
1316
1316
  "useHttp": {
1317
1317
  "type": "boolean"
1318
1318
  },
1319
+ "reuseTcpPorts": {
1320
+ "type": "boolean",
1321
+ "default": true
1322
+ },
1319
1323
  "workers": {
1320
1324
  "anyOf": [
1321
1325
  {
1322
- "type": "number",
1323
- "minimum": 1
1326
+ "type": "number"
1324
1327
  },
1325
1328
  {
1326
1329
  "type": "string"
1330
+ },
1331
+ {
1332
+ "type": "object",
1333
+ "properties": {
1334
+ "static": {
1335
+ "type": "number",
1336
+ "minimum": 1
1337
+ },
1338
+ "minimum": {
1339
+ "type": "number",
1340
+ "minimum": 1
1341
+ },
1342
+ "maximum": {
1343
+ "type": "number",
1344
+ "minimum": 0
1345
+ }
1346
+ }
1327
1347
  }
1328
1348
  ]
1329
1349
  },
@@ -1544,6 +1564,43 @@
1544
1564
  },
1545
1565
  {
1546
1566
  "type": "string"
1567
+ },
1568
+ {
1569
+ "type": "object",
1570
+ "properties": {
1571
+ "static": {
1572
+ "type": "number",
1573
+ "minimum": 1
1574
+ },
1575
+ "dynamic": {
1576
+ "type": "boolean",
1577
+ "default": false
1578
+ },
1579
+ "minimum": {
1580
+ "type": "number",
1581
+ "minimum": 1
1582
+ },
1583
+ "maximum": {
1584
+ "type": "number",
1585
+ "minimum": 0
1586
+ },
1587
+ "total": {
1588
+ "type": "number",
1589
+ "minimum": 1
1590
+ },
1591
+ "maxMemory": {
1592
+ "type": "number",
1593
+ "minimum": 0
1594
+ },
1595
+ "cooldown": {
1596
+ "type": "number",
1597
+ "minimum": 0
1598
+ },
1599
+ "gracePeriod": {
1600
+ "type": "number",
1601
+ "minimum": 0
1602
+ }
1603
+ }
1547
1604
  }
1548
1605
  ]
1549
1606
  },
@@ -1829,6 +1886,10 @@
1829
1886
  },
1830
1887
  "additionalProperties": false
1831
1888
  },
1889
+ "reuseTcpPorts": {
1890
+ "type": "boolean",
1891
+ "default": true
1892
+ },
1832
1893
  "startTimeout": {
1833
1894
  "default": 30000,
1834
1895
  "type": "number",
@@ -2320,6 +2381,58 @@
2320
2381
  }
2321
2382
  ],
2322
2383
  "default": 10000
2384
+ },
2385
+ "otlpExporter": {
2386
+ "type": "object",
2387
+ "description": "Configuration for exporting metrics to an OTLP endpoint",
2388
+ "properties": {
2389
+ "enabled": {
2390
+ "anyOf": [
2391
+ {
2392
+ "type": "boolean"
2393
+ },
2394
+ {
2395
+ "type": "string"
2396
+ }
2397
+ ],
2398
+ "description": "Enable or disable OTLP metrics export"
2399
+ },
2400
+ "endpoint": {
2401
+ "type": "string",
2402
+ "description": "OTLP endpoint URL (e.g., http://collector:4318/v1/metrics)"
2403
+ },
2404
+ "interval": {
2405
+ "anyOf": [
2406
+ {
2407
+ "type": "integer"
2408
+ },
2409
+ {
2410
+ "type": "string"
2411
+ }
2412
+ ],
2413
+ "default": 60000,
2414
+ "description": "Interval in milliseconds between metric pushes"
2415
+ },
2416
+ "headers": {
2417
+ "type": "object",
2418
+ "additionalProperties": {
2419
+ "type": "string"
2420
+ },
2421
+ "description": "Additional HTTP headers for authentication"
2422
+ },
2423
+ "serviceName": {
2424
+ "type": "string",
2425
+ "description": "Service name for OTLP resource attributes"
2426
+ },
2427
+ "serviceVersion": {
2428
+ "type": "string",
2429
+ "description": "Service version for OTLP resource attributes"
2430
+ }
2431
+ },
2432
+ "required": [
2433
+ "endpoint"
2434
+ ],
2435
+ "additionalProperties": false
2323
2436
  }
2324
2437
  },
2325
2438
  "additionalProperties": false
@@ -2479,35 +2592,40 @@
2479
2592
  "type": "number",
2480
2593
  "minimum": 1
2481
2594
  },
2595
+ "cooldownSec": {
2596
+ "type": "number",
2597
+ "minimum": 0
2598
+ },
2599
+ "gracePeriod": {
2600
+ "type": "number",
2601
+ "minimum": 0
2602
+ },
2482
2603
  "scaleUpELU": {
2483
2604
  "type": "number",
2484
2605
  "minimum": 0,
2485
- "maximum": 1
2606
+ "maximum": 1,
2607
+ "deprecated": true
2486
2608
  },
2487
2609
  "scaleDownELU": {
2488
2610
  "type": "number",
2489
2611
  "minimum": 0,
2490
- "maximum": 1
2612
+ "maximum": 1,
2613
+ "deprecated": true
2491
2614
  },
2492
2615
  "timeWindowSec": {
2493
2616
  "type": "number",
2494
- "minimum": 0
2617
+ "minimum": 0,
2618
+ "deprecated": true
2495
2619
  },
2496
2620
  "scaleDownTimeWindowSec": {
2497
2621
  "type": "number",
2498
- "minimum": 0
2499
- },
2500
- "cooldownSec": {
2501
- "type": "number",
2502
- "minimum": 0
2622
+ "minimum": 0,
2623
+ "deprecated": true
2503
2624
  },
2504
2625
  "scaleIntervalSec": {
2505
2626
  "type": "number",
2506
- "minimum": 0
2507
- },
2508
- "gracePeriod": {
2509
- "type": "number",
2510
- "minimum": 0
2627
+ "minimum": 0,
2628
+ "deprecated": true
2511
2629
  }
2512
2630
  },
2513
2631
  "additionalProperties": false