Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing memory circuit breaker options #266

Merged
merged 1 commit into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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