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

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

Merged
merged 3 commits into from Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/grpc-js/src/channel-options.ts
Expand Up @@ -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;
Expand All @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion packages/grpc-js/src/server.ts
Expand Up @@ -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'],
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.max_session_memory' in this.options) {
connectionOptions.maxSessionMemory = this.options['grpc.max_session_memory'];
}
let addressScheme = 'http://';
if ('secureContext' in connectionOptions) {
addressScheme = 'https://';
Expand Down