teal-finance / quid

Refresh/Access JWT authentication server with backend + administration frontend supporting HMAC (HS256 HS384 HS512), RSA (RS256 RS384 RS512), ECDSA (ES256 ES384 ES512) and Ed25519 (EdDSA). See also other repos for Javascript, Python and Go client libraries.
MIT License
11 stars 2 forks source link

GRPC API #6

Open joe-getcouragenow opened 4 years ago

joe-getcouragenow commented 4 years ago

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...

synw commented 4 years ago

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 commented 4 years ago

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

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 commented 4 years ago

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

olibre commented 4 years ago

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 commented 4 years ago

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:

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.