@@ -178,13 +178,8 @@ func generateFileContent(gen *protogen.Plugin, file *protogen.File, g *protogen.
178178
179179 g .P ("// This is a compile-time assertion to ensure that this generated file" )
180180 g .P ("// is compatible with the grpc package it is being compiled against." )
181- if * useGenericStreams {
182- g .P ("// Requires gRPC-Go v1.64.0 or later." )
183- g .P ("const _ = " , grpcPackage .Ident ("SupportPackageIsVersion9" ))
184- } else {
185- g .P ("// Requires gRPC-Go v1.62.0 or later." )
186- g .P ("const _ = " , grpcPackage .Ident ("SupportPackageIsVersion8" )) // When changing, update version number above.
187- }
181+ g .P ("// Requires gRPC-Go v1.64.0 or later." )
182+ g .P ("const _ = " , grpcPackage .Ident ("SupportPackageIsVersion9" ))
188183 g .P ()
189184 for _ , service := range file .Services {
190185 genService (gen , file , g , service )
@@ -333,11 +328,7 @@ func clientSignature(g *protogen.GeneratedFile, method *protogen.Method) string
333328 if ! method .Desc .IsStreamingClient () && ! method .Desc .IsStreamingServer () {
334329 s += "*" + g .QualifiedGoIdent (method .Output .GoIdent )
335330 } else {
336- if * useGenericStreams {
337- s += clientStreamInterface (g , method )
338- } else {
339- s += method .Parent .GoName + "_" + method .GoName + "Client"
340- }
331+ s += clientStreamInterface (g , method )
341332 }
342333 s += ", error)"
343334 return s
@@ -373,11 +364,8 @@ func genClientMethod(_ *protogen.Plugin, _ *protogen.File, g *protogen.Generated
373364 return
374365 }
375366
376- streamImpl := unexport (service .GoName ) + method .GoName + "Client"
377- if * useGenericStreams {
378- typeParam := g .QualifiedGoIdent (method .Input .GoIdent ) + ", " + g .QualifiedGoIdent (method .Output .GoIdent )
379- streamImpl = g .QualifiedGoIdent (grpcPackage .Ident ("GenericClientStream" )) + "[" + typeParam + "]"
380- }
367+ typeParam := g .QualifiedGoIdent (method .Input .GoIdent ) + ", " + g .QualifiedGoIdent (method .Output .GoIdent )
368+ streamImpl := g .QualifiedGoIdent (grpcPackage .Ident ("GenericClientStream" )) + "[" + typeParam + "]"
381369
382370 serviceDescVar := service .GoName + "_ServiceDesc"
383371 g .P ("stream, err := c.cc.NewStream(ctx, &" , serviceDescVar , ".Streams[" , index , `], ` , fmSymbol , `, cOpts...)` )
@@ -392,61 +380,9 @@ func genClientMethod(_ *protogen.Plugin, _ *protogen.File, g *protogen.Generated
392380 g .P ()
393381
394382 // Auxiliary types aliases, for backwards compatibility.
395- if * useGenericStreams {
396- g .P ("// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name." )
397- g .P ("type " , service .GoName , "_" , method .GoName , "Client = " , clientStreamInterface (g , method ))
398- g .P ()
399- return
400- }
401-
402- // Stream auxiliary types and methods, if we're not taking advantage of the
403- // pre-implemented generic types and their methods.
404- genSend := method .Desc .IsStreamingClient ()
405- genRecv := method .Desc .IsStreamingServer ()
406- genCloseAndRecv := ! method .Desc .IsStreamingServer ()
407-
408- g .P ("type " , service .GoName , "_" , method .GoName , "Client interface {" )
409- if genSend {
410- g .P ("Send(*" , method .Input .GoIdent , ") error" )
411- }
412- if genRecv {
413- g .P ("Recv() (*" , method .Output .GoIdent , ", error)" )
414- }
415- if genCloseAndRecv {
416- g .P ("CloseAndRecv() (*" , method .Output .GoIdent , ", error)" )
417- }
418- g .P (grpcPackage .Ident ("ClientStream" ))
419- g .P ("}" )
383+ g .P ("// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name." )
384+ g .P ("type " , service .GoName , "_" , method .GoName , "Client = " , clientStreamInterface (g , method ))
420385 g .P ()
421-
422- g .P ("type " , streamImpl , " struct {" )
423- g .P (grpcPackage .Ident ("ClientStream" ))
424- g .P ("}" )
425- g .P ()
426-
427- if genSend {
428- g .P ("func (x *" , streamImpl , ") Send(m *" , method .Input .GoIdent , ") error {" )
429- g .P ("return x.ClientStream.SendMsg(m)" )
430- g .P ("}" )
431- g .P ()
432- }
433- if genRecv {
434- g .P ("func (x *" , streamImpl , ") Recv() (*" , method .Output .GoIdent , ", error) {" )
435- g .P ("m := new(" , method .Output .GoIdent , ")" )
436- g .P ("if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err }" )
437- g .P ("return m, nil" )
438- g .P ("}" )
439- g .P ()
440- }
441- if genCloseAndRecv {
442- g .P ("func (x *" , streamImpl , ") CloseAndRecv() (*" , method .Output .GoIdent , ", error) {" )
443- g .P ("if err := x.ClientStream.CloseSend(); err != nil { return nil, err }" )
444- g .P ("m := new(" , method .Output .GoIdent , ")" )
445- g .P ("if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err }" )
446- g .P ("return m, nil" )
447- g .P ("}" )
448- g .P ()
449- }
450386}
451387
452388func serverSignature (g * protogen.GeneratedFile , method * protogen.Method ) string {
@@ -460,11 +396,7 @@ func serverSignature(g *protogen.GeneratedFile, method *protogen.Method) string
460396 reqArgs = append (reqArgs , "*" + g .QualifiedGoIdent (method .Input .GoIdent ))
461397 }
462398 if method .Desc .IsStreamingClient () || method .Desc .IsStreamingServer () {
463- if * useGenericStreams {
464- reqArgs = append (reqArgs , serverStreamInterface (g , method ))
465- } else {
466- reqArgs = append (reqArgs , method .Parent .GoName + "_" + method .GoName + "Server" )
467- }
399+ reqArgs = append (reqArgs , serverStreamInterface (g , method ))
468400 }
469401 return method .GoName + "(" + strings .Join (reqArgs , ", " ) + ") " + ret
470402}
@@ -545,11 +477,8 @@ func genServerMethod(_ *protogen.Plugin, _ *protogen.File, g *protogen.Generated
545477 return hname
546478 }
547479
548- streamImpl := unexport (service .GoName ) + method .GoName + "Server"
549- if * useGenericStreams {
550- typeParam := g .QualifiedGoIdent (method .Input .GoIdent ) + ", " + g .QualifiedGoIdent (method .Output .GoIdent )
551- streamImpl = g .QualifiedGoIdent (grpcPackage .Ident ("GenericServerStream" )) + "[" + typeParam + "]"
552- }
480+ typeParam := g .QualifiedGoIdent (method .Input .GoIdent ) + ", " + g .QualifiedGoIdent (method .Output .GoIdent )
481+ streamImpl := g .QualifiedGoIdent (grpcPackage .Ident ("GenericServerStream" )) + "[" + typeParam + "]"
553482
554483 g .P ("func " , hnameFuncNameFormatter (hname ), "(srv interface{}, stream " , grpcPackage .Ident ("ServerStream" ), ") error {" )
555484 if ! method .Desc .IsStreamingClient () {
@@ -563,59 +492,9 @@ func genServerMethod(_ *protogen.Plugin, _ *protogen.File, g *protogen.Generated
563492 g .P ()
564493
565494 // Auxiliary types aliases, for backwards compatibility.
566- if * useGenericStreams {
567- g .P ("// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name." )
568- g .P ("type " , service .GoName , "_" , method .GoName , "Server = " , serverStreamInterface (g , method ))
569- g .P ()
570- return hname
571- }
572-
573- // Stream auxiliary types and methods, if we're not taking advantage of the
574- // pre-implemented generic types and their methods.
575- genSend := method .Desc .IsStreamingServer ()
576- genSendAndClose := ! method .Desc .IsStreamingServer ()
577- genRecv := method .Desc .IsStreamingClient ()
578-
579- g .P ("type " , service .GoName , "_" , method .GoName , "Server interface {" )
580- if genSend {
581- g .P ("Send(*" , method .Output .GoIdent , ") error" )
582- }
583- if genSendAndClose {
584- g .P ("SendAndClose(*" , method .Output .GoIdent , ") error" )
585- }
586- if genRecv {
587- g .P ("Recv() (*" , method .Input .GoIdent , ", error)" )
588- }
589- g .P (grpcPackage .Ident ("ServerStream" ))
590- g .P ("}" )
591- g .P ()
592-
593- g .P ("type " , streamImpl , " struct {" )
594- g .P (grpcPackage .Ident ("ServerStream" ))
595- g .P ("}" )
495+ g .P ("// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name." )
496+ g .P ("type " , service .GoName , "_" , method .GoName , "Server = " , serverStreamInterface (g , method ))
596497 g .P ()
597-
598- if genSend {
599- g .P ("func (x *" , streamImpl , ") Send(m *" , method .Output .GoIdent , ") error {" )
600- g .P ("return x.ServerStream.SendMsg(m)" )
601- g .P ("}" )
602- g .P ()
603- }
604- if genSendAndClose {
605- g .P ("func (x *" , streamImpl , ") SendAndClose(m *" , method .Output .GoIdent , ") error {" )
606- g .P ("return x.ServerStream.SendMsg(m)" )
607- g .P ("}" )
608- g .P ()
609- }
610- if genRecv {
611- g .P ("func (x *" , streamImpl , ") Recv() (*" , method .Input .GoIdent , ", error) {" )
612- g .P ("m := new(" , method .Input .GoIdent , ")" )
613- g .P ("if err := x.ServerStream.RecvMsg(m); err != nil { return nil, err }" )
614- g .P ("return m, nil" )
615- g .P ("}" )
616- g .P ()
617- }
618-
619498 return hname
620499}
621500
0 commit comments