Skip to content

Commit

Permalink
Merge pull request #1666 from dwrip/master
Browse files Browse the repository at this point in the history
feature(grpc-js): Add possibility to provide maxSessionMemory http2 option through ChannelOptions
  • Loading branch information
murgatroid99 committed Apr 2, 2021
2 parents 3468e58 + 65d4de8 commit c3aeb94
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/grpc-js/src/channel-options.ts
Expand Up @@ -36,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;
}

Expand All @@ -59,6 +60,7 @@ export const recognizedOptions = {
'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(
Expand Down
3 changes: 3 additions & 0 deletions packages/grpc-js/src/server.ts
Expand Up @@ -260,6 +260,9 @@ export class Server {
const serverOptions: http2.ServerOptions = {
maxSendHeaderBlockLength: Number.MAX_SAFE_INTEGER
};
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 = {
maxConcurrentStreams: this.options['grpc.max_concurrent_streams'],
Expand Down
3 changes: 3 additions & 0 deletions packages/grpc-js/src/subchannel.ts
Expand Up @@ -307,6 +307,9 @@ export class Subchannel {
let connectionOptions: http2.SecureClientSessionOptions =
this.credentials._getConnectionOptions() || {};
connectionOptions.maxSendHeaderBlockLength = Number.MAX_SAFE_INTEGER;
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) {
addressScheme = 'https://';
Expand Down

0 comments on commit c3aeb94

Please sign in to comment.