/** * @module * This module provides functions and type definitions to work with the AsyncLocalStorage tracing context. * It's primarily intended for internal use, but the API is public, and may be useful when creating custom * subscribers. */ import { AsyncLocalStorage } from "node:async_hooks"; import type { ISubscriber } from "./subscriber.js"; /** * The subscriber context. This holds a reference to the current subscriber registered in the async context. */ export type SubscriberContext = { /** * The subscriber registered in the async context. */ subscriber: ISubscriber; /** * Clones the current context. */ clone(): SubscriberContext; }; /** * The AsyncLocalStorage instance used to store the subscriber context. */ export declare const context: AsyncLocalStorage; /** * Creates a new subscriber context with the provided subscriber. * * @param subscriber The subscriber to use in the new context. * @returns The new context. */ export declare function createSubscriberContext(subscriber: ISubscriber): SubscriberContext; /** * Retrieves the current subscriber context or throws an error if no context is found. * * @returns The current subscriber context or throws an error if no context is found. */ export declare function getSubscriberContextOrThrow(): SubscriberContext; /** * Retrieves the current subscriber context or `undefined` if no context is found. * * @returns The current subscriber context or `undefined` if no context is found. */ export declare function getSubscriberContext(): SubscriberContext | undefined; export declare function setDefaultGlobalSubscriber(subscriber: SubscriberContext): void; //# sourceMappingURL=context.d.ts.map