@dudousxd/nestjs-diagnostics
Version:
A standard convention for @dudousxd/nestjs-* libs to emit observability events over node:diagnostics_channel.
60 lines • 2.63 kB
TypeScript
import { type OnApplicationBootstrap, type OnApplicationShutdown } from '@nestjs/common';
import { DiscoveryService, MetadataScanner, ModuleRef } from '@nestjs/core';
import type { ListenerInvoker } from './delivery.js';
import { type DiagnosticsModuleOptions } from './diagnostics.options.js';
import { type OnDiagnosticMeta } from './on-diagnostic.decorator.js';
/** Thrown by the listener invoker for a listener id this process does not know. */
export declare class UnknownDiagnosticListenerError extends Error {
readonly listenerId: string;
readonly code = "E_UNKNOWN_DIAGNOSTICS_LISTENER";
constructor(listenerId: string);
}
/** A discovered `@OnDiagnostic` method. */
export interface RegisteredListener {
/** Stable id, `<ClassName>#<method>`. */
readonly id: string;
/** Where it listens (one entry per stacked decorator). */
readonly matchers: readonly OnDiagnosticMeta[];
readonly instance: Record<string, unknown>;
readonly method: string;
}
/**
* Discovers `@OnDiagnostic` methods, starts the `default` transport and routes every matching
* event: to the delivering transport (only in the emitting process), or straight to the handler.
*/
export declare class DiagnosticsExplorer implements OnApplicationBootstrap, OnApplicationShutdown {
private readonly discovery;
private readonly scanner;
private readonly moduleRef;
private readonly logger;
private readonly listeners;
private readonly matchCache;
private readonly subscribed;
private readonly wildcardLibs;
private readonly pending;
private scheduled;
private offChannelRegistered;
private transport;
private deliver;
private role;
private readonly options;
constructor(discovery: DiscoveryService, scanner: MetadataScanner, moduleRef: ModuleRef, options?: DiagnosticsModuleOptions);
/**
* Run listener `listenerId` for `envelope` in this process. The handler is called synchronously;
* the promise rejects with its error.
*/
readonly invoke: ListenerInvoker;
/** Every listener discovered in this process. */
registeredListeners(): RegisteredListener[];
onApplicationBootstrap(): Promise<void>;
onApplicationShutdown(): Promise<void>;
private discover;
/** The listeners that receive an event on `aviary:<lib>:<event>`. */
private listenersFor;
private subscribeListeners;
private subscribe;
private readonly onEvent;
/** Hand this turn's deliveries to the transport, in emit order. Settles once they are handed over. */
private flush;
}
//# sourceMappingURL=diagnostics.explorer.d.ts.map