import { IHttpRequestCorrelator } from './IHttpRequestCorrelator'; /** * Correlation service that can provide or forward an ID * that will be injected both in HTTP requests and log events, * using plugins and middlewares. * @remarks * This service only works with NodeJS 12.17/13.10 or later since it relies * on the new {AsyncLocalStorage} class, from the async_hooks module. * We don't provide an alternate implementation since we don't want * to introduce any external dependency to this project. * @see https://nodejs.org/api/async_hooks.html#async_hooks_new_asynclocalstorage * * See also the documentation of the {IHttpRequestCorrelator} for a concrete * example of such an implementation. */ export declare class HttpRequestCorrelator implements IHttpRequestCorrelator { private readonly idGenerator?; private readonly storage; private nextId; /** * Creates a new instance of a {HttpRequestCorrelator} * @param [idGenerator] an optional custom ID generator */ constructor(idGenerator?: (() => string) | undefined); /** * Generates a new ID for correlating multiple HTTP requests. * * If a custom generator was not provided in the constructor, * a default ID will be generated, without any warranty of its unicity * (format is 'CID-'). Note that we don't generate a Guid because * we don't want add any external dependency to this library. * @remarks * Note that if you provide explicitely a Correlation ID to the * `withId` or `withIdAsync` methods, `createNewId` won't be called. */ createNewId(): string; /** * gets the current correlation ID */ getId(): string | undefined; /** * Starts a new context and installs the submitted correlation ID (or generates a new one * if undefined), then invokes the submitted callback. * @param work a callback to invoke with the submitted correlation ID * @param [cid] the correlation ID to install be before invoking the submitted callback */ withId(work: () => T, cid?: string): T; /** * Starts a new context and installs the submitted correlation ID (or generates a new one * if undefined), then invokes the submitted callback. * This is the promisified version of the `withId` method. * @param work a callback to invoke with the submitted correlation ID * @param [cid] the correlation ID to install be before invoking the submitted callback */ withIdAsync(work: () => Promise, cid?: string): Promise; bind(target: T): T; private bindEmitter; private bindFunction; }