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

GRPC API #6

Open
joe-getcouragenow opened this issue Aug 24, 2020 · 5 comments
Open

GRPC API #6

joe-getcouragenow opened this issue Aug 24, 2020 · 5 comments

Comments

@joe-getcouragenow
Copy link

joe-getcouragenow commented Aug 24, 2020

Would you accept a GRPC API ?

I need to access quid from various languages and so GPRC makes that easy from flutter, golang and rust.

The existing API can live along side a GRPC, so it wont break the current node based admin gui.


I was actually thinking of making a Admin GUI using flutter web, just easier to manage and extend i find. I guess you however hoe vuejs for a reason and so dont want a PR for this ?

anyway, let me know...

@joe-getcouragenow joe-getcouragenow changed the title Flutter API GRPC API Aug 24, 2020
@synw
Copy link
Member

synw commented Aug 25, 2020

GPRC makes that easy

Thanks for your proposition. Question: how easier would it be than the http way?

Actually I would prefer some help with the client request libraries (libs to manage requests with transparent renew of the access tokens and request retries, like the js one). I plan to release this js lib separatly and make some for Dart and Python first. A grpc api would need to be maintained on the long term if we adopt it

I was actually thinking of making a Admin GUI using flutter web

Well I prefer maintaining some Flutter code as well than using the js/css/html combo. But actually I think that Flutter web is not mature enough, and the rendering is not very classic and less efficient for an admin interface on a computer. It could be interesting to make a Flutter web app to have the admin interface on the phone, I did not bother to make it responsive, but is it really useful at this stage?

@joe-getcouragenow
Copy link
Author

heres my own opinion:
About GRPC
GRPC code generates all the code and give you 90% of the code that you already hand code.
GRPC middleware does the all important metrics and logging for you too.

Here is how i load up the man cmd to support both serving grpc and grpc.web AND flutter web, without any envoy needed
https://github.com/getcouragenow/packages/blob/master/maintemplate/server/cmd/main.go#L85

  • disegard the "local". that just for when i dont use envoy, and you dont need envoy i think.

And to load up the other grpc Services into the Server its easy:
https://github.com/getcouragenow/packages/blob/master/maintemplate/server/cmd/main.go#L74
Which calls this: https://github.com/getcouragenow/packages/blob/master/mod-chat/server/pkg/service/server.go

All routing, params on a request, etc etc are all handled 100% by the proto like here:
https://github.com/getcouragenow/packages/blob/master/mod-chat/server/api/service.proto

I have not added much middleware except logging: https://github.com/getcouragenow/packages/blob/master/mod-chat/server/pkg/service/server.go#L19
Adding openconsensus would be the obvious one to add:
https://opencensus.io/guides/grpc/go/

https://opencensus.io/integrations/redis/go/

https://opencensus.io/integrations/sql/go_sql/

https://opencensus.io/integrations/mongodb/go_driver/

https://opencensus.io/integrations/mongodb/mongostatusd/


About Flutter
I use flutter web for a very large project and also cross compile it to desktop and mobile.
Zero code differences.
Its actually very mature and very fast. Load time is a bit bigger but for an admin tool i think its fine. And it natively creates offline cache with service worker so after the firs load it never reloads unless you release a new flutter web build.
Its basically developer friendly seamless, and i have been using it for quite a while.

@joe-getcouragenow
Copy link
Author

Oh and code generation of the Dart and golang code works fine.

@olibre
Copy link
Member

olibre commented Aug 29, 2020

Hi @joe-getcouragenow
That's great to have gRPC on Quid project.
But I have one question about the gRPC support for JS and/or WebAssembly:
Is it possible to generate gRPC client code to be used by an app running in a browser ? (web front-end)

I think gRPC is very nice when the user is used with gRPC.
But if a user is used with HTTP/REST APIs, they may prefer to use a classic REST API in lieu of having to download/install/upgrade gRPC compiler and (manually) generate/update obscure source code to be used by their Quid client.

Quiq is designed to be maintained in the long term.
Would you be ready to help maintaining/document the gRPC Proto3 files + server code in the long term?

@joe-getcouragenow
Copy link
Author

joe-getcouragenow commented Sep 7, 2020

Hi @joe-getcouragenow
That's great to have gRPC on Quid project.
But I have one question about the gRPC support for JS and/or WebAssembly:
Is it possible to generate gRPC client code to be used by an app running in a browser ? (web front-end)

Yes. The same flutter grpc code works in web, desktop and mobile. Its pretty cool.

I think gRPC is very nice when the user is used with gRPC.
But if a user is used with HTTP/REST APIs, they may prefer to use a classic REST API in lieu of having to download/install/upgrade gRPC compiler and (manually) generate/update obscure source code to be used by their Quid client.

Its only this to install:

  • brew install protobuf
  • go get github.com/protocolbuffers/protobuf-go
  • go get github.com/grpc/grpc-go

then script to gen the code like: protoc ${PROTO_SOURCE_DIR}/${PROTO_SOURCE_FILE} --go-grpc_out=proto --go_out=proto

Quiq is designed to be maintained in the long term.
Would you be ready to help maintaining/document the gRPC Proto3 files + server code in the long term?

Yes, because we are building something similar already in our project, and i was planning to integrate into it.

The only problem for me is your using relying on an external DB here: https://github.com/synw/quid/blob/master/quidlib/server/db/db.go

I would need to add an adapter for embedded DB.like Badger. These are both badger based for example.

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

No branches or pull requests

3 participants