well-typed / grapesy

Native Haskell gRPC client and server based on `http2`
Other
31 stars 4 forks source link

Plugin to generate Client/Server stubs #80

Open domenkozar opened 4 months ago

domenkozar commented 4 months ago

For example in Go it's possible to generate also all the client/server calls.

This avoids the tedious work of matching the request/response types, importing all Protos, etc.

edsko commented 4 months ago

I'm not sure exactly what you'd anticipate to be generated here. For example, if you take a look at https://github.com/well-typed/grapesy/blob/main/demo-client/Demo/Client/API/Protobuf/IO/RouteGuide.hs , which is the standard Protobuf RouteGuide example, there's barely any boilerplate required at all without generation. What did you have in mind?

domenkozar commented 4 months ago

I have a grpc with a few thousand rpc calls, so while I can manually add them, it would save time to just have req/resp calls generated.

Given a .proto snippet:

...
service Service {
    rpc ReqResource(Request) returns (Response) {
...

It would generate:

reqResource :: Client.CanCallRPC m => Request -> m Response
reqResource req = Client.nonStreaming (Client.rpc @(Client.Protobuf Service "reqResource") req

And other variants for streaming, etc.

domenkozar commented 4 months ago

Especially convenient when support for https://github.com/well-typed/grapesy/issues/85 is in.