2021-03-10 08:48:34 +01:00
|
|
|
// Copyright BigchainDB GmbH and BigchainDB contributors
|
|
|
|
// SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
|
|
|
// Code is Apache-2.0 and docs are CC-BY-4.0
|
|
|
|
|
|
|
|
import type { RequestConfig } from './baseRequest';
|
|
|
|
|
|
|
|
export interface Node {
|
|
|
|
endpoint: string;
|
|
|
|
headers: Record<string, string | string[]>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default class Request {
|
|
|
|
private node: Node;
|
|
|
|
private backoffTime: number;
|
|
|
|
private retries: number;
|
|
|
|
private connectionError?: Error;
|
|
|
|
|
|
|
|
constructor(node: Node);
|
|
|
|
|
2021-03-11 13:05:14 +01:00
|
|
|
request<O = Record<string, any>>(
|
2021-03-10 08:48:34 +01:00
|
|
|
urlPath: string,
|
2021-03-11 13:05:14 +01:00
|
|
|
config?: RequestConfig,
|
2021-03-10 08:48:34 +01:00
|
|
|
timeout?: number,
|
|
|
|
maxBackoffTime?: number
|
|
|
|
): Promise<O>;
|
|
|
|
|
|
|
|
updateBackoffTime(maxBackoffTime: number): void;
|
|
|
|
|
|
|
|
getBackoffTimedelta(): number;
|
|
|
|
|
|
|
|
static sleep(ms: number): void;
|
|
|
|
}
|