@platformatic/runtime 3.0.0-alpha.5 → 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
package/lib/errors.js
CHANGED
|
@@ -1,158 +1,124 @@
|
|
|
1
|
-
|
|
1
|
+
import createError from '@fastify/error'
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
export const ERROR_PREFIX = 'PLT_RUNTIME'
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const AddressInUseError = createError(
|
|
5
|
+
export const AddressInUseError = createError(
|
|
8
6
|
`${ERROR_PREFIX}_EADDR_IN_USE`,
|
|
9
7
|
'The current port is in use by another application'
|
|
10
8
|
)
|
|
11
|
-
const RuntimeExitedError = createError(
|
|
9
|
+
export const RuntimeExitedError = createError(
|
|
12
10
|
`${ERROR_PREFIX}_RUNTIME_EXIT`,
|
|
13
11
|
'The runtime exited before the operation completed'
|
|
14
12
|
)
|
|
15
|
-
const RuntimeAbortedError = createError(`${ERROR_PREFIX}_RUNTIME_ABORT`, 'The runtime aborted the operation')
|
|
13
|
+
export const RuntimeAbortedError = createError(`${ERROR_PREFIX}_RUNTIME_ABORT`, 'The runtime aborted the operation')
|
|
16
14
|
// The following two use the same code as we only need to differentiate the label
|
|
17
|
-
const
|
|
18
|
-
`${ERROR_PREFIX}
|
|
19
|
-
'The
|
|
15
|
+
export const ApplicationExitedError = createError(
|
|
16
|
+
`${ERROR_PREFIX}_APPLICATION_EXIT`,
|
|
17
|
+
'The application "%s" exited prematurely with error code %d'
|
|
20
18
|
)
|
|
21
|
-
const WorkerExitedError = createError(
|
|
22
|
-
`${ERROR_PREFIX}
|
|
23
|
-
'The worker %s of the
|
|
19
|
+
export const WorkerExitedError = createError(
|
|
20
|
+
`${ERROR_PREFIX}_APPLICATION_WORKER_EXIT`,
|
|
21
|
+
'The worker %s of the application "%s" exited prematurely with error code %d'
|
|
24
22
|
)
|
|
25
|
-
const UnknownRuntimeAPICommandError = createError(
|
|
23
|
+
export const UnknownRuntimeAPICommandError = createError(
|
|
26
24
|
`${ERROR_PREFIX}_UNKNOWN_RUNTIME_API_COMMAND`,
|
|
27
25
|
'Unknown Runtime API command "%s"'
|
|
28
26
|
)
|
|
29
|
-
const
|
|
30
|
-
`${ERROR_PREFIX}
|
|
31
|
-
'
|
|
27
|
+
export const ApplicationNotFoundError = createError(
|
|
28
|
+
`${ERROR_PREFIX}_APPLICATION_NOT_FOUND`,
|
|
29
|
+
'Application %s not found. Available applications are: %s'
|
|
32
30
|
)
|
|
33
|
-
const WorkerNotFoundError = createError(
|
|
31
|
+
export const WorkerNotFoundError = createError(
|
|
34
32
|
`${ERROR_PREFIX}_WORKER_NOT_FOUND`,
|
|
35
|
-
'Worker %s of
|
|
33
|
+
'Worker %s of application %s not found. Available applications are: %s'
|
|
34
|
+
)
|
|
35
|
+
export const ApplicationNotStartedError = createError(
|
|
36
|
+
`${ERROR_PREFIX}_APPLICATION_NOT_STARTED`,
|
|
37
|
+
"Application with id '%s' is not started"
|
|
36
38
|
)
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"Service with id '%s' failed to start in %dms."
|
|
39
|
+
export const ApplicationStartTimeoutError = createError(
|
|
40
|
+
`${ERROR_PREFIX}_APPLICATION_START_TIMEOUT`,
|
|
41
|
+
"Application with id '%s' failed to start in %dms."
|
|
41
42
|
)
|
|
42
|
-
const FailedToRetrieveOpenAPISchemaError = createError(
|
|
43
|
+
export const FailedToRetrieveOpenAPISchemaError = createError(
|
|
43
44
|
`${ERROR_PREFIX}_FAILED_TO_RETRIEVE_OPENAPI_SCHEMA`,
|
|
44
|
-
'Failed to retrieve OpenAPI schema for
|
|
45
|
+
'Failed to retrieve OpenAPI schema for application with id "%s": %s'
|
|
45
46
|
)
|
|
46
|
-
const FailedToRetrieveGraphQLSchemaError = createError(
|
|
47
|
+
export const FailedToRetrieveGraphQLSchemaError = createError(
|
|
47
48
|
`${ERROR_PREFIX}_FAILED_TO_RETRIEVE_GRAPHQL_SCHEMA`,
|
|
48
|
-
'Failed to retrieve GraphQL schema for
|
|
49
|
+
'Failed to retrieve GraphQL schema for application with id "%s": %s'
|
|
49
50
|
)
|
|
50
|
-
const FailedToRetrieveMetaError = createError(
|
|
51
|
+
export const FailedToRetrieveMetaError = createError(
|
|
51
52
|
`${ERROR_PREFIX}_FAILED_TO_RETRIEVE_META`,
|
|
52
|
-
'Failed to retrieve metadata for
|
|
53
|
+
'Failed to retrieve metadata for application with id "%s": %s'
|
|
53
54
|
)
|
|
54
|
-
const FailedToRetrieveMetricsError = createError(
|
|
55
|
+
export const FailedToRetrieveMetricsError = createError(
|
|
55
56
|
`${ERROR_PREFIX}_FAILED_TO_RETRIEVE_METRICS`,
|
|
56
|
-
'Failed to retrieve metrics for
|
|
57
|
+
'Failed to retrieve metrics for application with id "%s": %s'
|
|
57
58
|
)
|
|
58
|
-
const FailedToRetrieveHealthError = createError(
|
|
59
|
+
export const FailedToRetrieveHealthError = createError(
|
|
59
60
|
`${ERROR_PREFIX}_FAILED_TO_RETRIEVE_HEALTH`,
|
|
60
|
-
'Failed to retrieve health for
|
|
61
|
+
'Failed to retrieve health for application with id "%s": %s'
|
|
61
62
|
)
|
|
62
|
-
const FailedToPerformCustomHealthCheckError = createError(
|
|
63
|
+
export const FailedToPerformCustomHealthCheckError = createError(
|
|
63
64
|
`${ERROR_PREFIX}_FAILED_TO_PERFORM_CUSTOM_HEALTH_CHECK`,
|
|
64
|
-
'Failed to perform custom healthcheck for
|
|
65
|
+
'Failed to perform custom healthcheck for application with id "%s": %s'
|
|
65
66
|
)
|
|
66
|
-
const FailedToPerformCustomReadinessCheckError = createError(
|
|
67
|
+
export const FailedToPerformCustomReadinessCheckError = createError(
|
|
67
68
|
`${ERROR_PREFIX}_FAILED_TO_PERFORM_CUSTOM_READINESS_CHECK`,
|
|
68
|
-
'Failed to perform custom readiness check for
|
|
69
|
+
'Failed to perform custom readiness check for application with id "%s": %s'
|
|
69
70
|
)
|
|
70
|
-
const ApplicationAlreadyStartedError = createError(
|
|
71
|
+
export const ApplicationAlreadyStartedError = createError(
|
|
71
72
|
`${ERROR_PREFIX}_APPLICATION_ALREADY_STARTED`,
|
|
72
73
|
'Application is already started'
|
|
73
74
|
)
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
'Application has not been started'
|
|
77
|
-
)
|
|
78
|
-
const ConfigPathMustBeStringError = createError(
|
|
75
|
+
export const RuntimeNotStartedError = createError(`${ERROR_PREFIX}_NOT_STARTED`, 'Application has not been started')
|
|
76
|
+
export const ConfigPathMustBeStringError = createError(
|
|
79
77
|
`${ERROR_PREFIX}_CONFIG_PATH_MUST_BE_STRING`,
|
|
80
78
|
'Config path must be a string'
|
|
81
79
|
)
|
|
82
|
-
const NoConfigFileFoundError = createError(
|
|
80
|
+
export const NoConfigFileFoundError = createError(
|
|
83
81
|
`${ERROR_PREFIX}_NO_CONFIG_FILE_FOUND`,
|
|
84
|
-
"No config file found for
|
|
82
|
+
"No config file found for application '%s'"
|
|
85
83
|
)
|
|
86
|
-
const InvalidEntrypointError = createError(
|
|
84
|
+
export const InvalidEntrypointError = createError(
|
|
87
85
|
`${ERROR_PREFIX}_INVALID_ENTRYPOINT`,
|
|
88
86
|
"Invalid entrypoint: '%s' does not exist"
|
|
89
87
|
)
|
|
90
|
-
const MissingEntrypointError = createError(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
'The "services" property cannot be used when the "web" property is also defined'
|
|
88
|
+
export const MissingEntrypointError = createError(
|
|
89
|
+
`${ERROR_PREFIX}_MISSING_ENTRYPOINT`,
|
|
90
|
+
'Missing application entrypoint.'
|
|
94
91
|
)
|
|
95
|
-
const MissingDependencyError = createError(`${ERROR_PREFIX}_MISSING_DEPENDENCY`, 'Missing dependency: "%s"')
|
|
96
|
-
const InspectAndInspectBrkError = createError(
|
|
92
|
+
export const MissingDependencyError = createError(`${ERROR_PREFIX}_MISSING_DEPENDENCY`, 'Missing dependency: "%s"')
|
|
93
|
+
export const InspectAndInspectBrkError = createError(
|
|
97
94
|
`${ERROR_PREFIX}_INSPECT_AND_INSPECT_BRK`,
|
|
98
95
|
'--inspect and --inspect-brk cannot be used together'
|
|
99
96
|
)
|
|
100
|
-
const InspectorPortError = createError(
|
|
97
|
+
export const InspectorPortError = createError(
|
|
101
98
|
`${ERROR_PREFIX}_INSPECTOR_PORT`,
|
|
102
99
|
'Inspector port must be 0 or in range 1024 to 65535'
|
|
103
100
|
)
|
|
104
|
-
const InspectorHostError = createError(`${ERROR_PREFIX}_INSPECTOR_HOST`, 'Inspector host cannot be empty')
|
|
105
|
-
const CannotMapSpecifierToAbsolutePathError = createError(
|
|
101
|
+
export const InspectorHostError = createError(`${ERROR_PREFIX}_INSPECTOR_HOST`, 'Inspector host cannot be empty')
|
|
102
|
+
export const CannotMapSpecifierToAbsolutePathError = createError(
|
|
106
103
|
`${ERROR_PREFIX}_CANNOT_MAP_SPECIFIER_TO_ABSOLUTE_PATH`,
|
|
107
104
|
'Cannot map "%s" to an absolute path'
|
|
108
105
|
)
|
|
109
|
-
const NodeInspectorFlagsNotSupportedError = createError(
|
|
106
|
+
export const NodeInspectorFlagsNotSupportedError = createError(
|
|
110
107
|
`${ERROR_PREFIX}_NODE_INSPECTOR_FLAGS_NOT_SUPPORTED`,
|
|
111
108
|
"The Node.js inspector flags are not supported. Please use 'platformatic start --inspect' instead."
|
|
112
109
|
)
|
|
113
|
-
const FailedToUnlinkManagementApiSocket = createError(
|
|
110
|
+
export const FailedToUnlinkManagementApiSocket = createError(
|
|
114
111
|
`${ERROR_PREFIX}_FAILED_TO_UNLINK_MANAGEMENT_API_SOCKET`,
|
|
115
112
|
'Failed to unlink management API socket "%s"'
|
|
116
113
|
)
|
|
117
|
-
const LogFileNotFound = createError(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
UnknownRuntimeAPICommandError,
|
|
129
|
-
ServiceNotFoundError,
|
|
130
|
-
WorkerNotFoundError,
|
|
131
|
-
ServiceNotStartedError,
|
|
132
|
-
ServiceStartTimeoutError,
|
|
133
|
-
FailedToRetrieveOpenAPISchemaError,
|
|
134
|
-
FailedToRetrieveGraphQLSchemaError,
|
|
135
|
-
FailedToRetrieveMetaError,
|
|
136
|
-
FailedToRetrieveMetricsError,
|
|
137
|
-
FailedToRetrieveHealthError,
|
|
138
|
-
FailedToPerformCustomHealthCheckError,
|
|
139
|
-
FailedToPerformCustomReadinessCheckError,
|
|
140
|
-
ApplicationAlreadyStartedError,
|
|
141
|
-
ApplicationNotStartedError,
|
|
142
|
-
ConfigPathMustBeStringError,
|
|
143
|
-
NoConfigFileFoundError,
|
|
144
|
-
InvalidEntrypointError,
|
|
145
|
-
MissingEntrypointError,
|
|
146
|
-
InvalidServicesWithWebError,
|
|
147
|
-
MissingDependencyError,
|
|
148
|
-
InspectAndInspectBrkError,
|
|
149
|
-
InspectorPortError,
|
|
150
|
-
InspectorHostError,
|
|
151
|
-
CannotMapSpecifierToAbsolutePathError,
|
|
152
|
-
NodeInspectorFlagsNotSupportedError,
|
|
153
|
-
FailedToUnlinkManagementApiSocket,
|
|
154
|
-
LogFileNotFound,
|
|
155
|
-
WorkerIsRequired,
|
|
156
|
-
InvalidArgumentError,
|
|
157
|
-
MessagingError
|
|
158
|
-
}
|
|
114
|
+
export const LogFileNotFound = createError(
|
|
115
|
+
`${ERROR_PREFIX}_LOG_FILE_NOT_FOUND`,
|
|
116
|
+
'Log file with index %s not found',
|
|
117
|
+
404
|
|
118
|
+
)
|
|
119
|
+
export const WorkerIsRequired = createError(`${ERROR_PREFIX}_REQUIRED_WORKER`, 'The worker parameter is required')
|
|
120
|
+
export const InvalidArgumentError = createError(`${ERROR_PREFIX}_INVALID_ARGUMENT`, 'Invalid argument: "%s"')
|
|
121
|
+
export const MessagingError = createError(
|
|
122
|
+
`${ERROR_PREFIX}_MESSAGING_ERROR`,
|
|
123
|
+
'Cannot send a message to application "%s": %s'
|
|
124
|
+
)
|