go.uber.org/yarpc@v1.72.1/internal/prototest/examplepb/example.pb.yarpc.go (about) 1 // Code generated by protoc-gen-yarpc-go. DO NOT EDIT. 2 // source: internal/prototest/examplepb/example.proto 3 4 // Copyright (c) 2022 Uber Technologies, Inc. 5 // 6 // Permission is hereby granted, free of charge, to any person obtaining a copy 7 // of this software and associated documentation files (the "Software"), to deal 8 // in the Software without restriction, including without limitation the rights 9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 // copies of the Software, and to permit persons to whom the Software is 11 // furnished to do so, subject to the following conditions: 12 // 13 // The above copyright notice and this permission notice shall be included in 14 // all copies or substantial portions of the Software. 15 // 16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 // THE SOFTWARE. 23 24 package examplepb 25 26 import ( 27 "context" 28 "io/ioutil" 29 "reflect" 30 31 "github.com/gogo/protobuf/jsonpb" 32 "github.com/gogo/protobuf/proto" 33 "go.uber.org/fx" 34 "go.uber.org/yarpc" 35 "go.uber.org/yarpc/api/transport" 36 "go.uber.org/yarpc/api/x/restriction" 37 "go.uber.org/yarpc/encoding/protobuf" 38 "go.uber.org/yarpc/encoding/protobuf/reflection" 39 ) 40 41 var _ = ioutil.NopCloser 42 43 // KeyValueYARPCClient is the YARPC client-side interface for the KeyValue service. 44 type KeyValueYARPCClient interface { 45 GetValue(context.Context, *GetValueRequest, ...yarpc.CallOption) (*GetValueResponse, error) 46 SetValue(context.Context, *SetValueRequest, ...yarpc.CallOption) (*SetValueResponse, error) 47 } 48 49 func newKeyValueYARPCClient(clientConfig transport.ClientConfig, anyResolver jsonpb.AnyResolver, options ...protobuf.ClientOption) KeyValueYARPCClient { 50 return &_KeyValueYARPCCaller{protobuf.NewStreamClient( 51 protobuf.ClientParams{ 52 ServiceName: "uber.yarpc.internal.examples.protobuf.example.KeyValue", 53 ClientConfig: clientConfig, 54 AnyResolver: anyResolver, 55 Options: options, 56 }, 57 )} 58 } 59 60 // NewKeyValueYARPCClient builds a new YARPC client for the KeyValue service. 61 func NewKeyValueYARPCClient(clientConfig transport.ClientConfig, options ...protobuf.ClientOption) KeyValueYARPCClient { 62 return newKeyValueYARPCClient(clientConfig, nil, options...) 63 } 64 65 // KeyValueYARPCServer is the YARPC server-side interface for the KeyValue service. 66 type KeyValueYARPCServer interface { 67 GetValue(context.Context, *GetValueRequest) (*GetValueResponse, error) 68 SetValue(context.Context, *SetValueRequest) (*SetValueResponse, error) 69 } 70 71 type buildKeyValueYARPCProceduresParams struct { 72 Server KeyValueYARPCServer 73 AnyResolver jsonpb.AnyResolver 74 } 75 76 func buildKeyValueYARPCProcedures(params buildKeyValueYARPCProceduresParams) []transport.Procedure { 77 handler := &_KeyValueYARPCHandler{params.Server} 78 return protobuf.BuildProcedures( 79 protobuf.BuildProceduresParams{ 80 ServiceName: "uber.yarpc.internal.examples.protobuf.example.KeyValue", 81 UnaryHandlerParams: []protobuf.BuildProceduresUnaryHandlerParams{ 82 { 83 MethodName: "GetValue", 84 Handler: protobuf.NewUnaryHandler( 85 protobuf.UnaryHandlerParams{ 86 Handle: handler.GetValue, 87 NewRequest: newKeyValueServiceGetValueYARPCRequest, 88 AnyResolver: params.AnyResolver, 89 }, 90 ), 91 }, 92 { 93 MethodName: "SetValue", 94 Handler: protobuf.NewUnaryHandler( 95 protobuf.UnaryHandlerParams{ 96 Handle: handler.SetValue, 97 NewRequest: newKeyValueServiceSetValueYARPCRequest, 98 AnyResolver: params.AnyResolver, 99 }, 100 ), 101 }, 102 }, 103 OnewayHandlerParams: []protobuf.BuildProceduresOnewayHandlerParams{}, 104 StreamHandlerParams: []protobuf.BuildProceduresStreamHandlerParams{}, 105 }, 106 ) 107 } 108 109 // BuildKeyValueYARPCProcedures prepares an implementation of the KeyValue service for YARPC registration. 110 func BuildKeyValueYARPCProcedures(server KeyValueYARPCServer) []transport.Procedure { 111 return buildKeyValueYARPCProcedures(buildKeyValueYARPCProceduresParams{Server: server}) 112 } 113 114 // FxKeyValueYARPCClientParams defines the input 115 // for NewFxKeyValueYARPCClient. It provides the 116 // paramaters to get a KeyValueYARPCClient in an 117 // Fx application. 118 type FxKeyValueYARPCClientParams struct { 119 fx.In 120 121 Provider yarpc.ClientConfig 122 AnyResolver jsonpb.AnyResolver `name:"yarpcfx" optional:"true"` 123 Restriction restriction.Checker `optional:"true"` 124 } 125 126 // FxKeyValueYARPCClientResult defines the output 127 // of NewFxKeyValueYARPCClient. It provides a 128 // KeyValueYARPCClient to an Fx application. 129 type FxKeyValueYARPCClientResult struct { 130 fx.Out 131 132 Client KeyValueYARPCClient 133 134 // We are using an fx.Out struct here instead of just returning a client 135 // so that we can add more values or add named versions of the client in 136 // the future without breaking any existing code. 137 } 138 139 // NewFxKeyValueYARPCClient provides a KeyValueYARPCClient 140 // to an Fx application using the given name for routing. 141 // 142 // fx.Provide( 143 // examplepb.NewFxKeyValueYARPCClient("service-name"), 144 // ... 145 // ) 146 func NewFxKeyValueYARPCClient(name string, options ...protobuf.ClientOption) interface{} { 147 return func(params FxKeyValueYARPCClientParams) FxKeyValueYARPCClientResult { 148 cc := params.Provider.ClientConfig(name) 149 150 if params.Restriction != nil { 151 if namer, ok := cc.GetUnaryOutbound().(transport.Namer); ok { 152 if err := params.Restriction.Check(protobuf.Encoding, namer.TransportName()); err != nil { 153 panic(err.Error()) 154 } 155 } 156 } 157 158 return FxKeyValueYARPCClientResult{ 159 Client: newKeyValueYARPCClient(cc, params.AnyResolver, options...), 160 } 161 } 162 } 163 164 // FxKeyValueYARPCProceduresParams defines the input 165 // for NewFxKeyValueYARPCProcedures. It provides the 166 // paramaters to get KeyValueYARPCServer procedures in an 167 // Fx application. 168 type FxKeyValueYARPCProceduresParams struct { 169 fx.In 170 171 Server KeyValueYARPCServer 172 AnyResolver jsonpb.AnyResolver `name:"yarpcfx" optional:"true"` 173 } 174 175 // FxKeyValueYARPCProceduresResult defines the output 176 // of NewFxKeyValueYARPCProcedures. It provides 177 // KeyValueYARPCServer procedures to an Fx application. 178 // 179 // The procedures are provided to the "yarpcfx" value group. 180 // Dig 1.2 or newer must be used for this feature to work. 181 type FxKeyValueYARPCProceduresResult struct { 182 fx.Out 183 184 Procedures []transport.Procedure `group:"yarpcfx"` 185 ReflectionMeta reflection.ServerMeta `group:"yarpcfx"` 186 } 187 188 // NewFxKeyValueYARPCProcedures provides KeyValueYARPCServer procedures to an Fx application. 189 // It expects a KeyValueYARPCServer to be present in the container. 190 // 191 // fx.Provide( 192 // examplepb.NewFxKeyValueYARPCProcedures(), 193 // ... 194 // ) 195 func NewFxKeyValueYARPCProcedures() interface{} { 196 return func(params FxKeyValueYARPCProceduresParams) FxKeyValueYARPCProceduresResult { 197 return FxKeyValueYARPCProceduresResult{ 198 Procedures: buildKeyValueYARPCProcedures(buildKeyValueYARPCProceduresParams{ 199 Server: params.Server, 200 AnyResolver: params.AnyResolver, 201 }), 202 ReflectionMeta: KeyValueReflectionMeta, 203 } 204 } 205 } 206 207 // KeyValueReflectionMeta is the reflection server metadata 208 // required for using the gRPC reflection protocol with YARPC. 209 // 210 // See https://github.com/grpc/grpc/blob/master/doc/server-reflection.md. 211 var KeyValueReflectionMeta = reflection.ServerMeta{ 212 ServiceName: "uber.yarpc.internal.examples.protobuf.example.KeyValue", 213 FileDescriptors: yarpcFileDescriptorClosurebab15b635bbc13f7, 214 } 215 216 type _KeyValueYARPCCaller struct { 217 streamClient protobuf.StreamClient 218 } 219 220 func (c *_KeyValueYARPCCaller) GetValue(ctx context.Context, request *GetValueRequest, options ...yarpc.CallOption) (*GetValueResponse, error) { 221 responseMessage, err := c.streamClient.Call(ctx, "GetValue", request, newKeyValueServiceGetValueYARPCResponse, options...) 222 if responseMessage == nil { 223 return nil, err 224 } 225 response, ok := responseMessage.(*GetValueResponse) 226 if !ok { 227 return nil, protobuf.CastError(emptyKeyValueServiceGetValueYARPCResponse, responseMessage) 228 } 229 return response, err 230 } 231 232 func (c *_KeyValueYARPCCaller) SetValue(ctx context.Context, request *SetValueRequest, options ...yarpc.CallOption) (*SetValueResponse, error) { 233 responseMessage, err := c.streamClient.Call(ctx, "SetValue", request, newKeyValueServiceSetValueYARPCResponse, options...) 234 if responseMessage == nil { 235 return nil, err 236 } 237 response, ok := responseMessage.(*SetValueResponse) 238 if !ok { 239 return nil, protobuf.CastError(emptyKeyValueServiceSetValueYARPCResponse, responseMessage) 240 } 241 return response, err 242 } 243 244 type _KeyValueYARPCHandler struct { 245 server KeyValueYARPCServer 246 } 247 248 func (h *_KeyValueYARPCHandler) GetValue(ctx context.Context, requestMessage proto.Message) (proto.Message, error) { 249 var request *GetValueRequest 250 var ok bool 251 if requestMessage != nil { 252 request, ok = requestMessage.(*GetValueRequest) 253 if !ok { 254 return nil, protobuf.CastError(emptyKeyValueServiceGetValueYARPCRequest, requestMessage) 255 } 256 } 257 response, err := h.server.GetValue(ctx, request) 258 if response == nil { 259 return nil, err 260 } 261 return response, err 262 } 263 264 func (h *_KeyValueYARPCHandler) SetValue(ctx context.Context, requestMessage proto.Message) (proto.Message, error) { 265 var request *SetValueRequest 266 var ok bool 267 if requestMessage != nil { 268 request, ok = requestMessage.(*SetValueRequest) 269 if !ok { 270 return nil, protobuf.CastError(emptyKeyValueServiceSetValueYARPCRequest, requestMessage) 271 } 272 } 273 response, err := h.server.SetValue(ctx, request) 274 if response == nil { 275 return nil, err 276 } 277 return response, err 278 } 279 280 func newKeyValueServiceGetValueYARPCRequest() proto.Message { 281 return &GetValueRequest{} 282 } 283 284 func newKeyValueServiceGetValueYARPCResponse() proto.Message { 285 return &GetValueResponse{} 286 } 287 288 func newKeyValueServiceSetValueYARPCRequest() proto.Message { 289 return &SetValueRequest{} 290 } 291 292 func newKeyValueServiceSetValueYARPCResponse() proto.Message { 293 return &SetValueResponse{} 294 } 295 296 var ( 297 emptyKeyValueServiceGetValueYARPCRequest = &GetValueRequest{} 298 emptyKeyValueServiceGetValueYARPCResponse = &GetValueResponse{} 299 emptyKeyValueServiceSetValueYARPCRequest = &SetValueRequest{} 300 emptyKeyValueServiceSetValueYARPCResponse = &SetValueResponse{} 301 ) 302 303 // FooYARPCClient is the YARPC client-side interface for the Foo service. 304 type FooYARPCClient interface { 305 EchoOut(context.Context, ...yarpc.CallOption) (FooServiceEchoOutYARPCClient, error) 306 EchoIn(context.Context, *EchoInRequest, ...yarpc.CallOption) (FooServiceEchoInYARPCClient, error) 307 EchoBoth(context.Context, ...yarpc.CallOption) (FooServiceEchoBothYARPCClient, error) 308 } 309 310 // FooServiceEchoOutYARPCClient sends EchoOutRequests and receives the single EchoOutResponse when sending is done. 311 type FooServiceEchoOutYARPCClient interface { 312 Context() context.Context 313 Send(*EchoOutRequest, ...yarpc.StreamOption) error 314 CloseAndRecv(...yarpc.StreamOption) (*EchoOutResponse, error) 315 } 316 317 // FooServiceEchoInYARPCClient receives EchoInResponses, returning io.EOF when the stream is complete. 318 type FooServiceEchoInYARPCClient interface { 319 Context() context.Context 320 Recv(...yarpc.StreamOption) (*EchoInResponse, error) 321 CloseSend(...yarpc.StreamOption) error 322 } 323 324 // FooServiceEchoBothYARPCClient sends EchoBothRequests and receives EchoBothResponses, returning io.EOF when the stream is complete. 325 type FooServiceEchoBothYARPCClient interface { 326 Context() context.Context 327 Send(*EchoBothRequest, ...yarpc.StreamOption) error 328 Recv(...yarpc.StreamOption) (*EchoBothResponse, error) 329 CloseSend(...yarpc.StreamOption) error 330 } 331 332 func newFooYARPCClient(clientConfig transport.ClientConfig, anyResolver jsonpb.AnyResolver, options ...protobuf.ClientOption) FooYARPCClient { 333 return &_FooYARPCCaller{protobuf.NewStreamClient( 334 protobuf.ClientParams{ 335 ServiceName: "uber.yarpc.internal.examples.protobuf.example.Foo", 336 ClientConfig: clientConfig, 337 AnyResolver: anyResolver, 338 Options: options, 339 }, 340 )} 341 } 342 343 // NewFooYARPCClient builds a new YARPC client for the Foo service. 344 func NewFooYARPCClient(clientConfig transport.ClientConfig, options ...protobuf.ClientOption) FooYARPCClient { 345 return newFooYARPCClient(clientConfig, nil, options...) 346 } 347 348 // FooYARPCServer is the YARPC server-side interface for the Foo service. 349 type FooYARPCServer interface { 350 EchoOut(FooServiceEchoOutYARPCServer) (*EchoOutResponse, error) 351 EchoIn(*EchoInRequest, FooServiceEchoInYARPCServer) error 352 EchoBoth(FooServiceEchoBothYARPCServer) error 353 } 354 355 // FooServiceEchoOutYARPCServer receives EchoOutRequests. 356 type FooServiceEchoOutYARPCServer interface { 357 Context() context.Context 358 Recv(...yarpc.StreamOption) (*EchoOutRequest, error) 359 } 360 361 // FooServiceEchoInYARPCServer sends EchoInResponses. 362 type FooServiceEchoInYARPCServer interface { 363 Context() context.Context 364 Send(*EchoInResponse, ...yarpc.StreamOption) error 365 } 366 367 // FooServiceEchoBothYARPCServer receives EchoBothRequests and sends EchoBothResponse. 368 type FooServiceEchoBothYARPCServer interface { 369 Context() context.Context 370 Recv(...yarpc.StreamOption) (*EchoBothRequest, error) 371 Send(*EchoBothResponse, ...yarpc.StreamOption) error 372 } 373 374 type buildFooYARPCProceduresParams struct { 375 Server FooYARPCServer 376 AnyResolver jsonpb.AnyResolver 377 } 378 379 func buildFooYARPCProcedures(params buildFooYARPCProceduresParams) []transport.Procedure { 380 handler := &_FooYARPCHandler{params.Server} 381 return protobuf.BuildProcedures( 382 protobuf.BuildProceduresParams{ 383 ServiceName: "uber.yarpc.internal.examples.protobuf.example.Foo", 384 UnaryHandlerParams: []protobuf.BuildProceduresUnaryHandlerParams{}, 385 OnewayHandlerParams: []protobuf.BuildProceduresOnewayHandlerParams{}, 386 StreamHandlerParams: []protobuf.BuildProceduresStreamHandlerParams{ 387 { 388 MethodName: "EchoBoth", 389 Handler: protobuf.NewStreamHandler( 390 protobuf.StreamHandlerParams{ 391 Handle: handler.EchoBoth, 392 }, 393 ), 394 }, 395 396 { 397 MethodName: "EchoIn", 398 Handler: protobuf.NewStreamHandler( 399 protobuf.StreamHandlerParams{ 400 Handle: handler.EchoIn, 401 }, 402 ), 403 }, 404 405 { 406 MethodName: "EchoOut", 407 Handler: protobuf.NewStreamHandler( 408 protobuf.StreamHandlerParams{ 409 Handle: handler.EchoOut, 410 }, 411 ), 412 }, 413 }, 414 }, 415 ) 416 } 417 418 // BuildFooYARPCProcedures prepares an implementation of the Foo service for YARPC registration. 419 func BuildFooYARPCProcedures(server FooYARPCServer) []transport.Procedure { 420 return buildFooYARPCProcedures(buildFooYARPCProceduresParams{Server: server}) 421 } 422 423 // FxFooYARPCClientParams defines the input 424 // for NewFxFooYARPCClient. It provides the 425 // paramaters to get a FooYARPCClient in an 426 // Fx application. 427 type FxFooYARPCClientParams struct { 428 fx.In 429 430 Provider yarpc.ClientConfig 431 AnyResolver jsonpb.AnyResolver `name:"yarpcfx" optional:"true"` 432 Restriction restriction.Checker `optional:"true"` 433 } 434 435 // FxFooYARPCClientResult defines the output 436 // of NewFxFooYARPCClient. It provides a 437 // FooYARPCClient to an Fx application. 438 type FxFooYARPCClientResult struct { 439 fx.Out 440 441 Client FooYARPCClient 442 443 // We are using an fx.Out struct here instead of just returning a client 444 // so that we can add more values or add named versions of the client in 445 // the future without breaking any existing code. 446 } 447 448 // NewFxFooYARPCClient provides a FooYARPCClient 449 // to an Fx application using the given name for routing. 450 // 451 // fx.Provide( 452 // examplepb.NewFxFooYARPCClient("service-name"), 453 // ... 454 // ) 455 func NewFxFooYARPCClient(name string, options ...protobuf.ClientOption) interface{} { 456 return func(params FxFooYARPCClientParams) FxFooYARPCClientResult { 457 cc := params.Provider.ClientConfig(name) 458 459 if params.Restriction != nil { 460 if namer, ok := cc.GetUnaryOutbound().(transport.Namer); ok { 461 if err := params.Restriction.Check(protobuf.Encoding, namer.TransportName()); err != nil { 462 panic(err.Error()) 463 } 464 } 465 } 466 467 return FxFooYARPCClientResult{ 468 Client: newFooYARPCClient(cc, params.AnyResolver, options...), 469 } 470 } 471 } 472 473 // FxFooYARPCProceduresParams defines the input 474 // for NewFxFooYARPCProcedures. It provides the 475 // paramaters to get FooYARPCServer procedures in an 476 // Fx application. 477 type FxFooYARPCProceduresParams struct { 478 fx.In 479 480 Server FooYARPCServer 481 AnyResolver jsonpb.AnyResolver `name:"yarpcfx" optional:"true"` 482 } 483 484 // FxFooYARPCProceduresResult defines the output 485 // of NewFxFooYARPCProcedures. It provides 486 // FooYARPCServer procedures to an Fx application. 487 // 488 // The procedures are provided to the "yarpcfx" value group. 489 // Dig 1.2 or newer must be used for this feature to work. 490 type FxFooYARPCProceduresResult struct { 491 fx.Out 492 493 Procedures []transport.Procedure `group:"yarpcfx"` 494 ReflectionMeta reflection.ServerMeta `group:"yarpcfx"` 495 } 496 497 // NewFxFooYARPCProcedures provides FooYARPCServer procedures to an Fx application. 498 // It expects a FooYARPCServer to be present in the container. 499 // 500 // fx.Provide( 501 // examplepb.NewFxFooYARPCProcedures(), 502 // ... 503 // ) 504 func NewFxFooYARPCProcedures() interface{} { 505 return func(params FxFooYARPCProceduresParams) FxFooYARPCProceduresResult { 506 return FxFooYARPCProceduresResult{ 507 Procedures: buildFooYARPCProcedures(buildFooYARPCProceduresParams{ 508 Server: params.Server, 509 AnyResolver: params.AnyResolver, 510 }), 511 ReflectionMeta: FooReflectionMeta, 512 } 513 } 514 } 515 516 // FooReflectionMeta is the reflection server metadata 517 // required for using the gRPC reflection protocol with YARPC. 518 // 519 // See https://github.com/grpc/grpc/blob/master/doc/server-reflection.md. 520 var FooReflectionMeta = reflection.ServerMeta{ 521 ServiceName: "uber.yarpc.internal.examples.protobuf.example.Foo", 522 FileDescriptors: yarpcFileDescriptorClosurebab15b635bbc13f7, 523 } 524 525 type _FooYARPCCaller struct { 526 streamClient protobuf.StreamClient 527 } 528 529 func (c *_FooYARPCCaller) EchoOut(ctx context.Context, options ...yarpc.CallOption) (FooServiceEchoOutYARPCClient, error) { 530 stream, err := c.streamClient.CallStream(ctx, "EchoOut", options...) 531 if err != nil { 532 return nil, err 533 } 534 return &_FooServiceEchoOutYARPCClient{stream: stream}, nil 535 } 536 537 func (c *_FooYARPCCaller) EchoIn(ctx context.Context, request *EchoInRequest, options ...yarpc.CallOption) (FooServiceEchoInYARPCClient, error) { 538 stream, err := c.streamClient.CallStream(ctx, "EchoIn", options...) 539 if err != nil { 540 return nil, err 541 } 542 if err := stream.Send(request); err != nil { 543 return nil, err 544 } 545 return &_FooServiceEchoInYARPCClient{stream: stream}, nil 546 } 547 548 func (c *_FooYARPCCaller) EchoBoth(ctx context.Context, options ...yarpc.CallOption) (FooServiceEchoBothYARPCClient, error) { 549 stream, err := c.streamClient.CallStream(ctx, "EchoBoth", options...) 550 if err != nil { 551 return nil, err 552 } 553 return &_FooServiceEchoBothYARPCClient{stream: stream}, nil 554 } 555 556 type _FooYARPCHandler struct { 557 server FooYARPCServer 558 } 559 560 func (h *_FooYARPCHandler) EchoOut(serverStream *protobuf.ServerStream) error { 561 response, err := h.server.EchoOut(&_FooServiceEchoOutYARPCServer{serverStream: serverStream}) 562 if err != nil { 563 return err 564 } 565 return serverStream.Send(response) 566 } 567 568 func (h *_FooYARPCHandler) EchoIn(serverStream *protobuf.ServerStream) error { 569 requestMessage, err := serverStream.Receive(newFooServiceEchoInYARPCRequest) 570 if requestMessage == nil { 571 return err 572 } 573 574 request, ok := requestMessage.(*EchoInRequest) 575 if !ok { 576 return protobuf.CastError(emptyFooServiceEchoInYARPCRequest, requestMessage) 577 } 578 return h.server.EchoIn(request, &_FooServiceEchoInYARPCServer{serverStream: serverStream}) 579 } 580 581 func (h *_FooYARPCHandler) EchoBoth(serverStream *protobuf.ServerStream) error { 582 return h.server.EchoBoth(&_FooServiceEchoBothYARPCServer{serverStream: serverStream}) 583 } 584 585 type _FooServiceEchoOutYARPCClient struct { 586 stream *protobuf.ClientStream 587 } 588 589 func (c *_FooServiceEchoOutYARPCClient) Context() context.Context { 590 return c.stream.Context() 591 } 592 593 func (c *_FooServiceEchoOutYARPCClient) Send(request *EchoOutRequest, options ...yarpc.StreamOption) error { 594 return c.stream.Send(request, options...) 595 } 596 597 func (c *_FooServiceEchoOutYARPCClient) CloseAndRecv(options ...yarpc.StreamOption) (*EchoOutResponse, error) { 598 if err := c.stream.Close(options...); err != nil { 599 return nil, err 600 } 601 responseMessage, err := c.stream.Receive(newFooServiceEchoOutYARPCResponse, options...) 602 if responseMessage == nil { 603 return nil, err 604 } 605 response, ok := responseMessage.(*EchoOutResponse) 606 if !ok { 607 return nil, protobuf.CastError(emptyFooServiceEchoOutYARPCResponse, responseMessage) 608 } 609 return response, err 610 } 611 612 type _FooServiceEchoInYARPCClient struct { 613 stream *protobuf.ClientStream 614 } 615 616 func (c *_FooServiceEchoInYARPCClient) Context() context.Context { 617 return c.stream.Context() 618 } 619 620 func (c *_FooServiceEchoInYARPCClient) Recv(options ...yarpc.StreamOption) (*EchoInResponse, error) { 621 responseMessage, err := c.stream.Receive(newFooServiceEchoInYARPCResponse, options...) 622 if responseMessage == nil { 623 return nil, err 624 } 625 response, ok := responseMessage.(*EchoInResponse) 626 if !ok { 627 return nil, protobuf.CastError(emptyFooServiceEchoInYARPCResponse, responseMessage) 628 } 629 return response, err 630 } 631 632 func (c *_FooServiceEchoInYARPCClient) CloseSend(options ...yarpc.StreamOption) error { 633 return c.stream.Close(options...) 634 } 635 636 type _FooServiceEchoBothYARPCClient struct { 637 stream *protobuf.ClientStream 638 } 639 640 func (c *_FooServiceEchoBothYARPCClient) Context() context.Context { 641 return c.stream.Context() 642 } 643 644 func (c *_FooServiceEchoBothYARPCClient) Send(request *EchoBothRequest, options ...yarpc.StreamOption) error { 645 return c.stream.Send(request, options...) 646 } 647 648 func (c *_FooServiceEchoBothYARPCClient) Recv(options ...yarpc.StreamOption) (*EchoBothResponse, error) { 649 responseMessage, err := c.stream.Receive(newFooServiceEchoBothYARPCResponse, options...) 650 if responseMessage == nil { 651 return nil, err 652 } 653 response, ok := responseMessage.(*EchoBothResponse) 654 if !ok { 655 return nil, protobuf.CastError(emptyFooServiceEchoBothYARPCResponse, responseMessage) 656 } 657 return response, err 658 } 659 660 func (c *_FooServiceEchoBothYARPCClient) CloseSend(options ...yarpc.StreamOption) error { 661 return c.stream.Close(options...) 662 } 663 664 type _FooServiceEchoOutYARPCServer struct { 665 serverStream *protobuf.ServerStream 666 } 667 668 func (s *_FooServiceEchoOutYARPCServer) Context() context.Context { 669 return s.serverStream.Context() 670 } 671 672 func (s *_FooServiceEchoOutYARPCServer) Recv(options ...yarpc.StreamOption) (*EchoOutRequest, error) { 673 requestMessage, err := s.serverStream.Receive(newFooServiceEchoOutYARPCRequest, options...) 674 if requestMessage == nil { 675 return nil, err 676 } 677 request, ok := requestMessage.(*EchoOutRequest) 678 if !ok { 679 return nil, protobuf.CastError(emptyFooServiceEchoOutYARPCRequest, requestMessage) 680 } 681 return request, err 682 } 683 684 type _FooServiceEchoInYARPCServer struct { 685 serverStream *protobuf.ServerStream 686 } 687 688 func (s *_FooServiceEchoInYARPCServer) Context() context.Context { 689 return s.serverStream.Context() 690 } 691 692 func (s *_FooServiceEchoInYARPCServer) Send(response *EchoInResponse, options ...yarpc.StreamOption) error { 693 return s.serverStream.Send(response, options...) 694 } 695 696 type _FooServiceEchoBothYARPCServer struct { 697 serverStream *protobuf.ServerStream 698 } 699 700 func (s *_FooServiceEchoBothYARPCServer) Context() context.Context { 701 return s.serverStream.Context() 702 } 703 704 func (s *_FooServiceEchoBothYARPCServer) Recv(options ...yarpc.StreamOption) (*EchoBothRequest, error) { 705 requestMessage, err := s.serverStream.Receive(newFooServiceEchoBothYARPCRequest, options...) 706 if requestMessage == nil { 707 return nil, err 708 } 709 request, ok := requestMessage.(*EchoBothRequest) 710 if !ok { 711 return nil, protobuf.CastError(emptyFooServiceEchoBothYARPCRequest, requestMessage) 712 } 713 return request, err 714 } 715 716 func (s *_FooServiceEchoBothYARPCServer) Send(response *EchoBothResponse, options ...yarpc.StreamOption) error { 717 return s.serverStream.Send(response, options...) 718 } 719 720 func newFooServiceEchoOutYARPCRequest() proto.Message { 721 return &EchoOutRequest{} 722 } 723 724 func newFooServiceEchoOutYARPCResponse() proto.Message { 725 return &EchoOutResponse{} 726 } 727 728 func newFooServiceEchoInYARPCRequest() proto.Message { 729 return &EchoInRequest{} 730 } 731 732 func newFooServiceEchoInYARPCResponse() proto.Message { 733 return &EchoInResponse{} 734 } 735 736 func newFooServiceEchoBothYARPCRequest() proto.Message { 737 return &EchoBothRequest{} 738 } 739 740 func newFooServiceEchoBothYARPCResponse() proto.Message { 741 return &EchoBothResponse{} 742 } 743 744 var ( 745 emptyFooServiceEchoOutYARPCRequest = &EchoOutRequest{} 746 emptyFooServiceEchoOutYARPCResponse = &EchoOutResponse{} 747 emptyFooServiceEchoInYARPCRequest = &EchoInRequest{} 748 emptyFooServiceEchoInYARPCResponse = &EchoInResponse{} 749 emptyFooServiceEchoBothYARPCRequest = &EchoBothRequest{} 750 emptyFooServiceEchoBothYARPCResponse = &EchoBothResponse{} 751 ) 752 753 // TestMessageNameParityYARPCClient is the YARPC client-side interface for the TestMessageNameParity service. 754 type TestMessageNameParityYARPCClient interface { 755 MessageName(context.Context, *Get2NdMessageRequest, ...yarpc.CallOption) (*Get2NdMessageResponse, error) 756 } 757 758 func newTestMessageNameParityYARPCClient(clientConfig transport.ClientConfig, anyResolver jsonpb.AnyResolver, options ...protobuf.ClientOption) TestMessageNameParityYARPCClient { 759 return &_TestMessageNameParityYARPCCaller{protobuf.NewStreamClient( 760 protobuf.ClientParams{ 761 ServiceName: "uber.yarpc.internal.examples.protobuf.example.TestMessageNameParity", 762 ClientConfig: clientConfig, 763 AnyResolver: anyResolver, 764 Options: options, 765 }, 766 )} 767 } 768 769 // NewTestMessageNameParityYARPCClient builds a new YARPC client for the TestMessageNameParity service. 770 func NewTestMessageNameParityYARPCClient(clientConfig transport.ClientConfig, options ...protobuf.ClientOption) TestMessageNameParityYARPCClient { 771 return newTestMessageNameParityYARPCClient(clientConfig, nil, options...) 772 } 773 774 // TestMessageNameParityYARPCServer is the YARPC server-side interface for the TestMessageNameParity service. 775 type TestMessageNameParityYARPCServer interface { 776 MessageName(context.Context, *Get2NdMessageRequest) (*Get2NdMessageResponse, error) 777 } 778 779 type buildTestMessageNameParityYARPCProceduresParams struct { 780 Server TestMessageNameParityYARPCServer 781 AnyResolver jsonpb.AnyResolver 782 } 783 784 func buildTestMessageNameParityYARPCProcedures(params buildTestMessageNameParityYARPCProceduresParams) []transport.Procedure { 785 handler := &_TestMessageNameParityYARPCHandler{params.Server} 786 return protobuf.BuildProcedures( 787 protobuf.BuildProceduresParams{ 788 ServiceName: "uber.yarpc.internal.examples.protobuf.example.TestMessageNameParity", 789 UnaryHandlerParams: []protobuf.BuildProceduresUnaryHandlerParams{ 790 { 791 MethodName: "MessageName", 792 Handler: protobuf.NewUnaryHandler( 793 protobuf.UnaryHandlerParams{ 794 Handle: handler.MessageName, 795 NewRequest: newTestMessageNameParityServiceMessageNameYARPCRequest, 796 AnyResolver: params.AnyResolver, 797 }, 798 ), 799 }, 800 }, 801 OnewayHandlerParams: []protobuf.BuildProceduresOnewayHandlerParams{}, 802 StreamHandlerParams: []protobuf.BuildProceduresStreamHandlerParams{}, 803 }, 804 ) 805 } 806 807 // BuildTestMessageNameParityYARPCProcedures prepares an implementation of the TestMessageNameParity service for YARPC registration. 808 func BuildTestMessageNameParityYARPCProcedures(server TestMessageNameParityYARPCServer) []transport.Procedure { 809 return buildTestMessageNameParityYARPCProcedures(buildTestMessageNameParityYARPCProceduresParams{Server: server}) 810 } 811 812 // FxTestMessageNameParityYARPCClientParams defines the input 813 // for NewFxTestMessageNameParityYARPCClient. It provides the 814 // paramaters to get a TestMessageNameParityYARPCClient in an 815 // Fx application. 816 type FxTestMessageNameParityYARPCClientParams struct { 817 fx.In 818 819 Provider yarpc.ClientConfig 820 AnyResolver jsonpb.AnyResolver `name:"yarpcfx" optional:"true"` 821 Restriction restriction.Checker `optional:"true"` 822 } 823 824 // FxTestMessageNameParityYARPCClientResult defines the output 825 // of NewFxTestMessageNameParityYARPCClient. It provides a 826 // TestMessageNameParityYARPCClient to an Fx application. 827 type FxTestMessageNameParityYARPCClientResult struct { 828 fx.Out 829 830 Client TestMessageNameParityYARPCClient 831 832 // We are using an fx.Out struct here instead of just returning a client 833 // so that we can add more values or add named versions of the client in 834 // the future without breaking any existing code. 835 } 836 837 // NewFxTestMessageNameParityYARPCClient provides a TestMessageNameParityYARPCClient 838 // to an Fx application using the given name for routing. 839 // 840 // fx.Provide( 841 // examplepb.NewFxTestMessageNameParityYARPCClient("service-name"), 842 // ... 843 // ) 844 func NewFxTestMessageNameParityYARPCClient(name string, options ...protobuf.ClientOption) interface{} { 845 return func(params FxTestMessageNameParityYARPCClientParams) FxTestMessageNameParityYARPCClientResult { 846 cc := params.Provider.ClientConfig(name) 847 848 if params.Restriction != nil { 849 if namer, ok := cc.GetUnaryOutbound().(transport.Namer); ok { 850 if err := params.Restriction.Check(protobuf.Encoding, namer.TransportName()); err != nil { 851 panic(err.Error()) 852 } 853 } 854 } 855 856 return FxTestMessageNameParityYARPCClientResult{ 857 Client: newTestMessageNameParityYARPCClient(cc, params.AnyResolver, options...), 858 } 859 } 860 } 861 862 // FxTestMessageNameParityYARPCProceduresParams defines the input 863 // for NewFxTestMessageNameParityYARPCProcedures. It provides the 864 // paramaters to get TestMessageNameParityYARPCServer procedures in an 865 // Fx application. 866 type FxTestMessageNameParityYARPCProceduresParams struct { 867 fx.In 868 869 Server TestMessageNameParityYARPCServer 870 AnyResolver jsonpb.AnyResolver `name:"yarpcfx" optional:"true"` 871 } 872 873 // FxTestMessageNameParityYARPCProceduresResult defines the output 874 // of NewFxTestMessageNameParityYARPCProcedures. It provides 875 // TestMessageNameParityYARPCServer procedures to an Fx application. 876 // 877 // The procedures are provided to the "yarpcfx" value group. 878 // Dig 1.2 or newer must be used for this feature to work. 879 type FxTestMessageNameParityYARPCProceduresResult struct { 880 fx.Out 881 882 Procedures []transport.Procedure `group:"yarpcfx"` 883 ReflectionMeta reflection.ServerMeta `group:"yarpcfx"` 884 } 885 886 // NewFxTestMessageNameParityYARPCProcedures provides TestMessageNameParityYARPCServer procedures to an Fx application. 887 // It expects a TestMessageNameParityYARPCServer to be present in the container. 888 // 889 // fx.Provide( 890 // examplepb.NewFxTestMessageNameParityYARPCProcedures(), 891 // ... 892 // ) 893 func NewFxTestMessageNameParityYARPCProcedures() interface{} { 894 return func(params FxTestMessageNameParityYARPCProceduresParams) FxTestMessageNameParityYARPCProceduresResult { 895 return FxTestMessageNameParityYARPCProceduresResult{ 896 Procedures: buildTestMessageNameParityYARPCProcedures(buildTestMessageNameParityYARPCProceduresParams{ 897 Server: params.Server, 898 AnyResolver: params.AnyResolver, 899 }), 900 ReflectionMeta: TestMessageNameParityReflectionMeta, 901 } 902 } 903 } 904 905 // TestMessageNameParityReflectionMeta is the reflection server metadata 906 // required for using the gRPC reflection protocol with YARPC. 907 // 908 // See https://github.com/grpc/grpc/blob/master/doc/server-reflection.md. 909 var TestMessageNameParityReflectionMeta = reflection.ServerMeta{ 910 ServiceName: "uber.yarpc.internal.examples.protobuf.example.TestMessageNameParity", 911 FileDescriptors: yarpcFileDescriptorClosurebab15b635bbc13f7, 912 } 913 914 type _TestMessageNameParityYARPCCaller struct { 915 streamClient protobuf.StreamClient 916 } 917 918 func (c *_TestMessageNameParityYARPCCaller) MessageName(ctx context.Context, request *Get2NdMessageRequest, options ...yarpc.CallOption) (*Get2NdMessageResponse, error) { 919 responseMessage, err := c.streamClient.Call(ctx, "MessageName", request, newTestMessageNameParityServiceMessageNameYARPCResponse, options...) 920 if responseMessage == nil { 921 return nil, err 922 } 923 response, ok := responseMessage.(*Get2NdMessageResponse) 924 if !ok { 925 return nil, protobuf.CastError(emptyTestMessageNameParityServiceMessageNameYARPCResponse, responseMessage) 926 } 927 return response, err 928 } 929 930 type _TestMessageNameParityYARPCHandler struct { 931 server TestMessageNameParityYARPCServer 932 } 933 934 func (h *_TestMessageNameParityYARPCHandler) MessageName(ctx context.Context, requestMessage proto.Message) (proto.Message, error) { 935 var request *Get2NdMessageRequest 936 var ok bool 937 if requestMessage != nil { 938 request, ok = requestMessage.(*Get2NdMessageRequest) 939 if !ok { 940 return nil, protobuf.CastError(emptyTestMessageNameParityServiceMessageNameYARPCRequest, requestMessage) 941 } 942 } 943 response, err := h.server.MessageName(ctx, request) 944 if response == nil { 945 return nil, err 946 } 947 return response, err 948 } 949 950 func newTestMessageNameParityServiceMessageNameYARPCRequest() proto.Message { 951 return &Get2NdMessageRequest{} 952 } 953 954 func newTestMessageNameParityServiceMessageNameYARPCResponse() proto.Message { 955 return &Get2NdMessageResponse{} 956 } 957 958 var ( 959 emptyTestMessageNameParityServiceMessageNameYARPCRequest = &Get2NdMessageRequest{} 960 emptyTestMessageNameParityServiceMessageNameYARPCResponse = &Get2NdMessageResponse{} 961 ) 962 963 var yarpcFileDescriptorClosurebab15b635bbc13f7 = [][]byte{ 964 // internal/prototest/examplepb/example.proto 965 []byte{ 966 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x4d, 0x6f, 0xd3, 0x40, 967 0x10, 0xed, 0xc6, 0xa2, 0x4d, 0x26, 0x2d, 0xb1, 0x56, 0xad, 0x64, 0xf9, 0x54, 0xdc, 0x8b, 0x55, 968 0x81, 0x1b, 0x0c, 0x17, 0x24, 0x5a, 0xa4, 0xf2, 0x51, 0x21, 0x44, 0xa9, 0x6c, 0xc4, 0x81, 0x4b, 969 0xb5, 0x2e, 0x03, 0xad, 0xf0, 0x17, 0xde, 0x35, 0xc2, 0x3f, 0x01, 0x09, 0x0e, 0x5c, 0xf9, 0x09, 970 0x9c, 0xfb, 0x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, 0xa0, 0xbf, 0x09, 0x8c, 0xe7, 0xaa, 993 0xf4, 0x69, 0x77, 0xcf, 0x2e, 0xe4, 0xd3, 0x7c, 0xb6, 0x1a, 0x89, 0x92, 0x7e, 0x3c, 0x7e, 0x3f, 994 0x9a, 0x7d, 0x45, 0x82, 0xf5, 0x0a, 0xf6, 0xe0, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2e, 0x1b, 995 0x53, 0x70, 0x6c, 0x06, 0x00, 0x00, 996 }, 997 } 998 999 func init() { 1000 yarpc.RegisterClientBuilder( 1001 func(clientConfig transport.ClientConfig, structField reflect.StructField) KeyValueYARPCClient { 1002 return NewKeyValueYARPCClient(clientConfig, protobuf.ClientBuilderOptions(clientConfig, structField)...) 1003 }, 1004 ) 1005 yarpc.RegisterClientBuilder( 1006 func(clientConfig transport.ClientConfig, structField reflect.StructField) FooYARPCClient { 1007 return NewFooYARPCClient(clientConfig, protobuf.ClientBuilderOptions(clientConfig, structField)...) 1008 }, 1009 ) 1010 yarpc.RegisterClientBuilder( 1011 func(clientConfig transport.ClientConfig, structField reflect.StructField) TestMessageNameParityYARPCClient { 1012 return NewTestMessageNameParityYARPCClient(clientConfig, protobuf.ClientBuilderOptions(clientConfig, structField)...) 1013 }, 1014 ) 1015 }