From 7837e8e845226e2153fc103afadd23329b03d958 Mon Sep 17 00:00:00 2001 From: Andrey Melnik Date: Wed, 20 Jan 2021 01:00:57 +0300 Subject: [PATCH 1/2] feature(grpc-js): Add possibility to provide maxSessionMemory http2 option through ChannelOptions --- packages/grpc-js/src/channel-options.ts | 2 ++ packages/grpc-js/src/server.ts | 5 ++++- packages/grpc-js/src/subchannel.ts | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/grpc-js/src/channel-options.ts b/packages/grpc-js/src/channel-options.ts index df6cbb2b1..e1ad94dce 100644 --- a/packages/grpc-js/src/channel-options.ts +++ b/packages/grpc-js/src/channel-options.ts @@ -28,6 +28,7 @@ export interface ChannelOptions { 'grpc.keepalive_permit_without_calls'?: number; 'grpc.service_config'?: string; 'grpc.max_concurrent_streams'?: number; + 'grpc.max_session_memory'?: number; 'grpc.initial_reconnect_backoff_ms'?: number; 'grpc.max_reconnect_backoff_ms'?: number; 'grpc.use_local_subchannel_pool'?: number; @@ -53,6 +54,7 @@ export const recognizedOptions = { 'grpc.keepalive_permit_without_calls': true, 'grpc.service_config': true, 'grpc.max_concurrent_streams': true, + 'grpc.max_session_memory': true, 'grpc.initial_reconnect_backoff_ms': true, 'grpc.max_reconnect_backoff_ms': true, 'grpc.use_local_subchannel_pool': true, diff --git a/packages/grpc-js/src/server.ts b/packages/grpc-js/src/server.ts index 335a11fce..fe906af20 100644 --- a/packages/grpc-js/src/server.ts +++ b/packages/grpc-js/src/server.ts @@ -258,8 +258,11 @@ export class Server { } const serverOptions: http2.ServerOptions = { - maxSendHeaderBlockLength: Number.MAX_SAFE_INTEGER + maxSendHeaderBlockLength: Number.MAX_SAFE_INTEGER, }; + if ('grpc.max_session_memory' in this.options) { + serverOptions.maxSessionMemory = this.options['grpc.max_session_memory']; + } if ('grpc.max_concurrent_streams' in this.options) { serverOptions.settings = { maxConcurrentStreams: this.options['grpc.max_concurrent_streams'], diff --git a/packages/grpc-js/src/subchannel.ts b/packages/grpc-js/src/subchannel.ts index c32ee43ea..bcbd8877e 100644 --- a/packages/grpc-js/src/subchannel.ts +++ b/packages/grpc-js/src/subchannel.ts @@ -307,6 +307,9 @@ export class Subchannel { let connectionOptions: http2.SecureClientSessionOptions = this.credentials._getConnectionOptions() || {}; connectionOptions.maxSendHeaderBlockLength = Number.MAX_SAFE_INTEGER; + if ('grpc.max_session_memory' in this.options) { + connectionOptions.maxSessionMemory = this.options['grpc.max_session_memory']; + } let addressScheme = 'http://'; if ('secureContext' in connectionOptions) { addressScheme = 'https://'; From 21176c23ab7b2f96e85b5d07d330003661a5f016 Mon Sep 17 00:00:00 2001 From: Andrey Melnik Date: Wed, 20 Jan 2021 01:00:57 +0300 Subject: [PATCH 2/2] feature(grpc-js): Add possibility to provide maxSessionMemory http2 option through ChannelOptions --- packages/grpc-js/src/channel-options.ts | 4 ++-- packages/grpc-js/src/server.ts | 6 +++--- packages/grpc-js/src/subchannel.ts | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/grpc-js/src/channel-options.ts b/packages/grpc-js/src/channel-options.ts index e1ad94dce..ebb724b0e 100644 --- a/packages/grpc-js/src/channel-options.ts +++ b/packages/grpc-js/src/channel-options.ts @@ -28,7 +28,6 @@ export interface ChannelOptions { 'grpc.keepalive_permit_without_calls'?: number; 'grpc.service_config'?: string; 'grpc.max_concurrent_streams'?: number; - 'grpc.max_session_memory'?: number; 'grpc.initial_reconnect_backoff_ms'?: number; 'grpc.max_reconnect_backoff_ms'?: number; 'grpc.use_local_subchannel_pool'?: number; @@ -37,6 +36,7 @@ export interface ChannelOptions { 'grpc.enable_http_proxy'?: number; 'grpc.http_connect_target'?: string; 'grpc.http_connect_creds'?: string; + 'grpc-node.max_session_memory'?: number; [key: string]: any; } @@ -54,13 +54,13 @@ export const recognizedOptions = { 'grpc.keepalive_permit_without_calls': true, 'grpc.service_config': true, 'grpc.max_concurrent_streams': true, - 'grpc.max_session_memory': true, 'grpc.initial_reconnect_backoff_ms': true, 'grpc.max_reconnect_backoff_ms': true, 'grpc.use_local_subchannel_pool': true, 'grpc.max_send_message_length': true, 'grpc.max_receive_message_length': true, 'grpc.enable_http_proxy': true, + 'grpc-node.max_session_memory': true, }; export function channelOptionsEqual( diff --git a/packages/grpc-js/src/server.ts b/packages/grpc-js/src/server.ts index fe906af20..255e210b6 100644 --- a/packages/grpc-js/src/server.ts +++ b/packages/grpc-js/src/server.ts @@ -258,10 +258,10 @@ export class Server { } const serverOptions: http2.ServerOptions = { - maxSendHeaderBlockLength: Number.MAX_SAFE_INTEGER, + maxSendHeaderBlockLength: Number.MAX_SAFE_INTEGER }; - if ('grpc.max_session_memory' in this.options) { - serverOptions.maxSessionMemory = this.options['grpc.max_session_memory']; + if ('grpc-node.max_session_memory' in this.options) { + serverOptions.maxSessionMemory = this.options['grpc-node.max_session_memory']; } if ('grpc.max_concurrent_streams' in this.options) { serverOptions.settings = { diff --git a/packages/grpc-js/src/subchannel.ts b/packages/grpc-js/src/subchannel.ts index bcbd8877e..a435e452f 100644 --- a/packages/grpc-js/src/subchannel.ts +++ b/packages/grpc-js/src/subchannel.ts @@ -307,8 +307,8 @@ export class Subchannel { let connectionOptions: http2.SecureClientSessionOptions = this.credentials._getConnectionOptions() || {}; connectionOptions.maxSendHeaderBlockLength = Number.MAX_SAFE_INTEGER; - if ('grpc.max_session_memory' in this.options) { - connectionOptions.maxSessionMemory = this.options['grpc.max_session_memory']; + if ('grpc-node.max_session_memory' in this.options) { + connectionOptions.maxSessionMemory = this.options['grpc-node.max_session_memory']; } let addressScheme = 'http://'; if ('secureContext' in connectionOptions) {