Skip to content

protoc-gen-go-grpc support split single proto file gen to diffrent package #8233

Closed as not planned
@qianlongzt

Description

@qianlongzt

Use case(s) - what problem will this feature solve?

opentelemetry-go1 supports protobuf over gRPC and over HTTP, but its proto file defines both the service and related messages in the same file.
When using protobuf over HTTP, it's necessary to remove the gRPC dependency to reduce the binary size.

Proposed Solution

Add an option to rename grpc file.GoImportPath 5

-	g := gen.NewGeneratedFile(filename, file.GoImportPath)
+	path := file.GoImportPath
+ 	if n, ok := rename[file.Desc.Path()]; ok {
+ 		path = n
+	}
+	g := gen.NewGeneratedFile(filename, path)
-grpc_rename log.proto=github.com/aaa/bbb/xxx -grpc_rename trace.proto=github.com/aaa/bbb/yyy

Alternatives Considered

  1. opentelemetry-proto split proto file
  2. opentelemetry-proto-go add same shim file Feat split grpc again open-telemetry/opentelemetry-proto-go#248

Additional Context

open-telemetry/opentelemetry-go#2579

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions