ts-proto icon indicating copy to clipboard operation
ts-proto copied to clipboard

feat: Grpc web stream (Promise/Observable)

Open luhuaei opened this issue 3 years ago • 6 comments

Support grpc-web Promise stream and Observable stream.

  • add grpc-web-promise-stream test example(test Promise stream)
  • add grpc-web-observable-stream example(test Observable stream)
  • add grpc-web-go-stream-server example (test server backend)

Note

If you use returnObservable options all service methods will return Observable type. Without this parameter, it will default to Promise type. That is, if returnObservable is specified, there will be no return type of Promise, and vice versa.

This will cause the original generated code to be changed, like the previous generated code, server stream method will return Observable regardless of whether returnObservable is specified or not. (#337 )

cc @paralin

luhuaei avatar Jul 30 '22 00:07 luhuaei

try to add grpcWebMixObservable options default is true. It mean:

  • unary method use Promise response type.
  • client streaming or server streaming use Observable response type.
  • default parameters.txt is outputClientImpl=grpc-web equal to outputClientImpl=grpc-web,returnObservable=false,grpcWebMixObservablePromise=true

If you want all method return Observable response type, only set outputClientImpl=grpc-web,returnObservable=true.

If you want all method return Promise response type, setting: outputClientImpl=grpc-web,grpcWebMixObservablePromise=false.

luhuaei avatar Aug 01 '22 14:08 luhuaei

If you use returnObservable options all service methods will return Observable type. Without this parameter, it will default to Promise type. That is, if returnObservable is specified, there will be no return type of Promise, and vice versa.

This will cause the original generated code to be changed, like the previous generated code, server stream method will return Observable regardless of whether returnObservable is specified or not. (#337 )

This break change already compatiable by grpcWebMixObservablePromise options.

luhuaei avatar Aug 01 '22 14:08 luhuaei

@stephenh You can take a look, it's nice to merge into master. Thanks!!

luhuaei avatar Aug 01 '22 15:08 luhuaei

Hey @luhuaei I'll try to have a look at this soon. Big patch, lots to review

paralin avatar Aug 10 '22 04:08 paralin

Hey @luhuaei I'll try to have a look at this soon. Big patch, lots to review

Thanks! If you have any questions, feel free to ask.

luhuaei avatar Aug 10 '22 10:08 luhuaei

Hi, Any news here? We also need streaming support

netanel-utila avatar Jul 20 '23 11:07 netanel-utila