这个特定的函数是如何从这个 .proto 文件生成代码的?
How does this particular function come into being as a result of generating code from this .proto file?
(我相信这个问题主要是关于协议缓冲区,而不是 gRPC,但我可能是错的。)
有一个 .proto
文件作为 Helm 项目的一部分存在:https://github.com/kubernetes/helm/blob/v2.5.0/_proto/hapi/rudder/rudder.proto
作为 Helm 构建过程的一部分,这里生成了一个 Go 绑定(他们签入了它,但它是生成的,即没有以任何方式手工编辑):https://github.com/kubernetes/helm/blob/v2.5.0/pkg/proto/hapi/rudder/rudder.pb.go
我对这个函数有疑问:https://github.com/kubernetes/helm/blob/v2.5.0/pkg/proto/hapi/rudder/rudder.pb.go#L536
在给定上述 .proto
文件的情况下,该函数是如何产生的?
对于背景,我已经完成了 Java 等价(generated bindings in Java instead of Go, off the same .proto
files). You can see the pom.xml
section that does this here if it matters: https://github.com/microbean/microbean-helm/blob/microbean-helm-2.5.0.0/pom.xml#L290-L310 为什么不生成类似的 Java 方法,因为我正在生成相同的源, 使用基本相同的配方?
快速搜索可在此处找到这些字符串文字:https://github.com/golang/protobuf/blob/master/protoc-gen-go/grpc/grpc.go#L214
"打包grpc在Go代码中输出gRPC服务描述。
它作为 Go 协议缓冲区编译器插件的插件运行。"
本次代码生成是通过protoc编译器、protoc的Go插件以及该插件的gRPC模式共同调用的。参见 https://github.com/grpc/grpc-go/tree/master/examples。
gRPC Java API 只是略有不同。而不是调用:
rudder.RegisterReleaseModuleServiceServer(myGrpcServer, myReleaseModuleService)
您在 io.grpc.ServerBuilder
上调用了一个方法:
ServerBuilder sb = myGrpcServerBuilder.addService(myReleaseModuleService);
生成的代码implements BindableService
,构建器使用它来配置服务。
(我相信这个问题主要是关于协议缓冲区,而不是 gRPC,但我可能是错的。)
有一个 .proto
文件作为 Helm 项目的一部分存在:https://github.com/kubernetes/helm/blob/v2.5.0/_proto/hapi/rudder/rudder.proto
作为 Helm 构建过程的一部分,这里生成了一个 Go 绑定(他们签入了它,但它是生成的,即没有以任何方式手工编辑):https://github.com/kubernetes/helm/blob/v2.5.0/pkg/proto/hapi/rudder/rudder.pb.go
我对这个函数有疑问:https://github.com/kubernetes/helm/blob/v2.5.0/pkg/proto/hapi/rudder/rudder.pb.go#L536
在给定上述 .proto
文件的情况下,该函数是如何产生的?
对于背景,我已经完成了 Java 等价(generated bindings in Java instead of Go, off the same .proto
files). You can see the pom.xml
section that does this here if it matters: https://github.com/microbean/microbean-helm/blob/microbean-helm-2.5.0.0/pom.xml#L290-L310 为什么不生成类似的 Java 方法,因为我正在生成相同的源, 使用基本相同的配方?
快速搜索可在此处找到这些字符串文字:https://github.com/golang/protobuf/blob/master/protoc-gen-go/grpc/grpc.go#L214
"打包grpc在Go代码中输出gRPC服务描述。 它作为 Go 协议缓冲区编译器插件的插件运行。"
本次代码生成是通过protoc编译器、protoc的Go插件以及该插件的gRPC模式共同调用的。参见 https://github.com/grpc/grpc-go/tree/master/examples。
gRPC Java API 只是略有不同。而不是调用:
rudder.RegisterReleaseModuleServiceServer(myGrpcServer, myReleaseModuleService)
您在 io.grpc.ServerBuilder
上调用了一个方法:
ServerBuilder sb = myGrpcServerBuilder.addService(myReleaseModuleService);
生成的代码implements BindableService
,构建器使用它来配置服务。