Skip to content

Commit

Permalink
fix: add missing memory circuit breaker options (opensearch-project#266)
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Da Silva <mail@robdasilva.com>
  • Loading branch information
robdasilva authored and AMoo-Miki committed Jul 12, 2023
1 parent f5c6d16 commit 4678ab0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 2 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import Transport, {
RequestBody,
RequestNDBody,
Context,
MemoryCircuitBreakerOptions,
} from './lib/Transport';
import { URL } from 'url';
import Connection, { AgentOptions, agentFn } from './lib/Connection';
Expand Down Expand Up @@ -137,10 +138,7 @@ interface ClientOptions {
password?: string;
};
disablePrototypePoisoningProtection?: boolean | 'proto' | 'constructor';
memoryCircuitBreaker?: {
enabled: boolean;
maxPercentage: number;
};
memoryCircuitBreaker?: MemoryCircuitBreakerOptions
}

declare class Client {
Expand Down
11 changes: 9 additions & 2 deletions lib/Transport.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -77,6 +82,7 @@ interface TransportOptions {
generateRequestId?: generateRequestIdFn;
name?: string;
opaqueIdPrefix?: string;
memoryCircuitBreaker?: MemoryCircuitBreakerOptions;
}

export interface RequestEvent<TResponse = Record<string, any>, TContext = Context> {
Expand Down Expand Up @@ -172,6 +178,7 @@ export default class Transport {
sniffInterval: number;
sniffOnConnectionFault: boolean;
opaqueIdPrefix: string | null;
memoryCircuitBreaker: MemoryCircuitBreakerOptions | undefined;
sniffEndpoint: string;
_sniffEnabled: boolean;
_nextSniff: number;
Expand Down

0 comments on commit 4678ab0

Please sign in to comment.