-
Notifications
You must be signed in to change notification settings - Fork 328
Description
I'll keep this pretty short for now (I also know we discussed this very briefly @spenczar) but just to get the conversation going since this is on my near-term radar:
-
It would be nice to be able to have twitchtv/twirp generated code in a different package than the golang/protobuf generated code. This in theory would allow you to have separation of your Protobuf definitions and the specific RPC protocol you use. For example, I'd love to have:
-
foo/barpb
- Protobuf messages for packagefoo.bar
-
foo/twitchbarpb
- Twirp client/servers for packagefoo.bar
-
foo/grpcbarpb
- gRPC client/servers for packagefoo.bar
- I'm not sure if this is will be allowed with the newprotoc-gen-go-grpc
via https://github.com/protocolbuffers/protobuf-go/blob/master/compiler/protogen/protogen.go but we can leave this out of it -
foo/magicbarpb
- My custom magical RPC implementation (not in reality but as an example)
What this would require is protoc-gen-twirp
recognizing when it was generating code in a different package than the package of the golang/protobuf generated code, and then generating imports, ie:
// all shorthand, not even importing context
import barpb "github.com/alice/bob/foo/barpb"
type EchoService interface {
Echo(context.Context, *barpb.EchoRequest) (*barpb.EchoResponse, error)
}
This might be able to be implemented with some combination of the Mkey=value
(which would be annoying), import_path
, and import_prefix
options, but honestly it would be so much easier if there was just a definition_path=github.com/alice/bob/foo/barpb
option or something similar to just denote this easily. There are Golang Protobuf plugin libraries that handle this kind of behavior, so there's a lot of work to pattern off of.
Thoughts?