@@ -178,13 +178,8 @@ func generateFileContent(gen *protogen.Plugin, file *protogen.File, g *protogen.
178
178
179
179
g .P ("// This is a compile-time assertion to ensure that this generated file" )
180
180
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" ))
188
183
g .P ()
189
184
for _ , service := range file .Services {
190
185
genService (gen , file , g , service )
@@ -333,11 +328,7 @@ func clientSignature(g *protogen.GeneratedFile, method *protogen.Method) string
333
328
if ! method .Desc .IsStreamingClient () && ! method .Desc .IsStreamingServer () {
334
329
s += "*" + g .QualifiedGoIdent (method .Output .GoIdent )
335
330
} 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 )
341
332
}
342
333
s += ", error)"
343
334
return s
@@ -373,11 +364,8 @@ func genClientMethod(_ *protogen.Plugin, _ *protogen.File, g *protogen.Generated
373
364
return
374
365
}
375
366
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 + "]"
381
369
382
370
serviceDescVar := service .GoName + "_ServiceDesc"
383
371
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
392
380
g .P ()
393
381
394
382
// 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 ))
420
385
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
- }
450
386
}
451
387
452
388
func serverSignature (g * protogen.GeneratedFile , method * protogen.Method ) string {
@@ -460,11 +396,7 @@ func serverSignature(g *protogen.GeneratedFile, method *protogen.Method) string
460
396
reqArgs = append (reqArgs , "*" + g .QualifiedGoIdent (method .Input .GoIdent ))
461
397
}
462
398
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 ))
468
400
}
469
401
return method .GoName + "(" + strings .Join (reqArgs , ", " ) + ") " + ret
470
402
}
@@ -545,11 +477,8 @@ func genServerMethod(_ *protogen.Plugin, _ *protogen.File, g *protogen.Generated
545
477
return hname
546
478
}
547
479
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 + "]"
553
482
554
483
g .P ("func " , hnameFuncNameFormatter (hname ), "(srv interface{}, stream " , grpcPackage .Ident ("ServerStream" ), ") error {" )
555
484
if ! method .Desc .IsStreamingClient () {
@@ -563,59 +492,9 @@ func genServerMethod(_ *protogen.Plugin, _ *protogen.File, g *protogen.Generated
563
492
g .P ()
564
493
565
494
// 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 ))
596
497
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
-
619
498
return hname
620
499
}
621
500
0 commit comments