grapesy icon indicating copy to clipboard operation
grapesy copied to clipboard

Plugin to generate Client/Server stubs

Open domenkozar opened this issue 1 year ago • 3 comments

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.

domenkozar avatar Feb 07 '24 19:02 domenkozar

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?

edsko avatar Feb 08 '24 06:02 edsko

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 avatar Feb 08 '24 10:02 domenkozar

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

domenkozar avatar Feb 12 '24 16:02 domenkozar