nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
67.29k stars 7.59k forks source link

gRPC Server side streaming using call stream handler #6853

Closed daniel-vera-g closed 3 years ago

daniel-vera-g commented 3 years ago

gRPC Server side streaming using call stream handler

Description

So far(from the Documentation) Nest supports:

  1. Unary gRPC calls using @GrpcMethod
  2. Client side streaming: @GrpcStreamMethod() or @GrpcStreamCall()
  3. Bidirectional streaming using:
    • Subject Strategy: @GrpcStreamMethod()
    • Call stream handler: @GrpcStreamCall()
  4. Server side streaming using the subject strategy: @GrpcMethod(Learned here: https://github.com/nestjs/nest/issues/2659#issuecomment-516164027)

But I could not find a possibility to do server side streaming using the call stream handler method. Actually in the issue referenced above, a workaround using bidirectional streaming is used for call stream handlers.

Describe the solution you'd like

In the documentation it says, that:

"When the method return value is defined as stream, the @GrpcStreamCall() decorator provides the function parameter as grpc.ServerDuplexStream"

But in the case of server side streaming, we probably need the the ServerWritableStream(https://grpc.github.io/grpc/node/grpc-ServerWritableStream.html).

Teachability, Documentation, Adoption, Migration Strategy

  1. I'm pretty new to the Decorators concept, so I'm not sure how it could be implemented here
  2. I would re-structure the docs a bit to be able to distinguish between the different gRPC calls and NestJS RxJS/Call Stream handler combinations.

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

It seems a bit incomplete how the Docs reference Server/Client side streaming with the call stream handler method.

kamilmysliwiec commented 3 years ago

We currently don't plan to introduce new streaming strategies.

As for the docs, they are open-sourced and PRs are more than welcome! https://github.com/nestjs/docs.nestjs.com