@zudojs/core 0.1.0 → 1.0.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/LICENSE +21 -0
- package/README.md +141 -7
- package/dist/application/application.d.ts +43 -2
- package/dist/application/application.js +111 -13
- package/dist/application/applicationContext.context.d.ts +15 -0
- package/dist/application/applicationContext.context.js +12 -0
- package/dist/application/createApplication.d.ts +78 -0
- package/dist/application/createApplication.js +104 -0
- package/dist/application/index.d.ts +2 -1
- package/dist/application/index.js +2 -1
- package/dist/configuration/configurationManager.manager.d.ts +32 -0
- package/dist/configuration/configurationManager.manager.js +86 -7
- package/dist/configuration/core/configuration.d.ts +60 -15
- package/dist/configuration/core/configuration.js +248 -51
- package/dist/configuration/core/configurationKey.key.d.ts +4 -2
- package/dist/configuration/core/configurationKey.key.js +2 -13
- package/dist/configuration/core/configurationPath.path.d.ts +17 -0
- package/dist/configuration/core/configurationPath.path.js +33 -0
- package/dist/configuration/core/index.d.ts +7 -1
- package/dist/configuration/core/index.js +1 -0
- package/dist/configuration/error/configurationError.error.d.ts +11 -0
- package/dist/configuration/error/configurationError.error.js +29 -1
- package/dist/configuration/error/configurationRedactor.redactor.d.ts +16 -0
- package/dist/configuration/error/configurationRedactor.redactor.js +83 -5
- package/dist/configuration/error/index.d.ts +2 -1
- package/dist/configuration/error/index.js +2 -1
- package/dist/configuration/index.d.ts +1 -1
- package/dist/configuration/loader/configurationLoader.loader.d.ts +47 -9
- package/dist/configuration/loader/configurationLoader.loader.js +107 -26
- package/dist/configuration/loader/index.d.ts +1 -1
- package/dist/configuration/loader/index.js +1 -1
- package/dist/configuration/registry/configurationProvider.provider.d.ts +26 -1
- package/dist/configuration/registry/configurationProvider.provider.js +33 -7
- package/dist/configuration/registry/configurationRegistry.registry.js +2 -1
- package/dist/configuration/schema/configurationSchema.schema.d.ts +0 -4
- package/dist/configuration/schema/configurationSchema.schema.js +11 -32
- package/dist/configuration/schema/configurationValidation.validator.d.ts +14 -2
- package/dist/configuration/schema/configurationValidation.validator.js +55 -7
- package/dist/configuration/schema/index.d.ts +1 -1
- package/dist/configuration/schema/index.js +1 -1
- package/dist/container/container.d.ts +52 -5
- package/dist/container/container.js +110 -33
- package/dist/container/index.d.ts +1 -1
- package/dist/container/index.js +1 -1
- package/dist/container/scope.d.ts +7 -6
- package/dist/context/core/contextAliases.deprecated.d.ts +32 -0
- package/dist/context/core/contextAliases.deprecated.js +6 -0
- package/dist/context/core/executionContext.context.d.ts +8 -0
- package/dist/context/core/executionContext.context.js +38 -15
- package/dist/context/core/index.d.ts +2 -2
- package/dist/context/core/index.js +2 -2
- package/dist/context/index.d.ts +20 -0
- package/dist/context/index.js +20 -0
- package/dist/context/provider/contextProvider.provider.d.ts +7 -4
- package/dist/context/provider/contextProvider.provider.js +9 -6
- package/dist/context/provider/contextStorage.storage.d.ts +47 -7
- package/dist/context/provider/contextStorage.storage.js +54 -12
- package/dist/context/provider/defaultContextStorage.storage.d.ts +18 -0
- package/dist/context/provider/defaultContextStorage.storage.js +20 -0
- package/dist/context/provider/index.d.ts +2 -1
- package/dist/context/provider/index.js +1 -0
- package/dist/errors/exceptions.d.ts +22 -0
- package/dist/errors/exceptions.js +38 -1
- package/dist/errors/frameworkError.error.d.ts +6 -9
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +14 -0
- package/dist/lifecycle/core/index.d.ts +1 -1
- package/dist/lifecycle/core/index.js +1 -1
- package/dist/lifecycle/core/lifecycle.d.ts +47 -2
- package/dist/lifecycle/core/lifecycle.js +251 -85
- package/dist/lifecycle/core/lifecycleRegistry.registry.d.ts +8 -0
- package/dist/lifecycle/core/lifecycleRegistry.registry.js +20 -1
- package/dist/lifecycle/manager/lifecycleManager.manager.d.ts +21 -2
- package/dist/lifecycle/manager/lifecycleManager.manager.js +62 -99
- package/dist/lifecycle/scope/lifecycleScope.scope.d.ts +22 -1
- package/dist/lifecycle/scope/lifecycleScope.scope.js +85 -17
- package/dist/logging/console/consoleLogger.logger.d.ts +20 -1
- package/dist/logging/console/consoleLogger.logger.js +77 -11
- package/dist/logging/console/loggerFactory.factory.d.ts +6 -5
- package/dist/logging/console/loggerFactory.factory.js +1 -7
- package/dist/logging/core/index.d.ts +4 -3
- package/dist/logging/core/index.js +4 -3
- package/dist/logging/core/logEntry.entry.d.ts +41 -3
- package/dist/logging/core/logEntry.entry.js +114 -4
- package/dist/logging/core/logLevel.level.d.ts +18 -0
- package/dist/logging/core/logLevel.level.js +25 -1
- package/dist/logging/core/logRedaction.redaction.d.ts +38 -0
- package/dist/logging/core/logRedaction.redaction.js +19 -0
- package/dist/logging/core/logger.d.ts +14 -11
- package/dist/logging/core/logger.js +31 -6
- package/dist/logging/core/loggerContext.context.d.ts +12 -0
- package/dist/logging/core/loggerContext.context.js +19 -0
- package/dist/logging/core/loggerOptions.options.d.ts +17 -0
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.js +0 -6
- package/dist/modules/module.d.ts +7 -1
- package/dist/modules/moduleContext.context.d.ts +41 -7
- package/dist/modules/moduleContext.context.js +31 -8
- package/dist/modules/moduleDefinition.definition.d.ts +11 -7
- package/dist/modules/moduleDefinition.definition.js +41 -8
- package/dist/modules/moduleDependency/index.d.ts +2 -2
- package/dist/modules/moduleDependency/index.js +1 -1
- package/dist/modules/moduleDependency/moduleDependency.graph.d.ts +19 -2
- package/dist/modules/moduleDependency/moduleDependency.graph.js +122 -8
- package/dist/modules/moduleDependency/moduleDependency.ordering.d.ts +8 -0
- package/dist/modules/moduleDependency/moduleDependency.ordering.js +85 -57
- package/dist/modules/moduleDependency/moduleDependency.type.d.ts +28 -1
- package/dist/modules/moduleError/index.d.ts +1 -1
- package/dist/modules/moduleError/index.js +1 -1
- package/dist/modules/moduleError/moduleError.dependency.d.ts +11 -0
- package/dist/modules/moduleError/moduleError.dependency.js +15 -0
- package/dist/modules/moduleLifecycle/index.d.ts +5 -2
- package/dist/modules/moduleLifecycle/index.js +4 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.d.ts +44 -6
- package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.js +153 -9
- package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.d.ts +30 -5
- package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.js +130 -10
- package/dist/modules/moduleLifecycle/moduleLifecycle.type.d.ts +65 -28
- package/dist/modules/moduleLifecycle/moduleLifecycle.type.js +15 -4
- package/dist/modules/moduleLoader/moduleLoader.loader.d.ts +39 -5
- package/dist/modules/moduleLoader/moduleLoader.loader.js +123 -50
- package/dist/modules/moduleLoader/moduleLoader.type.d.ts +4 -2
- package/dist/modules/moduleLoader/moduleLoader.type.js +10 -3
- package/dist/modules/moduleMetadata.metadata.js +15 -5
- package/dist/modules/moduleRegistry/index.d.ts +1 -1
- package/dist/modules/moduleRegistry/moduleRegistry.registry.d.ts +2 -2
- package/dist/modules/moduleRegistry/moduleRegistry.registry.js +38 -6
- package/dist/modules/moduleRegistry/moduleRegistry.type.d.ts +18 -1
- package/dist/runtime/index.d.ts +17 -15
- package/dist/runtime/index.js +14 -10
- package/dist/runtime/runtime.d.ts +135 -33
- package/dist/runtime/runtime.js +344 -114
- package/dist/runtime/runtimeBootstrap/index.d.ts +2 -1
- package/dist/runtime/runtimeBootstrap/index.js +1 -1
- package/dist/runtime/runtimeBootstrap/pipeline/index.d.ts +2 -2
- package/dist/runtime/runtimeBootstrap/pipeline/index.js +1 -2
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.d.ts +41 -15
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.js +98 -76
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.d.ts +7 -4
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.js +87 -59
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.type.d.ts +10 -4
- package/dist/runtime/runtimeContext/index.d.ts +3 -5
- package/dist/runtime/runtimeContext/index.js +2 -4
- package/dist/runtime/runtimeContext/runtimeContext.factory.d.ts +10 -4
- package/dist/runtime/runtimeContext/runtimeContext.factory.js +30 -7
- package/dist/runtime/runtimeContext/runtimeContext.type.d.ts +36 -47
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.d.ts +5 -0
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.js +6 -4
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.d.ts +4 -0
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.js +7 -9
- package/dist/runtime/runtimeEnvironment/index.d.ts +2 -2
- package/dist/runtime/runtimeEnvironment/index.js +1 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.d.ts +20 -17
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.js +20 -13
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.type.d.ts +12 -1
- package/dist/runtime/runtimeError/index.d.ts +3 -3
- package/dist/runtime/runtimeError/index.js +1 -1
- package/dist/runtime/runtimeError/runtimeError.base.d.ts +15 -18
- package/dist/runtime/runtimeError/runtimeError.base.js +38 -36
- package/dist/runtime/runtimeError/runtimeError.lifecycle.d.ts +23 -8
- package/dist/runtime/runtimeError/runtimeError.lifecycle.js +31 -7
- package/dist/runtime/runtimeError/runtimeError.specialized.d.ts +1 -1
- package/dist/runtime/runtimeError/runtimeError.specialized.js +1 -1
- package/dist/runtime/runtimeError/runtimeError.type.d.ts +5 -9
- package/dist/runtime/runtimeLogger.d.ts +2 -2
- package/dist/runtime/runtimeLogger.js +3 -3
- package/dist/runtime/runtimeOptions/index.d.ts +1 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.defaults.d.ts +1 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.defaults.js +2 -0
- package/dist/runtime/runtimeOptions/runtimeOptions.resolver.js +5 -2
- package/dist/runtime/runtimeOptions/runtimeOptions.type.d.ts +45 -16
- package/dist/runtime/runtimeOptions/runtimeOptions.validation.js +0 -1
- package/dist/runtime/runtimeShutdown/index.d.ts +3 -2
- package/dist/runtime/runtimeShutdown/index.js +2 -2
- package/dist/runtime/runtimeShutdown/pipeline/index.d.ts +2 -1
- package/dist/runtime/runtimeShutdown/pipeline/index.js +1 -1
- package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.d.ts +37 -7
- package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.js +77 -51
- package/dist/runtime/runtimeShutdown/runtimeShutdown.core.d.ts +8 -16
- package/dist/runtime/runtimeShutdown/runtimeShutdown.core.js +85 -87
- package/dist/runtime/runtimeShutdown/runtimeShutdown.type.d.ts +9 -5
- package/dist/runtime/runtimeSignals/index.d.ts +8 -0
- package/dist/runtime/runtimeSignals/index.js +7 -0
- package/dist/runtime/runtimeSignals/runtimeSignals.d.ts +93 -0
- package/dist/runtime/runtimeSignals/runtimeSignals.js +149 -0
- package/dist/runtime/runtimeState.state.d.ts +32 -14
- package/dist/runtime/runtimeState.state.js +34 -27
- package/dist/runtime/runtimeTimeout.d.ts +40 -0
- package/dist/runtime/runtimeTimeout.js +42 -0
- package/package.json +21 -15
- package/dist/.tsbuildinfo +0 -1
- package/dist/application/application.d.ts.map +0 -1
- package/dist/application/application.js.map +0 -1
- package/dist/application/applicationContext.context.d.ts.map +0 -1
- package/dist/application/applicationContext.context.js.map +0 -1
- package/dist/application/applicationState.state.d.ts.map +0 -1
- package/dist/application/applicationState.state.js.map +0 -1
- package/dist/application/index.d.ts.map +0 -1
- package/dist/application/index.js.map +0 -1
- package/dist/configuration/configurationManager.manager.d.ts.map +0 -1
- package/dist/configuration/configurationManager.manager.js.map +0 -1
- package/dist/configuration/core/configuration.d.ts.map +0 -1
- package/dist/configuration/core/configuration.js.map +0 -1
- package/dist/configuration/core/configurationKey.key.d.ts.map +0 -1
- package/dist/configuration/core/configurationKey.key.js.map +0 -1
- package/dist/configuration/core/configurationSource.source.d.ts.map +0 -1
- package/dist/configuration/core/configurationSource.source.js.map +0 -1
- package/dist/configuration/core/index.d.ts.map +0 -1
- package/dist/configuration/core/index.js.map +0 -1
- package/dist/configuration/error/configurationError.error.d.ts.map +0 -1
- package/dist/configuration/error/configurationError.error.js.map +0 -1
- package/dist/configuration/error/configurationRedactor.redactor.d.ts.map +0 -1
- package/dist/configuration/error/configurationRedactor.redactor.js.map +0 -1
- package/dist/configuration/error/index.d.ts.map +0 -1
- package/dist/configuration/error/index.js.map +0 -1
- package/dist/configuration/events/configurationEvents.events.d.ts.map +0 -1
- package/dist/configuration/events/configurationEvents.events.js.map +0 -1
- package/dist/configuration/events/index.d.ts.map +0 -1
- package/dist/configuration/events/index.js.map +0 -1
- package/dist/configuration/index.d.ts.map +0 -1
- package/dist/configuration/index.js.map +0 -1
- package/dist/configuration/loader/configurationLoader.loader.d.ts.map +0 -1
- package/dist/configuration/loader/configurationLoader.loader.js.map +0 -1
- package/dist/configuration/loader/index.d.ts.map +0 -1
- package/dist/configuration/loader/index.js.map +0 -1
- package/dist/configuration/registry/configurationProvider.provider.d.ts.map +0 -1
- package/dist/configuration/registry/configurationProvider.provider.js.map +0 -1
- package/dist/configuration/registry/configurationRegistry.registry.d.ts.map +0 -1
- package/dist/configuration/registry/configurationRegistry.registry.js.map +0 -1
- package/dist/configuration/registry/index.d.ts.map +0 -1
- package/dist/configuration/registry/index.js.map +0 -1
- package/dist/configuration/schema/configurationSchema.schema.d.ts.map +0 -1
- package/dist/configuration/schema/configurationSchema.schema.js.map +0 -1
- package/dist/configuration/schema/configurationValidation.validator.d.ts.map +0 -1
- package/dist/configuration/schema/configurationValidation.validator.js.map +0 -1
- package/dist/configuration/schema/index.d.ts.map +0 -1
- package/dist/configuration/schema/index.js.map +0 -1
- package/dist/container/container.d.ts.map +0 -1
- package/dist/container/container.js.map +0 -1
- package/dist/container/index.d.ts.map +0 -1
- package/dist/container/index.js.map +0 -1
- package/dist/container/provider.d.ts.map +0 -1
- package/dist/container/provider.js.map +0 -1
- package/dist/container/scope.d.ts.map +0 -1
- package/dist/container/scope.js.map +0 -1
- package/dist/container/token.d.ts.map +0 -1
- package/dist/container/token.js.map +0 -1
- package/dist/context/core/context.d.ts +0 -95
- package/dist/context/core/context.d.ts.map +0 -1
- package/dist/context/core/context.js +0 -103
- package/dist/context/core/context.js.map +0 -1
- package/dist/context/core/contextKey.key.d.ts.map +0 -1
- package/dist/context/core/contextKey.key.js.map +0 -1
- package/dist/context/core/executionContext.context.d.ts.map +0 -1
- package/dist/context/core/executionContext.context.js.map +0 -1
- package/dist/context/core/index.d.ts.map +0 -1
- package/dist/context/core/index.js.map +0 -1
- package/dist/context/index.d.ts.map +0 -1
- package/dist/context/index.js.map +0 -1
- package/dist/context/provider/contextProvider.provider.d.ts.map +0 -1
- package/dist/context/provider/contextProvider.provider.js.map +0 -1
- package/dist/context/provider/contextStorage.storage.d.ts.map +0 -1
- package/dist/context/provider/contextStorage.storage.js.map +0 -1
- package/dist/context/provider/index.d.ts.map +0 -1
- package/dist/context/provider/index.js.map +0 -1
- package/dist/context/snapshot/contextSnapshot.snapshot.d.ts.map +0 -1
- package/dist/context/snapshot/contextSnapshot.snapshot.js.map +0 -1
- package/dist/context/snapshot/index.d.ts.map +0 -1
- package/dist/context/snapshot/index.js.map +0 -1
- package/dist/context/values/contextValues.values.d.ts.map +0 -1
- package/dist/context/values/contextValues.values.js.map +0 -1
- package/dist/context/values/index.d.ts.map +0 -1
- package/dist/context/values/index.js.map +0 -1
- package/dist/contracts/adapter.d.ts.map +0 -1
- package/dist/contracts/adapter.js.map +0 -1
- package/dist/contracts/disposable.d.ts.map +0 -1
- package/dist/contracts/disposable.js.map +0 -1
- package/dist/contracts/handler.d.ts.map +0 -1
- package/dist/contracts/handler.js.map +0 -1
- package/dist/contracts/index.d.ts.map +0 -1
- package/dist/contracts/index.js.map +0 -1
- package/dist/errors/errorCode.code.d.ts.map +0 -1
- package/dist/errors/errorCode.code.js.map +0 -1
- package/dist/errors/exceptions.d.ts.map +0 -1
- package/dist/errors/exceptions.js.map +0 -1
- package/dist/errors/frameworkError.error.d.ts.map +0 -1
- package/dist/errors/frameworkError.error.js.map +0 -1
- package/dist/errors/index.d.ts.map +0 -1
- package/dist/errors/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lifecycle/core/index.d.ts.map +0 -1
- package/dist/lifecycle/core/index.js.map +0 -1
- package/dist/lifecycle/core/lifecycle.d.ts.map +0 -1
- package/dist/lifecycle/core/lifecycle.js.map +0 -1
- package/dist/lifecycle/core/lifecycleHook.hook.d.ts.map +0 -1
- package/dist/lifecycle/core/lifecycleHook.hook.js.map +0 -1
- package/dist/lifecycle/core/lifecycleRegistry.registry.d.ts.map +0 -1
- package/dist/lifecycle/core/lifecycleRegistry.registry.js.map +0 -1
- package/dist/lifecycle/core/lifecycleState.state.d.ts +0 -2
- package/dist/lifecycle/core/lifecycleState.state.d.ts.map +0 -1
- package/dist/lifecycle/core/lifecycleState.state.js +0 -2
- package/dist/lifecycle/core/lifecycleState.state.js.map +0 -1
- package/dist/lifecycle/index.d.ts.map +0 -1
- package/dist/lifecycle/index.js.map +0 -1
- package/dist/lifecycle/manager/index.d.ts.map +0 -1
- package/dist/lifecycle/manager/index.js.map +0 -1
- package/dist/lifecycle/manager/lifecycleManager.manager.d.ts.map +0 -1
- package/dist/lifecycle/manager/lifecycleManager.manager.js.map +0 -1
- package/dist/lifecycle/scope/index.d.ts.map +0 -1
- package/dist/lifecycle/scope/index.js.map +0 -1
- package/dist/lifecycle/scope/lifecycleScope.scope.d.ts.map +0 -1
- package/dist/lifecycle/scope/lifecycleScope.scope.js.map +0 -1
- package/dist/logging/console/consoleLogger.logger.d.ts.map +0 -1
- package/dist/logging/console/consoleLogger.logger.js.map +0 -1
- package/dist/logging/console/index.d.ts.map +0 -1
- package/dist/logging/console/index.js.map +0 -1
- package/dist/logging/console/loggerFactory.factory.d.ts.map +0 -1
- package/dist/logging/console/loggerFactory.factory.js.map +0 -1
- package/dist/logging/core/index.d.ts.map +0 -1
- package/dist/logging/core/index.js.map +0 -1
- package/dist/logging/core/logEntry.entry.d.ts.map +0 -1
- package/dist/logging/core/logEntry.entry.js.map +0 -1
- package/dist/logging/core/logLevel.level.d.ts.map +0 -1
- package/dist/logging/core/logLevel.level.js.map +0 -1
- package/dist/logging/core/logger.d.ts.map +0 -1
- package/dist/logging/core/logger.js.map +0 -1
- package/dist/logging/core/loggerContext.context.d.ts.map +0 -1
- package/dist/logging/core/loggerContext.context.js.map +0 -1
- package/dist/logging/core/loggerOptions.options.d.ts.map +0 -1
- package/dist/logging/core/loggerOptions.options.js.map +0 -1
- package/dist/logging/index.d.ts.map +0 -1
- package/dist/logging/index.js.map +0 -1
- package/dist/modules/index.d.ts.map +0 -1
- package/dist/modules/index.js.map +0 -1
- package/dist/modules/module.d.ts.map +0 -1
- package/dist/modules/module.js.map +0 -1
- package/dist/modules/moduleContext.context.d.ts.map +0 -1
- package/dist/modules/moduleContext.context.js.map +0 -1
- package/dist/modules/moduleDefinition.definition.d.ts.map +0 -1
- package/dist/modules/moduleDefinition.definition.js.map +0 -1
- package/dist/modules/moduleDependency/index.d.ts.map +0 -1
- package/dist/modules/moduleDependency/index.js.map +0 -1
- package/dist/modules/moduleDependency/moduleDependency.graph.d.ts.map +0 -1
- package/dist/modules/moduleDependency/moduleDependency.graph.js.map +0 -1
- package/dist/modules/moduleDependency/moduleDependency.ordering.d.ts.map +0 -1
- package/dist/modules/moduleDependency/moduleDependency.ordering.js.map +0 -1
- package/dist/modules/moduleDependency/moduleDependency.type.d.ts.map +0 -1
- package/dist/modules/moduleDependency/moduleDependency.type.js.map +0 -1
- package/dist/modules/moduleError/index.d.ts.map +0 -1
- package/dist/modules/moduleError/index.js.map +0 -1
- package/dist/modules/moduleError/moduleError.base.d.ts.map +0 -1
- package/dist/modules/moduleError/moduleError.base.js.map +0 -1
- package/dist/modules/moduleError/moduleError.dependency.d.ts.map +0 -1
- package/dist/modules/moduleError/moduleError.dependency.js.map +0 -1
- package/dist/modules/moduleError/moduleError.helpers.d.ts.map +0 -1
- package/dist/modules/moduleError/moduleError.helpers.js.map +0 -1
- package/dist/modules/moduleError/moduleError.lifecycle.d.ts.map +0 -1
- package/dist/modules/moduleError/moduleError.lifecycle.js.map +0 -1
- package/dist/modules/moduleError/moduleError.registration.d.ts.map +0 -1
- package/dist/modules/moduleError/moduleError.registration.js.map +0 -1
- package/dist/modules/moduleLifecycle/index.d.ts.map +0 -1
- package/dist/modules/moduleLifecycle/index.js.map +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.d.ts.map +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.lifecycle.js.map +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.d.ts.map +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.stateMachine.js.map +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.type.d.ts.map +0 -1
- package/dist/modules/moduleLifecycle/moduleLifecycle.type.js.map +0 -1
- package/dist/modules/moduleLoader/index.d.ts.map +0 -1
- package/dist/modules/moduleLoader/index.js.map +0 -1
- package/dist/modules/moduleLoader/moduleLoader.loader.d.ts.map +0 -1
- package/dist/modules/moduleLoader/moduleLoader.loader.js.map +0 -1
- package/dist/modules/moduleLoader/moduleLoader.type.d.ts.map +0 -1
- package/dist/modules/moduleLoader/moduleLoader.type.js.map +0 -1
- package/dist/modules/moduleMetadata.metadata.d.ts.map +0 -1
- package/dist/modules/moduleMetadata.metadata.js.map +0 -1
- package/dist/modules/moduleRegistry/index.d.ts.map +0 -1
- package/dist/modules/moduleRegistry/index.js.map +0 -1
- package/dist/modules/moduleRegistry/moduleRegistry.registry.d.ts.map +0 -1
- package/dist/modules/moduleRegistry/moduleRegistry.registry.js.map +0 -1
- package/dist/modules/moduleRegistry/moduleRegistry.type.d.ts.map +0 -1
- package/dist/modules/moduleRegistry/moduleRegistry.type.js.map +0 -1
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/index.js.map +0 -1
- package/dist/runtime/runtime.d.ts.map +0 -1
- package/dist/runtime/runtime.js.map +0 -1
- package/dist/runtime/runtimeBootstrap/index.d.ts.map +0 -1
- package/dist/runtime/runtimeBootstrap/index.js.map +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/index.d.ts.map +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/index.js.map +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.invoke.d.ts +0 -6
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.invoke.d.ts.map +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.invoke.js +0 -27
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.invoke.js.map +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.d.ts.map +0 -1
- package/dist/runtime/runtimeBootstrap/pipeline/runtimeBootstrap.pipeline.js.map +0 -1
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.d.ts.map +0 -1
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.core.js.map +0 -1
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.type.d.ts.map +0 -1
- package/dist/runtime/runtimeBootstrap/runtimeBootstrap.type.js.map +0 -1
- package/dist/runtime/runtimeContext/index.d.ts.map +0 -1
- package/dist/runtime/runtimeContext/index.js.map +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.core.d.ts +0 -38
- package/dist/runtime/runtimeContext/runtimeContext.core.d.ts.map +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.core.js +0 -99
- package/dist/runtime/runtimeContext/runtimeContext.core.js.map +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.factory.d.ts.map +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.factory.js.map +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.type.d.ts.map +0 -1
- package/dist/runtime/runtimeContext/runtimeContext.type.js.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/index.d.ts.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/index.js.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.detection.d.ts.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.detection.js.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.d.ts.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.env.js.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.d.ts.map +0 -1
- package/dist/runtime/runtimeEnvironment/detection/runtimeEnvironment.os.js.map +0 -1
- package/dist/runtime/runtimeEnvironment/index.d.ts.map +0 -1
- package/dist/runtime/runtimeEnvironment/index.js.map +0 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.d.ts.map +0 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.core.js.map +0 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.type.d.ts.map +0 -1
- package/dist/runtime/runtimeEnvironment/runtimeEnvironment.type.js.map +0 -1
- package/dist/runtime/runtimeError/index.d.ts.map +0 -1
- package/dist/runtime/runtimeError/index.js.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.base.d.ts.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.base.js.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.lifecycle.d.ts.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.lifecycle.js.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.specialized.d.ts.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.specialized.js.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.type.d.ts.map +0 -1
- package/dist/runtime/runtimeError/runtimeError.type.js.map +0 -1
- package/dist/runtime/runtimeLogger.d.ts.map +0 -1
- package/dist/runtime/runtimeLogger.js.map +0 -1
- package/dist/runtime/runtimeManager/index.d.ts +0 -12
- package/dist/runtime/runtimeManager/index.d.ts.map +0 -1
- package/dist/runtime/runtimeManager/index.js +0 -11
- package/dist/runtime/runtimeManager/index.js.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.core.d.ts +0 -31
- package/dist/runtime/runtimeManager/runtimeManager.core.d.ts.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.core.js +0 -136
- package/dist/runtime/runtimeManager/runtimeManager.core.js.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.error.d.ts +0 -14
- package/dist/runtime/runtimeManager/runtimeManager.error.d.ts.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.error.js +0 -21
- package/dist/runtime/runtimeManager/runtimeManager.error.js.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.factory.d.ts +0 -7
- package/dist/runtime/runtimeManager/runtimeManager.factory.d.ts.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.factory.js +0 -8
- package/dist/runtime/runtimeManager/runtimeManager.factory.js.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.lifecycle.d.ts +0 -16
- package/dist/runtime/runtimeManager/runtimeManager.lifecycle.d.ts.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.lifecycle.js +0 -49
- package/dist/runtime/runtimeManager/runtimeManager.lifecycle.js.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.type.d.ts +0 -54
- package/dist/runtime/runtimeManager/runtimeManager.type.d.ts.map +0 -1
- package/dist/runtime/runtimeManager/runtimeManager.type.js +0 -2
- package/dist/runtime/runtimeManager/runtimeManager.type.js.map +0 -1
- package/dist/runtime/runtimeOptions/index.d.ts.map +0 -1
- package/dist/runtime/runtimeOptions/index.js.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.defaults.d.ts.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.defaults.js.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.resolver.d.ts.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.resolver.js.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.type.d.ts.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.type.js.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.validation.d.ts.map +0 -1
- package/dist/runtime/runtimeOptions/runtimeOptions.validation.js.map +0 -1
- package/dist/runtime/runtimeShutdown/index.d.ts.map +0 -1
- package/dist/runtime/runtimeShutdown/index.js.map +0 -1
- package/dist/runtime/runtimeShutdown/pipeline/index.d.ts.map +0 -1
- package/dist/runtime/runtimeShutdown/pipeline/index.js.map +0 -1
- package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.d.ts.map +0 -1
- package/dist/runtime/runtimeShutdown/pipeline/runtimeShutdown.pipeline.js.map +0 -1
- package/dist/runtime/runtimeShutdown/runtimeShutdown.core.d.ts.map +0 -1
- package/dist/runtime/runtimeShutdown/runtimeShutdown.core.js.map +0 -1
- package/dist/runtime/runtimeShutdown/runtimeShutdown.type.d.ts.map +0 -1
- package/dist/runtime/runtimeShutdown/runtimeShutdown.type.js.map +0 -1
- package/dist/runtime/runtimeState.state.d.ts.map +0 -1
- package/dist/runtime/runtimeState.state.js.map +0 -1
|
@@ -1,53 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { executeShutdownPipeline } from "./pipeline/index.js";
|
|
1
|
+
import { executeShutdownPipeline, createShutdownPipelineState, createShutdownResult, } from "./pipeline/index.js";
|
|
3
2
|
import { logRuntimeEvent } from "../runtimeLogger.js";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
cause,
|
|
13
|
-
});
|
|
14
|
-
this.shutdownCode = code;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export async function withShutdownTimeout(operation, timeoutMs) {
|
|
18
|
-
if (timeoutMs <= 0) {
|
|
19
|
-
await operation;
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
let timer;
|
|
23
|
-
const timeout = new Promise((_resolve, reject) => {
|
|
24
|
-
timer = setTimeout(() => {
|
|
25
|
-
reject(new RuntimeShutdownError(`Runtime shutdown exceeded the configured timeout of ${timeoutMs}ms.`, "SHUTDOWN_TIMEOUT"));
|
|
26
|
-
}, timeoutMs);
|
|
27
|
-
});
|
|
28
|
-
try {
|
|
29
|
-
await Promise.race([operation, timeout]);
|
|
30
|
-
}
|
|
31
|
-
finally {
|
|
32
|
-
clearTimeout(timer);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export function createShutdownResult(success, phase, stoppedModules, destroyedModules, errors, startedAt, completedAt) {
|
|
36
|
-
return Object.freeze({
|
|
37
|
-
success,
|
|
38
|
-
phase,
|
|
39
|
-
stoppedModules,
|
|
40
|
-
destroyedModules,
|
|
41
|
-
errors: Object.freeze([...errors]),
|
|
42
|
-
startedAt,
|
|
43
|
-
completedAt,
|
|
44
|
-
durationMs: completedAt.getTime() - startedAt.getTime(),
|
|
45
|
-
});
|
|
46
|
-
}
|
|
3
|
+
import { withRuntimeTimeout } from "../runtimeTimeout.js";
|
|
4
|
+
import { RuntimeError } from "../runtimeError/runtimeError.base.js";
|
|
5
|
+
import { InvalidRuntimeStateError, RuntimeStopError, } from "../runtimeError/runtimeError.lifecycle.js";
|
|
6
|
+
import { RuntimeErrorCode } from "../runtimeError/runtimeError.type.js";
|
|
7
|
+
/**
|
|
8
|
+
* Default shutdown service: stops and destroys modules according to
|
|
9
|
+
* the runtime's shutdown options.
|
|
10
|
+
*/
|
|
47
11
|
export class DefaultRuntimeShutdown {
|
|
48
|
-
|
|
12
|
+
_identity;
|
|
49
13
|
_environment;
|
|
50
|
-
_application;
|
|
51
14
|
_moduleRegistry;
|
|
52
15
|
_moduleLifecycle;
|
|
53
16
|
_logger;
|
|
@@ -55,11 +18,9 @@ export class DefaultRuntimeShutdown {
|
|
|
55
18
|
_running = false;
|
|
56
19
|
_phase = "created";
|
|
57
20
|
_lastResult;
|
|
58
|
-
_shutdownContext;
|
|
59
21
|
constructor(dependencies, runtimeOptions) {
|
|
60
|
-
this.
|
|
22
|
+
this._identity = dependencies.identity;
|
|
61
23
|
this._environment = dependencies.environment;
|
|
62
|
-
this._application = dependencies.application;
|
|
63
24
|
this._moduleRegistry = dependencies.moduleRegistry;
|
|
64
25
|
this._moduleLifecycle = dependencies.moduleLifecycle;
|
|
65
26
|
this._logger = dependencies.logger;
|
|
@@ -73,75 +34,112 @@ export class DefaultRuntimeShutdown {
|
|
|
73
34
|
}
|
|
74
35
|
async shutdown(options = {}) {
|
|
75
36
|
if (this._running) {
|
|
76
|
-
throw new
|
|
37
|
+
throw new InvalidRuntimeStateError("Runtime shutdown is already running.", this.errorContext({ state: this._phase }));
|
|
77
38
|
}
|
|
78
39
|
if (this._phase === "completed") {
|
|
79
|
-
throw new
|
|
40
|
+
throw new InvalidRuntimeStateError("Runtime has already been shut down.", this.errorContext({ state: this._phase }));
|
|
80
41
|
}
|
|
81
42
|
this._running = true;
|
|
82
43
|
this._phase = "created";
|
|
44
|
+
const startedAt = new Date();
|
|
83
45
|
const configuration = this.resolveOptions(options);
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
application: this._application,
|
|
87
|
-
type: "worker",
|
|
88
|
-
id: `${this._context.identity.id}-shutdown`,
|
|
89
|
-
});
|
|
46
|
+
const state = createShutdownPipelineState();
|
|
47
|
+
const diagnostics = this._runtimeOptions.diagnostics;
|
|
90
48
|
try {
|
|
91
|
-
|
|
92
|
-
|
|
49
|
+
if (diagnostics.shutdownLogging) {
|
|
50
|
+
this.log("info", "Runtime shutdown started.", {
|
|
51
|
+
...(diagnostics.includeState && { phase: this._phase }),
|
|
52
|
+
...(diagnostics.includeModules && {
|
|
53
|
+
modules: this._moduleRegistry
|
|
54
|
+
.getLoadedModules()
|
|
55
|
+
.map((module) => module.id),
|
|
56
|
+
}),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
await withRuntimeTimeout((signal) => executeShutdownPipeline(configuration, {
|
|
60
|
+
moduleLifecycle: this._moduleLifecycle,
|
|
61
|
+
runtimeId: this._identity.id,
|
|
62
|
+
runtimeName: this._identity.name,
|
|
63
|
+
}, state, signal, (phase) => {
|
|
93
64
|
this._phase = phase;
|
|
94
|
-
}, this.log.bind(this))
|
|
95
|
-
|
|
65
|
+
}, this.log.bind(this)), configuration.timeoutMs, {
|
|
66
|
+
message: `Runtime shutdown exceeded the configured timeout of ${configuration.timeoutMs}ms.`,
|
|
67
|
+
error: this.errorContext({
|
|
68
|
+
code: RuntimeErrorCode.SHUTDOWN_TIMEOUT,
|
|
69
|
+
operation: "stop",
|
|
70
|
+
phase: "stopping",
|
|
71
|
+
}),
|
|
72
|
+
onLateRejection: (error) => {
|
|
73
|
+
this.log("warn", "Abandoned runtime shutdown failed late.", {
|
|
74
|
+
error,
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
});
|
|
96
78
|
this._phase = "completed";
|
|
97
|
-
const
|
|
98
|
-
const result = createShutdownResult(true, "completed", 0, 0, [], new Date(), completedAt);
|
|
79
|
+
const result = createShutdownResult(state.errors.length === 0, "completed", state.counters, state.errors, startedAt, new Date());
|
|
99
80
|
this._lastResult = result;
|
|
100
|
-
|
|
81
|
+
if (diagnostics.shutdownLogging) {
|
|
82
|
+
this.log(result.success ? "info" : "warn", result.success
|
|
83
|
+
? "Runtime shutdown completed."
|
|
84
|
+
: "Runtime shutdown completed with errors.", {
|
|
85
|
+
durationMs: result.durationMs,
|
|
86
|
+
stoppedModules: result.stoppedModules,
|
|
87
|
+
destroyedModules: result.destroyedModules,
|
|
88
|
+
errors: result.errors.length,
|
|
89
|
+
...(diagnostics.includeState && { phase: result.phase }),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
101
92
|
return result;
|
|
102
93
|
}
|
|
103
94
|
catch (error) {
|
|
95
|
+
const failedPhase = this._phase;
|
|
104
96
|
this._phase = "failed";
|
|
105
|
-
const shutdownError = error instanceof
|
|
97
|
+
const shutdownError = error instanceof RuntimeError
|
|
106
98
|
? error
|
|
107
|
-
: new
|
|
108
|
-
|
|
109
|
-
const result = createShutdownResult(false, "failed",
|
|
99
|
+
: new RuntimeStopError("Runtime shutdown failed.", this.errorContext({ phase: "stopping", cause: error }));
|
|
100
|
+
state.errors.push({ phase: failedPhase, error: shutdownError });
|
|
101
|
+
const result = createShutdownResult(false, "failed", state.counters, state.errors, startedAt, new Date());
|
|
110
102
|
this._lastResult = result;
|
|
111
|
-
|
|
103
|
+
this.log("error", "Runtime shutdown failed.", {
|
|
104
|
+
error: shutdownError,
|
|
105
|
+
failedPhase,
|
|
106
|
+
durationMs: result.durationMs,
|
|
107
|
+
});
|
|
112
108
|
throw shutdownError;
|
|
113
109
|
}
|
|
114
110
|
finally {
|
|
115
111
|
this._running = false;
|
|
116
112
|
}
|
|
117
113
|
}
|
|
118
|
-
resolveOptions(options) {
|
|
119
|
-
return {
|
|
120
|
-
stopModules: options.stopModules ?? this._runtimeOptions.shutdown.autoStopModules,
|
|
121
|
-
destroyModules: options.destroyModules ??
|
|
122
|
-
this._runtimeOptions.shutdown.autoDestroyModules,
|
|
123
|
-
continueOnStopError: options.continueOnStopError ??
|
|
124
|
-
this._runtimeOptions.shutdown.continueOnStopError,
|
|
125
|
-
continueOnDestroyError: options.continueOnDestroyError ??
|
|
126
|
-
this._runtimeOptions.shutdown.continueOnDestroyError,
|
|
127
|
-
timeoutMs: options.timeoutMs ?? this._runtimeOptions.shutdown.timeoutMs,
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
114
|
getLastResult() {
|
|
131
115
|
return this._lastResult;
|
|
132
116
|
}
|
|
133
|
-
getShutdownContext() {
|
|
134
|
-
return this._shutdownContext;
|
|
135
|
-
}
|
|
136
117
|
reset() {
|
|
137
118
|
if (this._running) {
|
|
138
|
-
throw new
|
|
119
|
+
throw new InvalidRuntimeStateError("Cannot reset runtime shutdown while it is running.", this.errorContext({ state: this._phase }));
|
|
139
120
|
}
|
|
140
121
|
this._phase = "created";
|
|
141
122
|
this._lastResult = undefined;
|
|
142
123
|
}
|
|
124
|
+
resolveOptions(options) {
|
|
125
|
+
const shutdown = this._runtimeOptions.shutdown;
|
|
126
|
+
return {
|
|
127
|
+
stopModules: options.stopModules ?? shutdown.autoStopModules,
|
|
128
|
+
destroyModules: options.destroyModules ?? shutdown.autoDestroyModules,
|
|
129
|
+
continueOnStopError: options.continueOnStopError ?? shutdown.continueOnStopError,
|
|
130
|
+
continueOnDestroyError: options.continueOnDestroyError ?? shutdown.continueOnDestroyError,
|
|
131
|
+
timeoutMs: options.timeoutMs ?? shutdown.timeoutMs,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
errorContext(extra) {
|
|
135
|
+
return {
|
|
136
|
+
...extra,
|
|
137
|
+
runtimeId: this._identity.id,
|
|
138
|
+
runtimeName: this._identity.name,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
143
141
|
log(level, message, metadata) {
|
|
144
|
-
logRuntimeEvent(this._logger, this.
|
|
142
|
+
logRuntimeEvent(this._logger, this._identity, this._environment, level, message, metadata);
|
|
145
143
|
}
|
|
146
144
|
}
|
|
147
145
|
//# sourceMappingURL=runtimeShutdown.core.js.map
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import type { Logger } from "../../logging/core/logger.js";
|
|
2
|
-
import type { ApplicationContext } from "../../application/applicationContext.context.js";
|
|
3
2
|
import type { ModuleLifecycleManager } from "../../modules/moduleLifecycle/index.js";
|
|
4
3
|
import type { ModuleRegistry } from "../../modules/moduleRegistry/index.js";
|
|
5
|
-
import type {
|
|
4
|
+
import type { RuntimeIdentity } from "../runtimeContext/index.js";
|
|
6
5
|
import type { RuntimeEnvironment } from "../runtimeEnvironment/index.js";
|
|
7
6
|
/**
|
|
8
7
|
* Dependencies required by RuntimeShutdown.
|
|
9
8
|
*/
|
|
10
9
|
export interface RuntimeShutdownDependencies {
|
|
11
|
-
|
|
10
|
+
/** Identity attached to errors and log entries. */
|
|
11
|
+
readonly identity: RuntimeIdentity;
|
|
12
12
|
readonly environment: RuntimeEnvironment;
|
|
13
|
-
readonly application: ApplicationContext;
|
|
14
13
|
readonly moduleRegistry: ModuleRegistry;
|
|
15
14
|
readonly moduleLifecycle: ModuleLifecycleManager;
|
|
16
15
|
readonly logger: Logger;
|
|
@@ -31,6 +30,8 @@ export interface RuntimeShutdownConfig {
|
|
|
31
30
|
export type RuntimeShutdownPhase = "created" | "stopping" | "stopped" | "destroying" | "destroyed" | "completed" | "failed";
|
|
32
31
|
/**
|
|
33
32
|
* Error captured during shutdown.
|
|
33
|
+
*
|
|
34
|
+
* Module-level failures carry the failing module id in `moduleName`.
|
|
34
35
|
*/
|
|
35
36
|
export interface RuntimeShutdownErrorInfo {
|
|
36
37
|
readonly phase: RuntimeShutdownPhase;
|
|
@@ -39,6 +40,10 @@ export interface RuntimeShutdownErrorInfo {
|
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
41
42
|
* Result of a shutdown operation.
|
|
43
|
+
*
|
|
44
|
+
* `success` is true only when no error was recorded. A shutdown that
|
|
45
|
+
* continued past module failures (continueOn*Error) resolves with
|
|
46
|
+
* `success: false` and the failures listed in `errors`.
|
|
42
47
|
*/
|
|
43
48
|
export interface RuntimeShutdownResult {
|
|
44
49
|
readonly success: boolean;
|
|
@@ -58,7 +63,6 @@ export interface RuntimeShutdown {
|
|
|
58
63
|
readonly phase: RuntimeShutdownPhase;
|
|
59
64
|
shutdown(options?: RuntimeShutdownConfig): Promise<RuntimeShutdownResult>;
|
|
60
65
|
getLastResult(): RuntimeShutdownResult | undefined;
|
|
61
|
-
getShutdownContext(): import("../../context/core/context.js").Context | undefined;
|
|
62
66
|
reset(): void;
|
|
63
67
|
}
|
|
64
68
|
/**
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime Signals
|
|
3
|
+
*
|
|
4
|
+
* Process signal and exception handling for graceful shutdown.
|
|
5
|
+
*/
|
|
6
|
+
export { RuntimeSignalManager } from "./runtimeSignals.js";
|
|
7
|
+
export type { RuntimeTerminationSignal, RuntimeProcessEvent, RuntimeSignalTarget, RuntimeSignalHandlers, RuntimeSignalManagerOptions, } from "./runtimeSignals.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { Logger } from "../../logging/core/logger.js";
|
|
2
|
+
import type { RuntimeSignalOptions } from "../runtimeOptions/runtimeOptions.type.js";
|
|
3
|
+
/**
|
|
4
|
+
* Termination signals the runtime can react to.
|
|
5
|
+
*/
|
|
6
|
+
export type RuntimeTerminationSignal = "SIGINT" | "SIGTERM" | "SIGHUP";
|
|
7
|
+
/**
|
|
8
|
+
* Process events the signal manager can subscribe to.
|
|
9
|
+
*/
|
|
10
|
+
export type RuntimeProcessEvent = RuntimeTerminationSignal | "uncaughtException" | "unhandledRejection";
|
|
11
|
+
/**
|
|
12
|
+
* Minimal `process`-like target. Defaults to the global process; tests
|
|
13
|
+
* inject an EventEmitter so nothing is registered on the real process
|
|
14
|
+
* and `exit` can be observed instead of executed.
|
|
15
|
+
*/
|
|
16
|
+
export interface RuntimeSignalTarget {
|
|
17
|
+
on(event: string, listener: (...args: never[]) => void): unknown;
|
|
18
|
+
off(event: string, listener: (...args: never[]) => void): unknown;
|
|
19
|
+
exit?(code?: number): void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Hooks the runtime supplies to react to process events.
|
|
23
|
+
*/
|
|
24
|
+
export interface RuntimeSignalHandlers {
|
|
25
|
+
/**
|
|
26
|
+
* A termination signal arrived; the runtime should stop gracefully.
|
|
27
|
+
*/
|
|
28
|
+
onSignal(signal: RuntimeTerminationSignal): void | Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* An uncaught exception reached the process.
|
|
31
|
+
*/
|
|
32
|
+
onUncaughtException(error: unknown): void | Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* A promise rejection was never handled.
|
|
35
|
+
*/
|
|
36
|
+
onUnhandledRejection(reason: unknown): void | Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Options for the signal manager.
|
|
40
|
+
*/
|
|
41
|
+
export interface RuntimeSignalManagerOptions {
|
|
42
|
+
readonly signals: Required<RuntimeSignalOptions>;
|
|
43
|
+
readonly target?: RuntimeSignalTarget;
|
|
44
|
+
readonly logger?: Logger;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Registers and removes process signal/exception handlers on behalf
|
|
48
|
+
* of the runtime.
|
|
49
|
+
*
|
|
50
|
+
* Policy:
|
|
51
|
+
* - Handlers are registered by `register()` and removed by
|
|
52
|
+
* `unregister()`; both are idempotent.
|
|
53
|
+
* - The first termination signal triggers `onSignal` (graceful stop).
|
|
54
|
+
* - A second termination signal while the first is still being
|
|
55
|
+
* handled is logged and ignored, unless `forceExitOnSecondSignal`
|
|
56
|
+
* is on, in which case `target.exit(forceExitCode)` is called.
|
|
57
|
+
* - `process.exit` is never called otherwise.
|
|
58
|
+
*/
|
|
59
|
+
export declare class RuntimeSignalManager {
|
|
60
|
+
private readonly _signals;
|
|
61
|
+
private readonly _target;
|
|
62
|
+
private readonly _logger;
|
|
63
|
+
private readonly _listeners;
|
|
64
|
+
private _handlers;
|
|
65
|
+
private _receivedSignals;
|
|
66
|
+
private _stopping;
|
|
67
|
+
constructor(options: RuntimeSignalManagerOptions);
|
|
68
|
+
/**
|
|
69
|
+
* Whether handlers are currently attached to the target.
|
|
70
|
+
*/
|
|
71
|
+
get registered(): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Number of termination signals received since registration.
|
|
74
|
+
*/
|
|
75
|
+
get receivedSignals(): number;
|
|
76
|
+
/**
|
|
77
|
+
* Process events this manager subscribes to given its options.
|
|
78
|
+
*/
|
|
79
|
+
get events(): readonly RuntimeProcessEvent[];
|
|
80
|
+
/**
|
|
81
|
+
* Attaches handlers to the target. No-op when already registered or
|
|
82
|
+
* when no target is available (non-Node engines).
|
|
83
|
+
*/
|
|
84
|
+
register(handlers: RuntimeSignalHandlers): void;
|
|
85
|
+
/**
|
|
86
|
+
* Detaches all handlers from the target.
|
|
87
|
+
*/
|
|
88
|
+
unregister(): void;
|
|
89
|
+
private createListener;
|
|
90
|
+
private handleSignal;
|
|
91
|
+
private run;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=runtimeSignals.d.ts.map
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers and removes process signal/exception handlers on behalf
|
|
3
|
+
* of the runtime.
|
|
4
|
+
*
|
|
5
|
+
* Policy:
|
|
6
|
+
* - Handlers are registered by `register()` and removed by
|
|
7
|
+
* `unregister()`; both are idempotent.
|
|
8
|
+
* - The first termination signal triggers `onSignal` (graceful stop).
|
|
9
|
+
* - A second termination signal while the first is still being
|
|
10
|
+
* handled is logged and ignored, unless `forceExitOnSecondSignal`
|
|
11
|
+
* is on, in which case `target.exit(forceExitCode)` is called.
|
|
12
|
+
* - `process.exit` is never called otherwise.
|
|
13
|
+
*/
|
|
14
|
+
export class RuntimeSignalManager {
|
|
15
|
+
_signals;
|
|
16
|
+
_target;
|
|
17
|
+
_logger;
|
|
18
|
+
_listeners = new Map();
|
|
19
|
+
_handlers;
|
|
20
|
+
_receivedSignals = 0;
|
|
21
|
+
_stopping = false;
|
|
22
|
+
constructor(options) {
|
|
23
|
+
this._signals = options.signals;
|
|
24
|
+
this._target = options.target ?? getGlobalProcess();
|
|
25
|
+
this._logger = options.logger;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Whether handlers are currently attached to the target.
|
|
29
|
+
*/
|
|
30
|
+
get registered() {
|
|
31
|
+
return this._listeners.size > 0;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Number of termination signals received since registration.
|
|
35
|
+
*/
|
|
36
|
+
get receivedSignals() {
|
|
37
|
+
return this._receivedSignals;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Process events this manager subscribes to given its options.
|
|
41
|
+
*/
|
|
42
|
+
get events() {
|
|
43
|
+
const events = [];
|
|
44
|
+
if (this._signals.handleSigint)
|
|
45
|
+
events.push("SIGINT");
|
|
46
|
+
if (this._signals.handleSigterm)
|
|
47
|
+
events.push("SIGTERM");
|
|
48
|
+
if (this._signals.handleSighup)
|
|
49
|
+
events.push("SIGHUP");
|
|
50
|
+
if (this._signals.handleUncaughtException)
|
|
51
|
+
events.push("uncaughtException");
|
|
52
|
+
if (this._signals.handleUnhandledRejection)
|
|
53
|
+
events.push("unhandledRejection");
|
|
54
|
+
return events;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Attaches handlers to the target. No-op when already registered or
|
|
58
|
+
* when no target is available (non-Node engines).
|
|
59
|
+
*/
|
|
60
|
+
register(handlers) {
|
|
61
|
+
if (this.registered || !this._target)
|
|
62
|
+
return;
|
|
63
|
+
this._handlers = handlers;
|
|
64
|
+
this._receivedSignals = 0;
|
|
65
|
+
this._stopping = false;
|
|
66
|
+
for (const event of this.events) {
|
|
67
|
+
const listener = this.createListener(event);
|
|
68
|
+
this._listeners.set(event, listener);
|
|
69
|
+
this._target.on(event, listener);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Detaches all handlers from the target.
|
|
74
|
+
*/
|
|
75
|
+
unregister() {
|
|
76
|
+
if (!this._target)
|
|
77
|
+
return;
|
|
78
|
+
for (const [event, listener] of this._listeners) {
|
|
79
|
+
this._target.off(event, listener);
|
|
80
|
+
}
|
|
81
|
+
this._listeners.clear();
|
|
82
|
+
this._handlers = undefined;
|
|
83
|
+
}
|
|
84
|
+
createListener(event) {
|
|
85
|
+
switch (event) {
|
|
86
|
+
case "SIGINT":
|
|
87
|
+
case "SIGTERM":
|
|
88
|
+
case "SIGHUP":
|
|
89
|
+
return () => {
|
|
90
|
+
this.handleSignal(event);
|
|
91
|
+
};
|
|
92
|
+
case "uncaughtException":
|
|
93
|
+
return ((error) => {
|
|
94
|
+
this.run(() => this._handlers?.onUncaughtException(error), "uncaughtException");
|
|
95
|
+
});
|
|
96
|
+
case "unhandledRejection":
|
|
97
|
+
return ((reason) => {
|
|
98
|
+
this.run(() => this._handlers?.onUnhandledRejection(reason), "unhandledRejection");
|
|
99
|
+
});
|
|
100
|
+
default:
|
|
101
|
+
return () => { };
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
handleSignal(signal) {
|
|
105
|
+
this._receivedSignals += 1;
|
|
106
|
+
if (this._stopping) {
|
|
107
|
+
if (this._signals.forceExitOnSecondSignal) {
|
|
108
|
+
this._logger?.warn(`Received ${signal} during shutdown; forcing process exit.`, { signal, exitCode: this._signals.forceExitCode });
|
|
109
|
+
this._target?.exit?.(this._signals.forceExitCode);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
this._logger?.warn(`Received ${signal} while shutdown is already in progress; ignoring.`, { signal });
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
this._stopping = true;
|
|
116
|
+
this._logger?.info(`Received ${signal}; stopping runtime gracefully.`, {
|
|
117
|
+
signal,
|
|
118
|
+
});
|
|
119
|
+
this.run(() => this._handlers?.onSignal(signal), signal);
|
|
120
|
+
}
|
|
121
|
+
run(handler, event) {
|
|
122
|
+
try {
|
|
123
|
+
const result = handler();
|
|
124
|
+
if (result && typeof result.then === "function") {
|
|
125
|
+
result.catch((error) => {
|
|
126
|
+
this._logger?.error(`Runtime ${event} handler failed.`, error, {
|
|
127
|
+
event,
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
this._logger?.error(`Runtime ${event} handler failed.`, error, {
|
|
134
|
+
event,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function getGlobalProcess() {
|
|
140
|
+
const candidate = globalThis.process;
|
|
141
|
+
if (typeof candidate === "object" &&
|
|
142
|
+
candidate !== null &&
|
|
143
|
+
typeof candidate.on === "function" &&
|
|
144
|
+
typeof candidate.off === "function") {
|
|
145
|
+
return candidate;
|
|
146
|
+
}
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=runtimeSignals.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export { InvalidRuntimeStateError, InvalidRuntimeTransitionError, } from "./runtimeError/runtimeError.lifecycle.js";
|
|
2
2
|
/** Runtime lifecycle states. */
|
|
3
3
|
export declare enum RuntimeState {
|
|
4
4
|
CREATED = "created",
|
|
@@ -8,11 +8,16 @@ export declare enum RuntimeState {
|
|
|
8
8
|
STOPPED = "stopped",
|
|
9
9
|
FAILED = "failed"
|
|
10
10
|
}
|
|
11
|
-
/** Terminal runtime states. */
|
|
11
|
+
/** Terminal runtime states: no further transitions are possible. */
|
|
12
12
|
export declare const TERMINAL_RUNTIME_STATES: readonly RuntimeState[];
|
|
13
13
|
/** Runtime states from which startup is allowed. */
|
|
14
14
|
export declare const STARTABLE_RUNTIME_STATES: readonly RuntimeState[];
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Runtime states from which shutdown is allowed.
|
|
17
|
+
*
|
|
18
|
+
* CREATED is included because stopping a runtime that never started
|
|
19
|
+
* is a valid soft stop (no modules to unwind).
|
|
20
|
+
*/
|
|
16
21
|
export declare const STOPPABLE_RUNTIME_STATES: readonly RuntimeState[];
|
|
17
22
|
/** Runtime states that indicate a lifecycle operation is in progress. */
|
|
18
23
|
export declare const TRANSITIONAL_RUNTIME_STATES: readonly RuntimeState[];
|
|
@@ -24,6 +29,19 @@ export interface RuntimeStateSnapshot {
|
|
|
24
29
|
readonly transitioning: boolean;
|
|
25
30
|
readonly failed: boolean;
|
|
26
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Timestamps recorded by the runtime as it moves through its
|
|
34
|
+
* states. Owned by the Runtime object (never by the execution
|
|
35
|
+
* context, which is immutable).
|
|
36
|
+
*/
|
|
37
|
+
export interface RuntimeTiming {
|
|
38
|
+
readonly createdAt: Date;
|
|
39
|
+
readonly startupStartedAt?: Date;
|
|
40
|
+
readonly readyAt?: Date;
|
|
41
|
+
readonly shutdownStartedAt?: Date;
|
|
42
|
+
readonly stoppedAt?: Date;
|
|
43
|
+
readonly failedAt?: Date;
|
|
44
|
+
}
|
|
27
45
|
/** Describes a runtime state transition. */
|
|
28
46
|
export interface RuntimeStateTransition {
|
|
29
47
|
readonly from: RuntimeState;
|
|
@@ -31,17 +49,6 @@ export interface RuntimeStateTransition {
|
|
|
31
49
|
readonly timestamp: Date;
|
|
32
50
|
readonly reason?: string;
|
|
33
51
|
}
|
|
34
|
-
/** Error thrown when an invalid runtime state is encountered. */
|
|
35
|
-
export declare class InvalidRuntimeStateError extends RuntimeStateError {
|
|
36
|
-
readonly state: string;
|
|
37
|
-
constructor(message: string);
|
|
38
|
-
}
|
|
39
|
-
/** Error thrown when an invalid runtime state transition is attempted. */
|
|
40
|
-
export declare class InvalidRuntimeTransitionError extends RuntimeStateError {
|
|
41
|
-
readonly from: RuntimeState;
|
|
42
|
-
readonly to: RuntimeState;
|
|
43
|
-
constructor(from: RuntimeState, to: RuntimeState);
|
|
44
|
-
}
|
|
45
52
|
export declare function isRuntimeState(value: unknown): value is RuntimeState;
|
|
46
53
|
export declare function isRuntimeReady(state: RuntimeState): boolean;
|
|
47
54
|
export declare function isRuntimeFailed(state: RuntimeState): boolean;
|
|
@@ -49,6 +56,17 @@ export declare function isRuntimeTransitioning(state: RuntimeState): boolean;
|
|
|
49
56
|
export declare function isRuntimeTerminal(state: RuntimeState): boolean;
|
|
50
57
|
export declare function canStartRuntime(state: RuntimeState): boolean;
|
|
51
58
|
export declare function canStopRuntime(state: RuntimeState): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Determines whether a runtime state transition is valid.
|
|
61
|
+
*
|
|
62
|
+
* Rules:
|
|
63
|
+
* - Self transitions are never valid.
|
|
64
|
+
* - FAILED is reachable from every non-terminal state
|
|
65
|
+
* (CREATED, BOOTSTRAPPING, READY, STOPPING).
|
|
66
|
+
* - CREATED → STOPPED is a valid "soft stop": a runtime that
|
|
67
|
+
* never started can be stopped as a no-op.
|
|
68
|
+
* - STOPPED and FAILED are terminal for transitions.
|
|
69
|
+
*/
|
|
52
70
|
export declare function canTransitionRuntime(from: RuntimeState, to: RuntimeState): boolean;
|
|
53
71
|
export declare function assertRuntimeState(value: unknown): asserts value is RuntimeState;
|
|
54
72
|
export declare function assertRuntimeTransition(from: RuntimeState, to: RuntimeState): void;
|