nest icon indicating copy to clipboard operation
nest copied to clipboard

Add a way to pass loader options to custom grpc-loader

Open eladhaim opened this issue 1 year ago • 9 comments
trafficstars

Is there an existing issue that is already proposing this?

  • [X] I have searched the existing issues

Is your feature request related to a problem? Please describe it

We heavily rely on protobuf and use ts-proto to generate our package definitions. To handle the generated code, we've had to create our own gRPC loader. However, while we have the option to pass a custom gRPC loader, we currently cannot pass custom gRPC options. Ideally, we'd like the loader object within GrpcOptions to be of type any or a generic type that we can override to customize the options as needed.

Describe the solution you'd like

Our problem is just a type issue, converting the loader object to any/generic with default will do the job.

Teachability, documentation, adoption, migration strategy

Today:

     ClientsModule.register([
      {
        name: 'GRPC_CLIENT_NAME',
        transport: Transport.GRPC,
        options: {
          package: 'testPackage',
          protoPath: 'proto_path',
          protoLoader: 'our custom loader',
          url: 'localhost:4001',
          loader: {
             // @ts-ignore
             newOption: 'new option'
          },
        },
      }
    ]),

After the change:

   ClientsModule.register([
   {
     name: 'GRPC_CLIENT_NAME',
     transport: Transport.GRPC,
     options: {
       package: 'testPackage',
       protoPath: 'proto_path',
       protoLoader: 'our custom loader',
       url: 'localhost:4001',
       loader: {
          newOption: 'new option'
       },
     },
   }
 ])

What is the motivation / use case for changing the behavior?

Adding more flexibility to the server/client of grpc

eladhaim avatar Aug 29 '24 11:08 eladhaim