@@ -3,8 +3,6 @@ import { loadPackage } from '@nestjs/common/utils/load-package.util';
33import { isFunction , isObject } from '@nestjs/common/utils/shared.utils' ;
44import { Observable , Subscription } from 'rxjs' ;
55import {
6- GRPC_DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH ,
7- GRPC_DEFAULT_MAX_SEND_MESSAGE_LENGTH ,
86 GRPC_DEFAULT_PROTO_LOADER ,
97 GRPC_DEFAULT_URL ,
108} from '../constants' ;
@@ -14,6 +12,7 @@ import { InvalidProtoDefinitionException } from '../errors/invalid-proto-definit
1412import { ClientGrpc , GrpcOptions } from '../interfaces' ;
1513import { ClientProxy } from './client-proxy' ;
1614import { GRPC_CANCELLED } from './constants' ;
15+ import { ChannelOptions } from "../external/grpc-options.interface" ;
1716
1817let grpcPackage : any = { } ;
1918let grpcProtoLoaderPackage : any = { } ;
@@ -65,33 +64,20 @@ export class ClientGrpcProxy extends ClientProxy implements ClientGrpc {
6564 throw new InvalidGrpcServiceException ( ) ;
6665 }
6766
68- const maxSendMessageLengthKey = 'grpc.max_send_message_length' ;
69- const maxReceiveMessageLengthKey = 'grpc.max_receive_message_length' ;
70- const maxMessageLengthOptions = {
71- [ maxSendMessageLengthKey ] : this . getOptionsProp (
72- this . options ,
73- 'maxSendMessageLength' ,
74- GRPC_DEFAULT_MAX_SEND_MESSAGE_LENGTH ,
75- ) ,
76- [ maxReceiveMessageLengthKey ] : this . getOptionsProp (
77- this . options ,
78- 'maxReceiveMessageLength' ,
79- GRPC_DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH ,
80- ) ,
81- } ;
82- const maxMetadataSize = this . getOptionsProp (
83- this . options ,
84- 'maxMetadataSize' ,
85- - 1 ,
86- ) ;
87- if ( maxMetadataSize > 0 ) {
88- maxMessageLengthOptions [ 'grpc.max_metadata_size' ] = maxMetadataSize ;
67+ const channelOptions : ChannelOptions = this . options && this . options . channelOptions ? this . options . channelOptions : { } ;
68+ if ( this . options && this . options . maxSendMessageLength ) {
69+ channelOptions [ "grpc.max_send_message_length" ] = this . options . maxSendMessageLength ;
70+ }
71+ if ( this . options && this . options . maxReceiveMessageLength ) {
72+ channelOptions [ "grpc.max_receive_message_length" ] = this . options . maxReceiveMessageLength ;
73+ }
74+ if ( this . options && this . options . maxMetadataSize ) {
75+ channelOptions [ "grpc.max_metadata_size" ] = this . options . maxMetadataSize ;
8976 }
9077
9178 const keepaliveOptions = this . getKeepaliveOptions ( ) ;
9279 const options : Record < string , string | number > = {
93- ...( this . options . channelOptions || { } ) ,
94- ...maxMessageLengthOptions ,
80+ ...channelOptions ,
9581 ...keepaliveOptions ,
9682 } ;
9783
0 commit comments