@platformatic/runtime 3.0.0-alpha.4 → 3.0.0-alpha.6
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 +10 -7
- package/eslint.config.js +2 -4
- package/index.d.ts +11 -11
- package/index.js +35 -46
- package/lib/config.js +80 -102
- package/lib/dependencies.js +27 -29
- package/lib/errors.js +65 -99
- package/lib/generator.js +160 -164
- package/lib/logger.js +6 -8
- package/lib/management-api.js +36 -39
- package/lib/prom-server.js +10 -14
- package/lib/runtime.js +752 -715
- package/lib/scheduler.js +13 -15
- package/lib/schema.js +11 -8
- package/lib/shared-http-cache.js +5 -9
- package/lib/upgrade.js +5 -9
- package/lib/utils.js +6 -14
- package/lib/version.js +7 -0
- package/lib/versions/v1.36.0.js +2 -4
- package/lib/versions/v1.5.0.js +2 -4
- package/lib/versions/v2.0.0.js +3 -5
- package/lib/versions/v3.0.0.js +16 -0
- package/lib/worker/{app.js → controller.js} +46 -56
- package/lib/worker/http-cache.js +11 -14
- package/lib/worker/interceptors.js +14 -18
- package/lib/worker/itc.js +74 -74
- package/lib/worker/main.js +45 -49
- package/lib/worker/messaging.js +23 -27
- package/lib/worker/round-robin-map.js +23 -19
- package/lib/worker/shared-context.js +2 -6
- package/lib/worker/symbols.js +12 -29
- package/package.json +21 -21
- package/schema.json +254 -20
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { kITC } from './symbols.js'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class SharedContext {
|
|
3
|
+
export class SharedContext {
|
|
6
4
|
constructor () {
|
|
7
5
|
this.sharedContext = null
|
|
8
6
|
}
|
|
@@ -22,5 +20,3 @@ class SharedContext {
|
|
|
22
20
|
this.sharedContext = context
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
|
-
|
|
26
|
-
module.exports = { SharedContext }
|
package/lib/worker/symbols.js
CHANGED
|
@@ -1,33 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const kInterceptors = Symbol.for('plt.runtime.worker.interceptors')
|
|
12
|
-
const kLastELU = Symbol.for('plt.runtime.worker.lastELU')
|
|
1
|
+
export const kConfig = Symbol.for('plt.runtime.config')
|
|
2
|
+
export const kId = Symbol.for('plt.runtime.id') // This is also used to detect if we are running in a Platformatic runtime thread
|
|
3
|
+
export const kFullId = Symbol.for('plt.runtime.fullId')
|
|
4
|
+
export const kApplicationId = Symbol.for('plt.runtime.application.id')
|
|
5
|
+
export const kWorkerId = Symbol.for('plt.runtime.worker.id')
|
|
6
|
+
export const kITC = Symbol.for('plt.runtime.itc')
|
|
7
|
+
export const kHealthCheckTimer = Symbol.for('plt.runtime.worker.healthCheckTimer')
|
|
8
|
+
export const kWorkerStatus = Symbol('plt.runtime.worker.status')
|
|
9
|
+
export const kInterceptors = Symbol.for('plt.runtime.worker.interceptors')
|
|
10
|
+
export const kLastELU = Symbol.for('plt.runtime.worker.lastELU')
|
|
13
11
|
|
|
14
12
|
// This string marker should be safe to use since it belongs to Unicode private area
|
|
15
|
-
const kStderrMarker = '\ue002'
|
|
13
|
+
export const kStderrMarker = '\ue002'
|
|
16
14
|
|
|
17
15
|
// Note that this is used to create a BroadcastChannel so it must be a string
|
|
18
|
-
const kWorkersBroadcast = 'plt.runtime.workers'
|
|
19
|
-
|
|
20
|
-
module.exports = {
|
|
21
|
-
kConfig,
|
|
22
|
-
kId,
|
|
23
|
-
kFullId,
|
|
24
|
-
kServiceId,
|
|
25
|
-
kWorkerId,
|
|
26
|
-
kITC,
|
|
27
|
-
kHealthCheckTimer,
|
|
28
|
-
kLastELU,
|
|
29
|
-
kWorkerStatus,
|
|
30
|
-
kStderrMarker,
|
|
31
|
-
kInterceptors,
|
|
32
|
-
kWorkersBroadcast
|
|
33
|
-
}
|
|
16
|
+
export const kWorkersBroadcast = 'plt.runtime.workers'
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/runtime",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"author": "Platformatic Inc. <oss@platformatic.dev> (https://platformatic.dev)",
|
|
7
8
|
"repository": {
|
|
8
9
|
"type": "git",
|
|
@@ -18,8 +19,8 @@
|
|
|
18
19
|
"@fastify/express": "^4.0.0",
|
|
19
20
|
"@fastify/formbody": "^8.0.0",
|
|
20
21
|
"autocannon": "^8.0.0",
|
|
21
|
-
"borp": "^0.20.0",
|
|
22
22
|
"c8": "^10.0.0",
|
|
23
|
+
"cleaner-spec-reporter": "^0.5.0",
|
|
23
24
|
"eslint": "9",
|
|
24
25
|
"execa": "^9.0.0",
|
|
25
26
|
"express": "^4.18.3",
|
|
@@ -33,12 +34,12 @@
|
|
|
33
34
|
"typescript": "^5.5.4",
|
|
34
35
|
"undici-oidc-interceptor": "^0.5.0",
|
|
35
36
|
"why-is-node-running": "^2.2.2",
|
|
36
|
-
"@platformatic/
|
|
37
|
-
"@platformatic/
|
|
38
|
-
"@platformatic/
|
|
39
|
-
"@platformatic/
|
|
40
|
-
"@platformatic/sql-
|
|
41
|
-
"@platformatic/
|
|
37
|
+
"@platformatic/gateway": "3.0.0-alpha.6",
|
|
38
|
+
"@platformatic/db": "3.0.0-alpha.6",
|
|
39
|
+
"@platformatic/node": "3.0.0-alpha.6",
|
|
40
|
+
"@platformatic/sql-mapper": "3.0.0-alpha.6",
|
|
41
|
+
"@platformatic/sql-graphql": "3.0.0-alpha.6",
|
|
42
|
+
"@platformatic/service": "3.0.0-alpha.6"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
45
|
"@fastify/accepts": "^5.0.0",
|
|
@@ -68,24 +69,23 @@
|
|
|
68
69
|
"undici": "^7.0.0",
|
|
69
70
|
"undici-thread-interceptor": "^0.14.0",
|
|
70
71
|
"ws": "^8.16.0",
|
|
71
|
-
"@platformatic/basic": "3.0.0-alpha.
|
|
72
|
-
"@platformatic/
|
|
73
|
-
"@platformatic/
|
|
74
|
-
"@platformatic/
|
|
75
|
-
"@platformatic/
|
|
76
|
-
"@platformatic/telemetry": "3.0.0-alpha.
|
|
72
|
+
"@platformatic/basic": "3.0.0-alpha.6",
|
|
73
|
+
"@platformatic/itc": "3.0.0-alpha.6",
|
|
74
|
+
"@platformatic/foundation": "3.0.0-alpha.6",
|
|
75
|
+
"@platformatic/metrics": "3.0.0-alpha.6",
|
|
76
|
+
"@platformatic/generators": "3.0.0-alpha.6",
|
|
77
|
+
"@platformatic/telemetry": "3.0.0-alpha.6"
|
|
77
78
|
},
|
|
78
79
|
"engines": {
|
|
79
80
|
"node": ">=22.18.0"
|
|
80
81
|
},
|
|
81
82
|
"scripts": {
|
|
82
|
-
"test": "
|
|
83
|
-
"test:main": "
|
|
84
|
-
"test:api": "
|
|
85
|
-
"test:cli": "
|
|
86
|
-
"test:start": "
|
|
87
|
-
"test:multiple-workers": "
|
|
88
|
-
"coverage": "pnpm run lint && borp -X fixtures -X test -C --concurrency=1 --timeout=1200000 ",
|
|
83
|
+
"test": "node --test --test-reporter=cleaner-spec-reporter --test-concurrency=1 --test-timeout=2000000 test/*.test.js test/**/*.test.js",
|
|
84
|
+
"test:main": "node --test --test-reporter=cleaner-spec-reporter --test-concurrency=1 --test-timeout=2000000 test/*.test.js test/versions/*.test.js",
|
|
85
|
+
"test:api": "node --test --test-reporter=cleaner-spec-reporter --test-concurrency=1 --test-timeout=2000000 test/api/*.test.js test/management-api/*.test.js",
|
|
86
|
+
"test:cli": "node --test --test-reporter=cleaner-spec-reporter --test-concurrency=1 --test-timeout=2000000 test/cli/*.test.js test/cli/**/*.test.js",
|
|
87
|
+
"test:start": "node --test --test-reporter=cleaner-spec-reporter --test-concurrency=1 --test-timeout=2000000 test/start/*.test.js",
|
|
88
|
+
"test:multiple-workers": "node --test --test-reporter=cleaner-spec-reporter --test-concurrency=1 --test-timeout=2000000 test/multiple-workers/*.test.js",
|
|
89
89
|
"gen-schema": "node lib/schema.js > schema.json",
|
|
90
90
|
"gen-types": "json2ts > config.d.ts < schema.json",
|
|
91
91
|
"build": "pnpm run gen-schema && pnpm run gen-types",
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/runtime/3.0.0-alpha.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/runtime/3.0.0-alpha.6.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Runtime Config",
|
|
5
5
|
"type": "object",
|
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
},
|
|
203
|
-
"
|
|
203
|
+
"applications": {
|
|
204
204
|
"type": "array",
|
|
205
205
|
"items": {
|
|
206
206
|
"type": "object",
|
|
@@ -429,17 +429,234 @@
|
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
431
|
},
|
|
432
|
-
"
|
|
433
|
-
"
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
432
|
+
"services": {
|
|
433
|
+
"type": "array",
|
|
434
|
+
"items": {
|
|
435
|
+
"type": "object",
|
|
436
|
+
"anyOf": [
|
|
437
|
+
{
|
|
438
|
+
"required": [
|
|
439
|
+
"id",
|
|
440
|
+
"path"
|
|
441
|
+
]
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
"required": [
|
|
445
|
+
"id",
|
|
446
|
+
"url"
|
|
447
|
+
]
|
|
448
|
+
}
|
|
449
|
+
],
|
|
450
|
+
"properties": {
|
|
451
|
+
"id": {
|
|
452
|
+
"type": "string"
|
|
453
|
+
},
|
|
454
|
+
"path": {
|
|
455
|
+
"type": "string",
|
|
456
|
+
"allowEmptyPaths": true,
|
|
457
|
+
"resolvePath": true
|
|
458
|
+
},
|
|
459
|
+
"config": {
|
|
460
|
+
"type": "string"
|
|
461
|
+
},
|
|
462
|
+
"url": {
|
|
463
|
+
"type": "string"
|
|
464
|
+
},
|
|
465
|
+
"gitBranch": {
|
|
466
|
+
"type": "string",
|
|
467
|
+
"default": "main"
|
|
468
|
+
},
|
|
469
|
+
"useHttp": {
|
|
470
|
+
"type": "boolean"
|
|
471
|
+
},
|
|
472
|
+
"workers": {
|
|
473
|
+
"anyOf": [
|
|
474
|
+
{
|
|
475
|
+
"type": "number",
|
|
476
|
+
"minimum": 1
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
"type": "string"
|
|
480
|
+
}
|
|
481
|
+
]
|
|
482
|
+
},
|
|
483
|
+
"health": {
|
|
484
|
+
"type": "object",
|
|
485
|
+
"default": {},
|
|
486
|
+
"properties": {
|
|
487
|
+
"enabled": {
|
|
488
|
+
"anyOf": [
|
|
489
|
+
{
|
|
490
|
+
"type": "boolean"
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
"type": "string"
|
|
494
|
+
}
|
|
495
|
+
]
|
|
496
|
+
},
|
|
497
|
+
"interval": {
|
|
498
|
+
"anyOf": [
|
|
499
|
+
{
|
|
500
|
+
"type": "number",
|
|
501
|
+
"minimum": 0
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
"type": "string"
|
|
505
|
+
}
|
|
506
|
+
]
|
|
507
|
+
},
|
|
508
|
+
"gracePeriod": {
|
|
509
|
+
"anyOf": [
|
|
510
|
+
{
|
|
511
|
+
"type": "number",
|
|
512
|
+
"minimum": 0
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
"type": "string"
|
|
516
|
+
}
|
|
517
|
+
]
|
|
518
|
+
},
|
|
519
|
+
"maxUnhealthyChecks": {
|
|
520
|
+
"anyOf": [
|
|
521
|
+
{
|
|
522
|
+
"type": "number",
|
|
523
|
+
"minimum": 1
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
"type": "string"
|
|
527
|
+
}
|
|
528
|
+
]
|
|
529
|
+
},
|
|
530
|
+
"maxELU": {
|
|
531
|
+
"anyOf": [
|
|
532
|
+
{
|
|
533
|
+
"type": "number",
|
|
534
|
+
"minimum": 0,
|
|
535
|
+
"maximum": 1
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
"type": "string"
|
|
539
|
+
}
|
|
540
|
+
]
|
|
541
|
+
},
|
|
542
|
+
"maxHeapUsed": {
|
|
543
|
+
"anyOf": [
|
|
544
|
+
{
|
|
545
|
+
"type": "number",
|
|
546
|
+
"minimum": 0,
|
|
547
|
+
"maximum": 1
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
"type": "string"
|
|
551
|
+
}
|
|
552
|
+
]
|
|
553
|
+
},
|
|
554
|
+
"maxHeapTotal": {
|
|
555
|
+
"anyOf": [
|
|
556
|
+
{
|
|
557
|
+
"type": "number",
|
|
558
|
+
"minimum": 0
|
|
559
|
+
},
|
|
560
|
+
{
|
|
561
|
+
"type": "string"
|
|
562
|
+
}
|
|
563
|
+
]
|
|
564
|
+
},
|
|
565
|
+
"maxYoungGeneration": {
|
|
566
|
+
"anyOf": [
|
|
567
|
+
{
|
|
568
|
+
"type": "number",
|
|
569
|
+
"minimum": 0
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
"type": "string"
|
|
573
|
+
}
|
|
574
|
+
]
|
|
575
|
+
}
|
|
576
|
+
},
|
|
577
|
+
"additionalProperties": false
|
|
578
|
+
},
|
|
579
|
+
"arguments": {
|
|
580
|
+
"type": "array",
|
|
581
|
+
"items": {
|
|
582
|
+
"type": "string"
|
|
583
|
+
}
|
|
584
|
+
},
|
|
585
|
+
"env": {
|
|
586
|
+
"type": "object",
|
|
587
|
+
"additionalProperties": {
|
|
588
|
+
"type": "string"
|
|
589
|
+
}
|
|
590
|
+
},
|
|
591
|
+
"envfile": {
|
|
592
|
+
"type": "string"
|
|
593
|
+
},
|
|
594
|
+
"sourceMaps": {
|
|
595
|
+
"type": "boolean",
|
|
596
|
+
"default": false
|
|
597
|
+
},
|
|
598
|
+
"packageManager": {
|
|
599
|
+
"type": "string",
|
|
600
|
+
"enum": [
|
|
601
|
+
"npm",
|
|
602
|
+
"pnpm",
|
|
603
|
+
"yarn"
|
|
604
|
+
]
|
|
605
|
+
},
|
|
606
|
+
"preload": {
|
|
607
|
+
"anyOf": [
|
|
608
|
+
{
|
|
609
|
+
"type": "string",
|
|
610
|
+
"resolvePath": true
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
"type": "array",
|
|
614
|
+
"items": {
|
|
615
|
+
"type": "string",
|
|
616
|
+
"resolvePath": true
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
]
|
|
620
|
+
},
|
|
621
|
+
"nodeOptions": {
|
|
622
|
+
"type": "string"
|
|
623
|
+
},
|
|
624
|
+
"telemetry": {
|
|
625
|
+
"type": "object",
|
|
626
|
+
"properties": {
|
|
627
|
+
"instrumentations": {
|
|
628
|
+
"type": "array",
|
|
629
|
+
"description": "An array of instrumentations loaded if telemetry is enabled",
|
|
630
|
+
"items": {
|
|
631
|
+
"oneOf": [
|
|
632
|
+
{
|
|
633
|
+
"type": "string"
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
"type": "object",
|
|
637
|
+
"properties": {
|
|
638
|
+
"package": {
|
|
639
|
+
"type": "string"
|
|
640
|
+
},
|
|
641
|
+
"exportName": {
|
|
642
|
+
"type": "string"
|
|
643
|
+
},
|
|
644
|
+
"options": {
|
|
645
|
+
"type": "object",
|
|
646
|
+
"additionalProperties": true
|
|
647
|
+
}
|
|
648
|
+
},
|
|
649
|
+
"required": [
|
|
650
|
+
"package"
|
|
651
|
+
]
|
|
652
|
+
}
|
|
653
|
+
]
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
440
658
|
}
|
|
441
|
-
|
|
442
|
-
"default": 1
|
|
659
|
+
}
|
|
443
660
|
},
|
|
444
661
|
"web": {
|
|
445
662
|
"type": "array",
|
|
@@ -670,6 +887,18 @@
|
|
|
670
887
|
}
|
|
671
888
|
}
|
|
672
889
|
},
|
|
890
|
+
"workers": {
|
|
891
|
+
"anyOf": [
|
|
892
|
+
{
|
|
893
|
+
"type": "number",
|
|
894
|
+
"minimum": 1
|
|
895
|
+
},
|
|
896
|
+
{
|
|
897
|
+
"type": "string"
|
|
898
|
+
}
|
|
899
|
+
],
|
|
900
|
+
"default": 1
|
|
901
|
+
},
|
|
673
902
|
"logger": {
|
|
674
903
|
"type": "object",
|
|
675
904
|
"properties": {
|
|
@@ -976,7 +1205,7 @@
|
|
|
976
1205
|
],
|
|
977
1206
|
"default": 10000
|
|
978
1207
|
},
|
|
979
|
-
"
|
|
1208
|
+
"application": {
|
|
980
1209
|
"anyOf": [
|
|
981
1210
|
{
|
|
982
1211
|
"type": "number",
|
|
@@ -992,7 +1221,7 @@
|
|
|
992
1221
|
"default": {},
|
|
993
1222
|
"required": [
|
|
994
1223
|
"runtime",
|
|
995
|
-
"
|
|
1224
|
+
"application"
|
|
996
1225
|
],
|
|
997
1226
|
"additionalProperties": false
|
|
998
1227
|
},
|
|
@@ -1423,13 +1652,13 @@
|
|
|
1423
1652
|
}
|
|
1424
1653
|
]
|
|
1425
1654
|
},
|
|
1426
|
-
"
|
|
1655
|
+
"applicationName": {
|
|
1427
1656
|
"type": "string",
|
|
1428
|
-
"description": "The name of the
|
|
1657
|
+
"description": "The name of the application. Defaults to the folder name if not specified."
|
|
1429
1658
|
},
|
|
1430
1659
|
"version": {
|
|
1431
1660
|
"type": "string",
|
|
1432
|
-
"description": "The version of the
|
|
1661
|
+
"description": "The version of the application (optional)"
|
|
1433
1662
|
},
|
|
1434
1663
|
"skip": {
|
|
1435
1664
|
"type": "array",
|
|
@@ -1536,7 +1765,7 @@
|
|
|
1536
1765
|
}
|
|
1537
1766
|
},
|
|
1538
1767
|
"required": [
|
|
1539
|
-
"
|
|
1768
|
+
"applicationName"
|
|
1540
1769
|
],
|
|
1541
1770
|
"additionalProperties": false
|
|
1542
1771
|
},
|
|
@@ -1557,7 +1786,7 @@
|
|
|
1557
1786
|
}
|
|
1558
1787
|
}
|
|
1559
1788
|
},
|
|
1560
|
-
"
|
|
1789
|
+
"applicationTimeout": {
|
|
1561
1790
|
"anyOf": [
|
|
1562
1791
|
{
|
|
1563
1792
|
"type": "number",
|
|
@@ -1581,7 +1810,7 @@
|
|
|
1581
1810
|
],
|
|
1582
1811
|
"default": 30000
|
|
1583
1812
|
},
|
|
1584
|
-
"
|
|
1813
|
+
"resolvedApplicationsBasePath": {
|
|
1585
1814
|
"type": "string",
|
|
1586
1815
|
"default": "external"
|
|
1587
1816
|
},
|
|
@@ -1668,6 +1897,11 @@
|
|
|
1668
1897
|
"autoload"
|
|
1669
1898
|
]
|
|
1670
1899
|
},
|
|
1900
|
+
{
|
|
1901
|
+
"required": [
|
|
1902
|
+
"applications"
|
|
1903
|
+
]
|
|
1904
|
+
},
|
|
1671
1905
|
{
|
|
1672
1906
|
"required": [
|
|
1673
1907
|
"services"
|