From c6464379b0547bc182fba876f7497a1982e7b728 Mon Sep 17 00:00:00 2001 From: Robert Da Silva Date: Thu, 21 Jul 2022 23:51:15 +0200 Subject: [PATCH] fix: add missing memory circuit breaker options Signed-off-by: Robert Da Silva --- index.d.ts | 6 ++---- lib/Transport.d.ts | 11 +++++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/index.d.ts b/index.d.ts index 328664ea4..8a6112c99 100644 --- a/index.d.ts +++ b/index.d.ts @@ -45,6 +45,7 @@ import Transport, { RequestBody, RequestNDBody, Context, + MemoryCircuitBreakerOptions, } from './lib/Transport'; import { URL } from 'url'; import Connection, { AgentOptions, agentFn } from './lib/Connection'; @@ -137,10 +138,7 @@ interface ClientOptions { password?: string; }; disablePrototypePoisoningProtection?: boolean | 'proto' | 'constructor'; - memoryCircuitBreaker?: { - enabled: boolean; - maxPercentage: number; - }; + memoryCircuitBreaker?: MemoryCircuitBreakerOptions } declare class Client { diff --git a/lib/Transport.d.ts b/lib/Transport.d.ts index 026601b12..3b3c2f802 100644 --- a/lib/Transport.d.ts +++ b/lib/Transport.d.ts @@ -29,10 +29,10 @@ */ import { Readable as ReadableStream } from 'stream'; -import { ConnectionPool, CloudConnectionPool } from './pool'; import Connection from './Connection'; -import Serializer from './Serializer'; import * as errors from './errors'; +import { CloudConnectionPool, ConnectionPool } from './pool'; +import Serializer from './Serializer'; export type ApiError = | errors.ConfigurationError @@ -59,6 +59,11 @@ export interface generateRequestIdFn { (params: TransportRequestParams, options: TransportRequestOptions): any; } +export interface MemoryCircuitBreakerOptions { + enabled: boolean; + maxPercentage: number; +} + interface TransportOptions { emit: (event: string | symbol, ...args: any[]) => boolean; connectionPool: ConnectionPool | CloudConnectionPool; @@ -77,6 +82,7 @@ interface TransportOptions { generateRequestId?: generateRequestIdFn; name?: string; opaqueIdPrefix?: string; + memoryCircuitBreaker?: MemoryCircuitBreakerOptions; } export interface RequestEvent, TContext = Context> { @@ -172,6 +178,7 @@ export default class Transport { sniffInterval: number; sniffOnConnectionFault: boolean; opaqueIdPrefix: string | null; + memoryCircuitBreaker: MemoryCircuitBreakerOptions | undefined; sniffEndpoint: string; _sniffEnabled: boolean; _nextSniff: number;