mirror of
https://github.com/crazy-max/diun.git
synced 2025-12-24 14:31:47 +01:00
chore(deps): bump google.golang.org/grpc/cmd/protoc-gen-go-grpc
Bumps [google.golang.org/grpc/cmd/protoc-gen-go-grpc](https://github.com/grpc/grpc-go) from 1.3.0 to 1.5.1. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.3.0...v1.5.1) --- updated-dependencies: - dependency-name: google.golang.org/grpc/cmd/protoc-gen-go-grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
2
go.mod
2
go.mod
@@ -44,7 +44,7 @@ require (
|
||||
golang.org/x/mod v0.21.0
|
||||
golang.org/x/sys v0.28.0
|
||||
google.golang.org/grpc v1.67.0
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1
|
||||
google.golang.org/protobuf v1.35.2
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
k8s.io/api v0.29.3
|
||||
|
||||
4
go.sum
4
go.sum
@@ -443,8 +443,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
|
||||
google.golang.org/grpc v1.67.0 h1:IdH9y6PF5MPSdAntIcpjQ+tXO41pcQsfZV2RxtQgVcw=
|
||||
google.golang.org/grpc v1.67.0/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0 h1:rNBFJjBCOgVr9pWD7rs/knKL4FRTKgpZmsRfV214zcA=
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0/go.mod h1:Dk1tviKTvMCz5tvh7t+fh94dhmQVHuCt2OzJB3CTW9Y=
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 h1:F29+wU6Ee6qgu9TddPgooOdaqsxTMunOoj8KA5yuS5A=
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1/go.mod h1:5KF+wpkbTSbGcR9zteSqZV6fqFOWBl4Yde8En8MryZA=
|
||||
google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io=
|
||||
google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
|
||||
|
||||
11
vendor/google.golang.org/grpc/cmd/protoc-gen-go-grpc/README.md
generated
vendored
11
vendor/google.golang.org/grpc/cmd/protoc-gen-go-grpc/README.md
generated
vendored
@@ -13,9 +13,16 @@ change from the grpc code generator previously included with `protoc-gen-go`.
|
||||
To restore this behavior, set the option `require_unimplemented_servers=false`.
|
||||
E.g.:
|
||||
|
||||
```
|
||||
protoc --go-grpc_out=require_unimplemented_servers=false[,other options...]:. \
|
||||
```sh
|
||||
protoc --go-grpc_out=. --go-grpc_opt=require_unimplemented_servers=false[,other options...] \
|
||||
```
|
||||
|
||||
Note that this is not recommended, and the option is only provided to restore
|
||||
backward compatibility with previously-generated code.
|
||||
|
||||
When embedding the `Unimplemented<ServiceName>Server` in a struct that
|
||||
implements the service, it should be embedded by _value_ instead of as a
|
||||
_pointer_. If it is embedded as a pointer, it must be assigned to a valid,
|
||||
non-nil pointer or else unimplemented methods would panic when called. This is
|
||||
tested at service registration time, and will lead to a panic in
|
||||
`Register<ServiceName>Server` if it is not embedded properly.
|
||||
|
||||
157
vendor/google.golang.org/grpc/cmd/protoc-gen-go-grpc/grpc.go
generated
vendored
157
vendor/google.golang.org/grpc/cmd/protoc-gen-go-grpc/grpc.go
generated
vendored
@@ -52,6 +52,10 @@ func (serviceGenerateHelper) formatFullMethodSymbol(service *protogen.Service, m
|
||||
}
|
||||
|
||||
func (serviceGenerateHelper) genFullMethods(g *protogen.GeneratedFile, service *protogen.Service) {
|
||||
if len(service.Methods) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
g.P("const (")
|
||||
for _, method := range service.Methods {
|
||||
fmSymbol := helper.formatFullMethodSymbol(service, method)
|
||||
@@ -80,9 +84,12 @@ func (serviceGenerateHelper) generateUnimplementedServerType(gen *protogen.Plugi
|
||||
mustOrShould = "should"
|
||||
}
|
||||
// Server Unimplemented struct for forward compatibility.
|
||||
g.P("// Unimplemented", serverType, " ", mustOrShould, " be embedded to have forward compatible implementations.")
|
||||
g.P("type Unimplemented", serverType, " struct {")
|
||||
g.P("}")
|
||||
g.P("// Unimplemented", serverType, " ", mustOrShould, " be embedded to have")
|
||||
g.P("// forward compatible implementations.")
|
||||
g.P("//")
|
||||
g.P("// NOTE: this should be embedded by value instead of pointer to avoid a nil")
|
||||
g.P("// pointer dereference when methods are called.")
|
||||
g.P("type Unimplemented", serverType, " struct {}")
|
||||
g.P()
|
||||
for _, method := range service.Methods {
|
||||
nilArg := ""
|
||||
@@ -96,6 +103,7 @@ func (serviceGenerateHelper) generateUnimplementedServerType(gen *protogen.Plugi
|
||||
if *requireUnimplemented {
|
||||
g.P("func (Unimplemented", serverType, ") mustEmbedUnimplemented", serverType, "() {}")
|
||||
}
|
||||
g.P("func (Unimplemented", serverType, ") testEmbeddedByValue() {}")
|
||||
g.P()
|
||||
}
|
||||
|
||||
@@ -170,14 +178,30 @@ func generateFileContent(gen *protogen.Plugin, file *protogen.File, g *protogen.
|
||||
|
||||
g.P("// This is a compile-time assertion to ensure that this generated file")
|
||||
g.P("// is compatible with the grpc package it is being compiled against.")
|
||||
g.P("// Requires gRPC-Go v1.32.0 or later.")
|
||||
g.P("const _ = ", grpcPackage.Ident("SupportPackageIsVersion7")) // When changing, update version number above.
|
||||
if *useGenericStreams {
|
||||
g.P("// Requires gRPC-Go v1.64.0 or later.")
|
||||
g.P("const _ = ", grpcPackage.Ident("SupportPackageIsVersion9"))
|
||||
} else {
|
||||
g.P("// Requires gRPC-Go v1.62.0 or later.")
|
||||
g.P("const _ = ", grpcPackage.Ident("SupportPackageIsVersion8")) // When changing, update version number above.
|
||||
}
|
||||
g.P()
|
||||
for _, service := range file.Services {
|
||||
genService(gen, file, g, service)
|
||||
}
|
||||
}
|
||||
|
||||
// genServiceComments copies the comments from the RPC proto definitions
|
||||
// to the corresponding generated interface file.
|
||||
func genServiceComments(g *protogen.GeneratedFile, service *protogen.Service) {
|
||||
if service.Comments.Leading != "" {
|
||||
// Add empty comment line to attach this service's comments to
|
||||
// the godoc comments previously output for all services.
|
||||
g.P("//")
|
||||
g.P(strings.TrimSpace(service.Comments.Leading.String()))
|
||||
}
|
||||
}
|
||||
|
||||
func genService(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, service *protogen.Service) {
|
||||
// Full methods constants.
|
||||
helper.genFullMethods(g, service)
|
||||
@@ -189,14 +213,17 @@ func genService(gen *protogen.Plugin, file *protogen.File, g *protogen.Generated
|
||||
g.P("//")
|
||||
g.P("// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.")
|
||||
|
||||
// Copy comments from proto file.
|
||||
genServiceComments(g, service)
|
||||
|
||||
if service.Desc.Options().(*descriptorpb.ServiceOptions).GetDeprecated() {
|
||||
g.P("//")
|
||||
g.P(deprecationComment)
|
||||
}
|
||||
g.Annotate(clientName, service.Location)
|
||||
g.AnnotateSymbol(clientName, protogen.Annotation{Location: service.Location})
|
||||
g.P("type ", clientName, " interface {")
|
||||
for _, method := range service.Methods {
|
||||
g.Annotate(clientName+"."+method.GoName, method.Location)
|
||||
g.AnnotateSymbol(clientName+"."+method.GoName, protogen.Annotation{Location: method.Location})
|
||||
if method.Desc.Options().(*descriptorpb.MethodOptions).GetDeprecated() {
|
||||
g.P(deprecationComment)
|
||||
}
|
||||
@@ -241,15 +268,19 @@ func genService(gen *protogen.Plugin, file *protogen.File, g *protogen.Generated
|
||||
serverType := service.GoName + "Server"
|
||||
g.P("// ", serverType, " is the server API for ", service.GoName, " service.")
|
||||
g.P("// All implementations ", mustOrShould, " embed Unimplemented", serverType)
|
||||
g.P("// for forward compatibility")
|
||||
g.P("// for forward compatibility.")
|
||||
|
||||
// Copy comments from proto file.
|
||||
genServiceComments(g, service)
|
||||
|
||||
if service.Desc.Options().(*descriptorpb.ServiceOptions).GetDeprecated() {
|
||||
g.P("//")
|
||||
g.P(deprecationComment)
|
||||
}
|
||||
g.Annotate(serverType, service.Location)
|
||||
g.AnnotateSymbol(serverType, protogen.Annotation{Location: service.Location})
|
||||
g.P("type ", serverType, " interface {")
|
||||
for _, method := range service.Methods {
|
||||
g.Annotate(serverType+"."+method.GoName, method.Location)
|
||||
g.AnnotateSymbol(serverType+"."+method.GoName, protogen.Annotation{Location: method.Location})
|
||||
if method.Desc.Options().(*descriptorpb.MethodOptions).GetDeprecated() {
|
||||
g.P(deprecationComment)
|
||||
}
|
||||
@@ -279,6 +310,13 @@ func genService(gen *protogen.Plugin, file *protogen.File, g *protogen.Generated
|
||||
}
|
||||
serviceDescVar := service.GoName + "_ServiceDesc"
|
||||
g.P("func Register", service.GoName, "Server(s ", grpcPackage.Ident("ServiceRegistrar"), ", srv ", serverType, ") {")
|
||||
g.P("// If the following call pancis, it indicates Unimplemented", serverType, " was")
|
||||
g.P("// embedded by pointer and is nil. This will cause panics if an")
|
||||
g.P("// unimplemented method is ever invoked, so we test this at initialization")
|
||||
g.P("// time to prevent it from happening at runtime later due to I/O.")
|
||||
g.P("if t, ok := srv.(interface { testEmbeddedByValue() }); ok {")
|
||||
g.P("t.testEmbeddedByValue()")
|
||||
g.P("}")
|
||||
g.P("s.RegisterService(&", serviceDescVar, `, srv)`)
|
||||
g.P("}")
|
||||
g.P()
|
||||
@@ -295,12 +333,27 @@ func clientSignature(g *protogen.GeneratedFile, method *protogen.Method) string
|
||||
if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
|
||||
s += "*" + g.QualifiedGoIdent(method.Output.GoIdent)
|
||||
} else {
|
||||
s += method.Parent.GoName + "_" + method.GoName + "Client"
|
||||
if *useGenericStreams {
|
||||
s += clientStreamInterface(g, method)
|
||||
} else {
|
||||
s += method.Parent.GoName + "_" + method.GoName + "Client"
|
||||
}
|
||||
}
|
||||
s += ", error)"
|
||||
return s
|
||||
}
|
||||
|
||||
func clientStreamInterface(g *protogen.GeneratedFile, method *protogen.Method) string {
|
||||
typeParam := g.QualifiedGoIdent(method.Input.GoIdent) + ", " + g.QualifiedGoIdent(method.Output.GoIdent)
|
||||
if method.Desc.IsStreamingClient() && method.Desc.IsStreamingServer() {
|
||||
return g.QualifiedGoIdent(grpcPackage.Ident("BidiStreamingClient")) + "[" + typeParam + "]"
|
||||
} else if method.Desc.IsStreamingClient() {
|
||||
return g.QualifiedGoIdent(grpcPackage.Ident("ClientStreamingClient")) + "[" + typeParam + "]"
|
||||
} else { // i.e. if method.Desc.IsStreamingServer()
|
||||
return g.QualifiedGoIdent(grpcPackage.Ident("ServerStreamingClient")) + "[" + g.QualifiedGoIdent(method.Output.GoIdent) + "]"
|
||||
}
|
||||
}
|
||||
|
||||
func genClientMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, method *protogen.Method, index int) {
|
||||
service := method.Parent
|
||||
fmSymbol := helper.formatFullMethodSymbol(service, method)
|
||||
@@ -309,20 +362,27 @@ func genClientMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.Gene
|
||||
g.P(deprecationComment)
|
||||
}
|
||||
g.P("func (c *", unexport(service.GoName), "Client) ", clientSignature(g, method), "{")
|
||||
g.P("cOpts := append([]", grpcPackage.Ident("CallOption"), "{", grpcPackage.Ident("StaticMethod()"), "}, opts...)")
|
||||
if !method.Desc.IsStreamingServer() && !method.Desc.IsStreamingClient() {
|
||||
g.P("out := new(", method.Output.GoIdent, ")")
|
||||
g.P(`err := c.cc.Invoke(ctx, `, fmSymbol, `, in, out, opts...)`)
|
||||
g.P(`err := c.cc.Invoke(ctx, `, fmSymbol, `, in, out, cOpts...)`)
|
||||
g.P("if err != nil { return nil, err }")
|
||||
g.P("return out, nil")
|
||||
g.P("}")
|
||||
g.P()
|
||||
return
|
||||
}
|
||||
streamType := unexport(service.GoName) + method.GoName + "Client"
|
||||
|
||||
streamImpl := unexport(service.GoName) + method.GoName + "Client"
|
||||
if *useGenericStreams {
|
||||
typeParam := g.QualifiedGoIdent(method.Input.GoIdent) + ", " + g.QualifiedGoIdent(method.Output.GoIdent)
|
||||
streamImpl = g.QualifiedGoIdent(grpcPackage.Ident("GenericClientStream")) + "[" + typeParam + "]"
|
||||
}
|
||||
|
||||
serviceDescVar := service.GoName + "_ServiceDesc"
|
||||
g.P("stream, err := c.cc.NewStream(ctx, &", serviceDescVar, ".Streams[", index, `], `, fmSymbol, `, opts...)`)
|
||||
g.P("stream, err := c.cc.NewStream(ctx, &", serviceDescVar, ".Streams[", index, `], `, fmSymbol, `, cOpts...)`)
|
||||
g.P("if err != nil { return nil, err }")
|
||||
g.P("x := &", streamType, "{stream}")
|
||||
g.P("x := &", streamImpl, "{ClientStream: stream}")
|
||||
if !method.Desc.IsStreamingClient() {
|
||||
g.P("if err := x.ClientStream.SendMsg(in); err != nil { return nil, err }")
|
||||
g.P("if err := x.ClientStream.CloseSend(); err != nil { return nil, err }")
|
||||
@@ -331,11 +391,20 @@ func genClientMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.Gene
|
||||
g.P("}")
|
||||
g.P()
|
||||
|
||||
// Auxiliary types aliases, for backwards compatibility.
|
||||
if *useGenericStreams {
|
||||
g.P("// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.")
|
||||
g.P("type ", service.GoName, "_", method.GoName, "Client = ", clientStreamInterface(g, method))
|
||||
g.P()
|
||||
return
|
||||
}
|
||||
|
||||
// Stream auxiliary types and methods, if we're not taking advantage of the
|
||||
// pre-implemented generic types and their methods.
|
||||
genSend := method.Desc.IsStreamingClient()
|
||||
genRecv := method.Desc.IsStreamingServer()
|
||||
genCloseAndRecv := !method.Desc.IsStreamingServer()
|
||||
|
||||
// Stream auxiliary types and methods.
|
||||
g.P("type ", service.GoName, "_", method.GoName, "Client interface {")
|
||||
if genSend {
|
||||
g.P("Send(*", method.Input.GoIdent, ") error")
|
||||
@@ -350,19 +419,19 @@ func genClientMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.Gene
|
||||
g.P("}")
|
||||
g.P()
|
||||
|
||||
g.P("type ", streamType, " struct {")
|
||||
g.P("type ", streamImpl, " struct {")
|
||||
g.P(grpcPackage.Ident("ClientStream"))
|
||||
g.P("}")
|
||||
g.P()
|
||||
|
||||
if genSend {
|
||||
g.P("func (x *", streamType, ") Send(m *", method.Input.GoIdent, ") error {")
|
||||
g.P("func (x *", streamImpl, ") Send(m *", method.Input.GoIdent, ") error {")
|
||||
g.P("return x.ClientStream.SendMsg(m)")
|
||||
g.P("}")
|
||||
g.P()
|
||||
}
|
||||
if genRecv {
|
||||
g.P("func (x *", streamType, ") Recv() (*", method.Output.GoIdent, ", error) {")
|
||||
g.P("func (x *", streamImpl, ") Recv() (*", method.Output.GoIdent, ", error) {")
|
||||
g.P("m := new(", method.Output.GoIdent, ")")
|
||||
g.P("if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err }")
|
||||
g.P("return m, nil")
|
||||
@@ -370,7 +439,7 @@ func genClientMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.Gene
|
||||
g.P()
|
||||
}
|
||||
if genCloseAndRecv {
|
||||
g.P("func (x *", streamType, ") CloseAndRecv() (*", method.Output.GoIdent, ", error) {")
|
||||
g.P("func (x *", streamImpl, ") CloseAndRecv() (*", method.Output.GoIdent, ", error) {")
|
||||
g.P("if err := x.ClientStream.CloseSend(); err != nil { return nil, err }")
|
||||
g.P("m := new(", method.Output.GoIdent, ")")
|
||||
g.P("if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err }")
|
||||
@@ -391,7 +460,11 @@ func serverSignature(g *protogen.GeneratedFile, method *protogen.Method) string
|
||||
reqArgs = append(reqArgs, "*"+g.QualifiedGoIdent(method.Input.GoIdent))
|
||||
}
|
||||
if method.Desc.IsStreamingClient() || method.Desc.IsStreamingServer() {
|
||||
reqArgs = append(reqArgs, method.Parent.GoName+"_"+method.GoName+"Server")
|
||||
if *useGenericStreams {
|
||||
reqArgs = append(reqArgs, serverStreamInterface(g, method))
|
||||
} else {
|
||||
reqArgs = append(reqArgs, method.Parent.GoName+"_"+method.GoName+"Server")
|
||||
}
|
||||
}
|
||||
return method.GoName + "(" + strings.Join(reqArgs, ", ") + ") " + ret
|
||||
}
|
||||
@@ -437,6 +510,17 @@ func genServiceDesc(file *protogen.File, g *protogen.GeneratedFile, serviceDescV
|
||||
g.P()
|
||||
}
|
||||
|
||||
func serverStreamInterface(g *protogen.GeneratedFile, method *protogen.Method) string {
|
||||
typeParam := g.QualifiedGoIdent(method.Input.GoIdent) + ", " + g.QualifiedGoIdent(method.Output.GoIdent)
|
||||
if method.Desc.IsStreamingClient() && method.Desc.IsStreamingServer() {
|
||||
return g.QualifiedGoIdent(grpcPackage.Ident("BidiStreamingServer")) + "[" + typeParam + "]"
|
||||
} else if method.Desc.IsStreamingClient() {
|
||||
return g.QualifiedGoIdent(grpcPackage.Ident("ClientStreamingServer")) + "[" + typeParam + "]"
|
||||
} else { // i.e. if method.Desc.IsStreamingServer()
|
||||
return g.QualifiedGoIdent(grpcPackage.Ident("ServerStreamingServer")) + "[" + g.QualifiedGoIdent(method.Output.GoIdent) + "]"
|
||||
}
|
||||
}
|
||||
|
||||
func genServerMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, method *protogen.Method, hnameFuncNameFormatter func(string) string) string {
|
||||
service := method.Parent
|
||||
hname := fmt.Sprintf("_%s_%s_Handler", service.GoName, method.GoName)
|
||||
@@ -459,23 +543,38 @@ func genServerMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.Gene
|
||||
g.P()
|
||||
return hname
|
||||
}
|
||||
streamType := unexport(service.GoName) + method.GoName + "Server"
|
||||
|
||||
streamImpl := unexport(service.GoName) + method.GoName + "Server"
|
||||
if *useGenericStreams {
|
||||
typeParam := g.QualifiedGoIdent(method.Input.GoIdent) + ", " + g.QualifiedGoIdent(method.Output.GoIdent)
|
||||
streamImpl = g.QualifiedGoIdent(grpcPackage.Ident("GenericServerStream")) + "[" + typeParam + "]"
|
||||
}
|
||||
|
||||
g.P("func ", hnameFuncNameFormatter(hname), "(srv interface{}, stream ", grpcPackage.Ident("ServerStream"), ") error {")
|
||||
if !method.Desc.IsStreamingClient() {
|
||||
g.P("m := new(", method.Input.GoIdent, ")")
|
||||
g.P("if err := stream.RecvMsg(m); err != nil { return err }")
|
||||
g.P("return srv.(", service.GoName, "Server).", method.GoName, "(m, &", streamType, "{stream})")
|
||||
g.P("return srv.(", service.GoName, "Server).", method.GoName, "(m, &", streamImpl, "{ServerStream: stream})")
|
||||
} else {
|
||||
g.P("return srv.(", service.GoName, "Server).", method.GoName, "(&", streamType, "{stream})")
|
||||
g.P("return srv.(", service.GoName, "Server).", method.GoName, "(&", streamImpl, "{ServerStream: stream})")
|
||||
}
|
||||
g.P("}")
|
||||
g.P()
|
||||
|
||||
// Auxiliary types aliases, for backwards compatibility.
|
||||
if *useGenericStreams {
|
||||
g.P("// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.")
|
||||
g.P("type ", service.GoName, "_", method.GoName, "Server = ", serverStreamInterface(g, method))
|
||||
g.P()
|
||||
return hname
|
||||
}
|
||||
|
||||
// Stream auxiliary types and methods, if we're not taking advantage of the
|
||||
// pre-implemented generic types and their methods.
|
||||
genSend := method.Desc.IsStreamingServer()
|
||||
genSendAndClose := !method.Desc.IsStreamingServer()
|
||||
genRecv := method.Desc.IsStreamingClient()
|
||||
|
||||
// Stream auxiliary types and methods.
|
||||
g.P("type ", service.GoName, "_", method.GoName, "Server interface {")
|
||||
if genSend {
|
||||
g.P("Send(*", method.Output.GoIdent, ") error")
|
||||
@@ -490,25 +589,25 @@ func genServerMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.Gene
|
||||
g.P("}")
|
||||
g.P()
|
||||
|
||||
g.P("type ", streamType, " struct {")
|
||||
g.P("type ", streamImpl, " struct {")
|
||||
g.P(grpcPackage.Ident("ServerStream"))
|
||||
g.P("}")
|
||||
g.P()
|
||||
|
||||
if genSend {
|
||||
g.P("func (x *", streamType, ") Send(m *", method.Output.GoIdent, ") error {")
|
||||
g.P("func (x *", streamImpl, ") Send(m *", method.Output.GoIdent, ") error {")
|
||||
g.P("return x.ServerStream.SendMsg(m)")
|
||||
g.P("}")
|
||||
g.P()
|
||||
}
|
||||
if genSendAndClose {
|
||||
g.P("func (x *", streamType, ") SendAndClose(m *", method.Output.GoIdent, ") error {")
|
||||
g.P("func (x *", streamImpl, ") SendAndClose(m *", method.Output.GoIdent, ") error {")
|
||||
g.P("return x.ServerStream.SendMsg(m)")
|
||||
g.P("}")
|
||||
g.P()
|
||||
}
|
||||
if genRecv {
|
||||
g.P("func (x *", streamType, ") Recv() (*", method.Input.GoIdent, ", error) {")
|
||||
g.P("func (x *", streamImpl, ") Recv() (*", method.Input.GoIdent, ", error) {")
|
||||
g.P("m := new(", method.Input.GoIdent, ")")
|
||||
g.P("if err := x.ServerStream.RecvMsg(m); err != nil { return nil, err }")
|
||||
g.P("return m, nil")
|
||||
|
||||
9
vendor/google.golang.org/grpc/cmd/protoc-gen-go-grpc/main.go
generated
vendored
9
vendor/google.golang.org/grpc/cmd/protoc-gen-go-grpc/main.go
generated
vendored
@@ -38,12 +38,14 @@ import (
|
||||
"fmt"
|
||||
|
||||
"google.golang.org/protobuf/compiler/protogen"
|
||||
"google.golang.org/protobuf/types/descriptorpb"
|
||||
"google.golang.org/protobuf/types/pluginpb"
|
||||
)
|
||||
|
||||
const version = "1.3.0"
|
||||
const version = "1.5.1"
|
||||
|
||||
var requireUnimplemented *bool
|
||||
var useGenericStreams *bool
|
||||
|
||||
func main() {
|
||||
showVersion := flag.Bool("version", false, "print the version and exit")
|
||||
@@ -55,11 +57,14 @@ func main() {
|
||||
|
||||
var flags flag.FlagSet
|
||||
requireUnimplemented = flags.Bool("require_unimplemented_servers", true, "set to false to match legacy behavior")
|
||||
useGenericStreams = flags.Bool("use_generic_streams_experimental", true, "set to true to use generic types for streaming client and server objects; this flag is EXPERIMENTAL and may be changed or removed in a future release")
|
||||
|
||||
protogen.Options{
|
||||
ParamFunc: flags.Set,
|
||||
}.Run(func(gen *protogen.Plugin) error {
|
||||
gen.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)
|
||||
gen.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL) | uint64(pluginpb.CodeGeneratorResponse_FEATURE_SUPPORTS_EDITIONS)
|
||||
gen.SupportedEditionsMinimum = descriptorpb.Edition_EDITION_PROTO2
|
||||
gen.SupportedEditionsMaximum = descriptorpb.Edition_EDITION_2023
|
||||
for _, f := range gen.Files {
|
||||
if !f.Generate {
|
||||
continue
|
||||
|
||||
50
vendor/google.golang.org/grpc/cmd/protoc-gen-go-grpc/protoc-gen-go-grpc_test.sh
generated
vendored
Normal file
50
vendor/google.golang.org/grpc/cmd/protoc-gen-go-grpc/protoc-gen-go-grpc_test.sh
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
# Copyright 2024 gRPC authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Uncomment to enable debugging.
|
||||
# set -x
|
||||
|
||||
WORKDIR="$(dirname $0)"
|
||||
TEMPDIR=$(mktemp -d)
|
||||
|
||||
trap "rm -rf ${TEMPDIR}" EXIT
|
||||
|
||||
# Build protoc-gen-go-grpc binary and add to $PATH.
|
||||
pushd "${WORKDIR}"
|
||||
go build -o "${TEMPDIR}" .
|
||||
PATH="${TEMPDIR}:${PATH}"
|
||||
popd
|
||||
|
||||
protoc \
|
||||
--go-grpc_out="${TEMPDIR}" \
|
||||
--go-grpc_opt=paths=source_relative,use_generic_streams_experimental=true \
|
||||
"examples/route_guide/routeguide/route_guide.proto"
|
||||
|
||||
GOLDENFILE="examples/route_guide/routeguide/route_guide_grpc.pb.go"
|
||||
GENFILE="${TEMPDIR}/examples/route_guide/routeguide/route_guide_grpc.pb.go"
|
||||
|
||||
# diff is piped to [[ $? == 1 ]] to avoid exiting on diff but exit on error
|
||||
# (like if the file was not found). See man diff for more info.
|
||||
DIFF=$(diff "${GOLDENFILE}" "${GENFILE}" || [[ $? == 1 ]])
|
||||
if [[ -n "${DIFF}" ]]; then
|
||||
echo -e "ERROR: Generated file differs from golden file:\n${DIFF}"
|
||||
echo -e "If you have made recent changes to protoc-gen-go-grpc," \
|
||||
"please regenerate the golden files by running:" \
|
||||
"\n\t go generate google.golang.org/grpc/..." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo SUCCESS
|
||||
4
vendor/modules.txt
vendored
4
vendor/modules.txt
vendored
@@ -586,8 +586,8 @@ google.golang.org/grpc/serviceconfig
|
||||
google.golang.org/grpc/stats
|
||||
google.golang.org/grpc/status
|
||||
google.golang.org/grpc/tap
|
||||
# google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0
|
||||
## explicit; go 1.17
|
||||
# google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1
|
||||
## explicit; go 1.21
|
||||
google.golang.org/grpc/cmd/protoc-gen-go-grpc
|
||||
# google.golang.org/protobuf v1.35.2
|
||||
## explicit; go 1.21
|
||||
|
||||
Reference in New Issue
Block a user