@@ -2,18 +2,14 @@ import { Logger } from '@nestjs/common/services/logger.service';
2
2
import { loadPackage } from '@nestjs/common/utils/load-package.util' ;
3
3
import { isFunction , isObject } from '@nestjs/common/utils/shared.utils' ;
4
4
import { Observable , Subscription } from 'rxjs' ;
5
- import {
6
- GRPC_DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH ,
7
- GRPC_DEFAULT_MAX_SEND_MESSAGE_LENGTH ,
8
- GRPC_DEFAULT_PROTO_LOADER ,
9
- GRPC_DEFAULT_URL ,
10
- } from '../constants' ;
5
+ import { GRPC_DEFAULT_PROTO_LOADER , GRPC_DEFAULT_URL } from '../constants' ;
11
6
import { InvalidGrpcPackageException } from '../errors/invalid-grpc-package.exception' ;
12
7
import { InvalidGrpcServiceException } from '../errors/invalid-grpc-service.exception' ;
13
8
import { InvalidProtoDefinitionException } from '../errors/invalid-proto-definition.exception' ;
14
9
import { ClientGrpc , GrpcOptions } from '../interfaces' ;
15
10
import { ClientProxy } from './client-proxy' ;
16
11
import { GRPC_CANCELLED } from './constants' ;
12
+ import { ChannelOptions } from '../external/grpc-options.interface' ;
17
13
18
14
let grpcPackage : any = { } ;
19
15
let grpcProtoLoaderPackage : any = { } ;
@@ -66,33 +62,25 @@ export class ClientGrpcProxy extends ClientProxy implements ClientGrpc {
66
62
throw new InvalidGrpcServiceException ( ) ;
67
63
}
68
64
69
- const maxSendMessageLengthKey = 'grpc.max_send_message_length' ;
70
- const maxReceiveMessageLengthKey = 'grpc.max_receive_message_length' ;
71
- const maxMessageLengthOptions = {
72
- [ maxSendMessageLengthKey ] : this . getOptionsProp (
73
- this . options ,
74
- 'maxSendMessageLength' ,
75
- GRPC_DEFAULT_MAX_SEND_MESSAGE_LENGTH ,
76
- ) ,
77
- [ maxReceiveMessageLengthKey ] : this . getOptionsProp (
78
- this . options ,
79
- 'maxReceiveMessageLength' ,
80
- GRPC_DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH ,
81
- ) ,
82
- } ;
83
- const maxMetadataSize = this . getOptionsProp (
84
- this . options ,
85
- 'maxMetadataSize' ,
86
- - 1 ,
87
- ) ;
88
- if ( maxMetadataSize > 0 ) {
89
- maxMessageLengthOptions [ 'grpc.max_metadata_size' ] = maxMetadataSize ;
65
+ const channelOptions : ChannelOptions =
66
+ this . options && this . options . channelOptions
67
+ ? this . options . channelOptions
68
+ : { } ;
69
+ if ( this . options && this . options . maxSendMessageLength ) {
70
+ channelOptions [ 'grpc.max_send_message_length' ] =
71
+ this . options . maxSendMessageLength ;
72
+ }
73
+ if ( this . options && this . options . maxReceiveMessageLength ) {
74
+ channelOptions [ 'grpc.max_receive_message_length' ] =
75
+ this . options . maxReceiveMessageLength ;
76
+ }
77
+ if ( this . options && this . options . maxMetadataSize ) {
78
+ channelOptions [ 'grpc.max_metadata_size' ] = this . options . maxMetadataSize ;
90
79
}
91
80
92
81
const keepaliveOptions = this . getKeepaliveOptions ( ) ;
93
82
const options : Record < string , string | number > = {
94
- ...( this . options . channelOptions || { } ) ,
95
- ...maxMessageLengthOptions ,
83
+ ...channelOptions ,
96
84
...keepaliveOptions ,
97
85
} ;
98
86
0 commit comments