Creates a new RunResult instance.
The framework logger for runtime diagnostics
The central store containing all registered tasks, events, resources
Handles event emission and hook execution
Executes tasks with middleware and validation
Normalized run() options captured for this runtime instance. This lets tooling inspect the effective runtime configuration directly.
Callback to clean up all resources during disposal
Requests that any in-flight graceful shutdown stop waiting at the next safe Runner-owned checkpoint and jump to direct resource disposal.
Exposes whether force disposal was requested so runtime-facing business calls can stop admitting new work immediately, even while internal shutdown checkpoints are still unwinding through coolingDown.
Emits an event to trigger all registered hooks listening for it.
Events are emitted synchronously or asynchronously depending on hook configuration.
Hooks execute in order based on their order() value (lower runs first).
// Basic emission
await runtime.emitEvent(userRegistered, { userId: "123", email: "a@b.com" });
// With report for hook failure tracking
const report = await runtime.emitEvent(notify, undefined, { report: true });
if (report.failedListeners.length > 0) {
console.error("Failed hooks:", report.failedListeners);
}
ReadonlyloggerFramework logger for diagnostics and debugging. Use this for logging within tasks or hooks.
ReadonlyrunNormalized run() options captured for this runtime instance. This lets tooling inspect the effective runtime configuration directly.
ReadonlystoreCentral store containing all registered definitions. Provides access to tasks, events, resources, and their metadata.
Returns the runtime mode (e.g., "test", "dev", "prod") as specified in run options.
Current admission state for new work.
Returns the root value initialized by the root resource. Only available after the root resource has been initialized.
Disposes the runtime and all registered resources.
Disposal executes in reverse initialization order:
dispose methods are calledAfter disposal, any further operations will throw. Safe to call multiple times (subsequent calls return immediately).
Promise that resolves when disposal is complete
Evaluates async health checks for all health-enabled resources or a filtered subset.
OptionalresourceDefs: (Initializes (if not already) and returns the value of a resource on-demand.
This method is useful when:
The resource definition or resource ID string
The initialized value of the resource (unwrapped if Promise-based)
Retrieves the configuration that was passed to a resource.
This returns the config object (the input), not the initialized value.
Use getResourceValue() to get the initialized value.
The resource definition or resource ID string
The config object passed when registering the resource
Synchronously retrieves the initialized value of a resource.
The resource must have been initialized (either at startup or via lazy loading).
For resources not initialized at startup, use getLazyResourceValue() instead.
The resource definition or resource ID string
The initialized value of the resource (unwrapped if Promise-based)
Stops admitting new external work while allowing active work to continue.
Optional_reason: stringRegisters a recovery condition for the current pause episode.
Re-opens admissions immediately and clears the active recovery episode.
Executes a registered task within the runtime context.
The task runs through its full middleware pipeline including:
Configures lazy loading options for resources. Used to enable on-demand resource initialization.
Lazy mode configuration
Sets the root value after the root resource initializes.
The initialized root value
RunResult represents the runtime instance after executing
run(root). It provides access to tasks, events, resources, and lifecycle management.Key features:
runTask()emitEvent()getResourceValue()/getLazyResourceValue()rootdispose()Example