Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Grpc web stream (Promise/Observable) #633

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

luhuaei
Copy link
Contributor

@luhuaei luhuaei commented Jul 30, 2022

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 luhuaei changed the title WIP: Grpc web stream (Promise/Observable) feat: Grpc web stream (Promise/Observable) Aug 1, 2022
grpcWebMixObservable 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
Copy link
Contributor Author

luhuaei commented Aug 1, 2022

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
Copy link
Contributor Author

luhuaei commented Aug 1, 2022

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
Copy link
Contributor Author

luhuaei commented Aug 1, 2022

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

@paralin
Copy link
Collaborator

paralin commented Aug 10, 2022

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

@luhuaei
Copy link
Contributor Author

luhuaei commented Aug 10, 2022

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.

@netanel-utila
Copy link

Hi, Any news here? We also need streaming support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants