feature(grpc-js): Add possibility to provide maxSessionMemory http2 option through ChannelOptions

This commit is contained in:
Andrey Melnik 2021-01-20 01:00:57 +03:00
parent 604dd0f206
commit 7837e8e845
3 changed files with 9 additions and 1 deletions

View File

@ -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,

View File

@ -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'],

View File

@ -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://';