File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { Logger } from '@nestjs/common/services/logger.service';
22import { loadPackage } from '@nestjs/common/utils/load-package.util' ;
33import { isObject } from '@nestjs/common/utils/shared.utils' ;
44import { Observable } from 'rxjs' ;
5- import { GRPC_DEFAULT_URL } from '../constants' ;
5+ import { GRPC_DEFAULT_PROTO_LOADER , GRPC_DEFAULT_URL } from '../constants' ;
66import { InvalidGrpcPackageException } from '../exceptions/errors/invalid-grpc-package.exception' ;
77import { InvalidGrpcServiceException } from '../exceptions/errors/invalid-grpc-service.exception' ;
88import { InvalidProtoDefinitionException } from '../exceptions/errors/invalid-proto-definition.exception' ;
@@ -24,9 +24,12 @@ export class ClientGrpcProxy extends ClientProxy implements ClientGrpc {
2424 this . url =
2525 this . getOptionsProp < GrpcOptions > ( options , 'url' ) || GRPC_DEFAULT_URL ;
2626
27+ const protoLoader =
28+ this . getOptionsProp < GrpcOptions > ( options , 'protoLoader' ) || GRPC_DEFAULT_PROTO_LOADER ;
29+
2730 grpcPackage = loadPackage ( 'grpc' , ClientGrpcProxy . name ) ;
2831 grpcProtoLoaderPackage = loadPackage (
29- '@grpc/proto-loader' ,
32+ protoLoader ,
3033 ClientGrpcProxy . name ,
3134 ) ;
3235 this . grpcClient = this . createClient ( ) ;
Original file line number Diff line number Diff line change @@ -25,3 +25,5 @@ export const RQM_DEFAULT_QUEUE = 'default';
2525export const RQM_DEFAULT_PREFETCH_COUNT = 0 ;
2626export const RQM_DEFAULT_IS_GLOBAL_PREFETCH_COUNT = false ;
2727export const RQM_DEFAULT_QUEUE_OPTIONS = { } ;
28+
29+ export const GRPC_DEFAULT_PROTO_LOADER = '@grpc/proto-loader' ;
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ export interface GrpcOptions {
2424 credentials ?: any ;
2525 protoPath : string ;
2626 package : string ;
27+ protoLoader ?: string ;
2728 /** @deprecated */
2829 root ?: string ;
2930 loader ?: {
Original file line number Diff line number Diff line change 11import { fromEvent } from 'rxjs' ;
22import { takeUntil } from 'rxjs/operators' ;
3- import { CANCEL_EVENT , GRPC_DEFAULT_URL } from '../constants' ;
3+ import { CANCEL_EVENT , GRPC_DEFAULT_PROTO_LOADER , GRPC_DEFAULT_URL } from '../constants' ;
44import { InvalidGrpcPackageException } from '../exceptions/errors/invalid-grpc-package.exception' ;
55import { InvalidProtoDefinitionException } from '../exceptions/errors/invalid-proto-definition.exception' ;
66import { CustomTransportStrategy } from '../interfaces' ;
@@ -22,9 +22,12 @@ export class ServerGrpc extends Server implements CustomTransportStrategy {
2222 this . url =
2323 this . getOptionsProp < GrpcOptions > ( options , 'url' ) || GRPC_DEFAULT_URL ;
2424
25+ const protoLoader =
26+ this . getOptionsProp < GrpcOptions > ( options , 'protoLoader' ) || GRPC_DEFAULT_PROTO_LOADER ;
27+
2528 grpcPackage = this . loadPackage ( 'grpc' , ServerGrpc . name ) ;
2629 grpcProtoLoaderPackage = this . loadPackage (
27- '@grpc/proto-loader' ,
30+ protoLoader ,
2831 ServerGrpc . name ,
2932 ) ;
3033 }
You can’t perform that action at this time.
0 commit comments