/*! * Copyright (c) 2020 Ville de Montreal. All rights reserved. * Licensed under the MIT license. * See LICENSE file in the project root for full license information. */ import { IHttpRequestCorrelator } from './IHttpRequestCorrelator'; /** * Fake implementation of a IHttpRequestCorrelator for unit tests. */ export declare class FakeHttpRequestCorrelator implements IHttpRequestCorrelator { private readonly idStack; constructor(initialValue?: string); /** * the list of emitters that were bound */ emitters: any[]; /** * the list of functions that were bound */ functions: any[]; /** * gets the current correlation ID */ getId(): string | undefined; /** * binds the current correlation context to the target * @param target the target to bind to * @returns either the submitted target (if it is an emitter) or a wrapped target (for a function) * @remarks you might have to bind to an emitter in order to maitain * the correlation context. */ bind(target: T): T; /** * Executes a function inside a context where the correlation ID is defined. * * @param work the function to run within the cid context. * @param [cid] the correlation ID to use. */ withId(work: () => void, cid?: string): void; /** * 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; }