@dynatrace/devkit
Version:
The Dynatrace App Toolkit utilities for writing and testing migrations.
40 lines (39 loc) • 1.46 kB
TypeScript
/**
* @internal Only for the use of DevXp
* Util to get a free port to run tests on.
*/
export declare function findPortInRange(host: string, startPort: number, endPort?: number): Promise<number | undefined>;
/**
* @internal Only for the use of DevXp
* Util to check if a port is used or not
*/
export declare function isUsed(host: string, port: number): Promise<boolean>;
/**
* @internal Only for the use of DevXp
* Util to write code that depends on a port being unused. Tries to run
* the specified code on a specified port and retries with next port (<= options.endPort)
* if it fails due to the port being bound already.
* @param run code to run that depends on a port being unused.
* @param startPort port that should be used for the first try.
* @param options further options.
* @returns
*/
export declare function runOnUnusedPort<T>(run: (port: number) => Promise<T>, startPort: number, options?: {
range?: number | number[];
/**
* Part of error message that indicates that the
* port is already in use.
* @default 'EADDRINUSE'
*/
errorMessage?: string;
/**
* Error message that should be displayed if no
* free port was found in the specified range.
*/
displayMessage?: string;
/**
* Callback that is executed every time the code failed
* due to the port being used. Can be used to do info logs.
*/
onUsedCallback?: (port: number) => void;
}): Promise<T>;