github.com/cloudwego/dynamicgo@v0.2.6-0.20240519101509-707f41b6b834/testdata/kitex_gen/pb/example/testservice/testservice.go (about) 1 // Code generated by Kitex v0.5.2. DO NOT EDIT. 2 3 package testservice 4 5 import ( 6 "context" 7 "fmt" 8 example "github.com/cloudwego/dynamicgo/testdata/kitex_gen/pb/example" 9 client "github.com/cloudwego/kitex/client" 10 kitex "github.com/cloudwego/kitex/pkg/serviceinfo" 11 streaming "github.com/cloudwego/kitex/pkg/streaming" 12 proto "google.golang.org/protobuf/proto" 13 ) 14 15 func serviceInfo() *kitex.ServiceInfo { 16 return testServiceServiceInfo 17 } 18 19 var testServiceServiceInfo = NewServiceInfo() 20 21 func NewServiceInfo() *kitex.ServiceInfo { 22 serviceName := "TestService" 23 handlerType := (*example.TestService)(nil) 24 methods := map[string]kitex.MethodInfo{ 25 "ScalarsMethodTest": kitex.NewMethodInfo(scalarsMethodTestHandler, newScalarsMethodTestArgs, newScalarsMethodTestResult, false), 26 "MessageMethodTest": kitex.NewMethodInfo(messageMethodTestHandler, newMessageMethodTestArgs, newMessageMethodTestResult, false), 27 "NestedMethodTest": kitex.NewMethodInfo(nestedMethodTestHandler, newNestedMethodTestArgs, newNestedMethodTestResult, false), 28 "PartialMethodTest": kitex.NewMethodInfo(partialMethodTestHandler, newPartialMethodTestArgs, newPartialMethodTestResult, false), 29 "ListMethodTest": kitex.NewMethodInfo(listMethodTestHandler, newListMethodTestArgs, newListMethodTestResult, false), 30 "MapMethodTest": kitex.NewMethodInfo(mapMethodTestHandler, newMapMethodTestArgs, newMapMethodTestResult, false), 31 "OneofMethodTest": kitex.NewMethodInfo(oneofMethodTestHandler, newOneofMethodTestArgs, newOneofMethodTestResult, false), 32 } 33 extra := map[string]interface{}{ 34 "PackageName": "pb3", 35 } 36 svcInfo := &kitex.ServiceInfo{ 37 ServiceName: serviceName, 38 HandlerType: handlerType, 39 Methods: methods, 40 PayloadCodec: kitex.Protobuf, 41 KiteXGenVersion: "v0.5.2", 42 Extra: extra, 43 } 44 return svcInfo 45 } 46 47 func scalarsMethodTestHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { 48 switch s := arg.(type) { 49 case *streaming.Args: 50 st := s.Stream 51 req := new(example.ExampleScalarsReq) 52 if err := st.RecvMsg(req); err != nil { 53 return err 54 } 55 resp, err := handler.(example.TestService).ScalarsMethodTest(ctx, req) 56 if err != nil { 57 return err 58 } 59 if err := st.SendMsg(resp); err != nil { 60 return err 61 } 62 case *ScalarsMethodTestArgs: 63 success, err := handler.(example.TestService).ScalarsMethodTest(ctx, s.Req) 64 if err != nil { 65 return err 66 } 67 realResult := result.(*ScalarsMethodTestResult) 68 realResult.Success = success 69 } 70 return nil 71 } 72 func newScalarsMethodTestArgs() interface{} { 73 return &ScalarsMethodTestArgs{} 74 } 75 76 func newScalarsMethodTestResult() interface{} { 77 return &ScalarsMethodTestResult{} 78 } 79 80 type ScalarsMethodTestArgs struct { 81 Req *example.ExampleScalarsReq 82 } 83 84 func (p *ScalarsMethodTestArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 85 if !p.IsSetReq() { 86 p.Req = new(example.ExampleScalarsReq) 87 } 88 return p.Req.FastRead(buf, _type, number) 89 } 90 91 func (p *ScalarsMethodTestArgs) FastWrite(buf []byte) (n int) { 92 if !p.IsSetReq() { 93 return 0 94 } 95 return p.Req.FastWrite(buf) 96 } 97 98 func (p *ScalarsMethodTestArgs) Size() (n int) { 99 if !p.IsSetReq() { 100 return 0 101 } 102 return p.Req.Size() 103 } 104 105 func (p *ScalarsMethodTestArgs) Marshal(out []byte) ([]byte, error) { 106 if !p.IsSetReq() { 107 return out, fmt.Errorf("No req in ScalarsMethodTestArgs") 108 } 109 return proto.Marshal(p.Req) 110 } 111 112 func (p *ScalarsMethodTestArgs) Unmarshal(in []byte) error { 113 msg := new(example.ExampleScalarsReq) 114 if err := proto.Unmarshal(in, msg); err != nil { 115 return err 116 } 117 p.Req = msg 118 return nil 119 } 120 121 var ScalarsMethodTestArgs_Req_DEFAULT *example.ExampleScalarsReq 122 123 func (p *ScalarsMethodTestArgs) GetReq() *example.ExampleScalarsReq { 124 if !p.IsSetReq() { 125 return ScalarsMethodTestArgs_Req_DEFAULT 126 } 127 return p.Req 128 } 129 130 func (p *ScalarsMethodTestArgs) IsSetReq() bool { 131 return p.Req != nil 132 } 133 134 func (p *ScalarsMethodTestArgs) GetFirstArgument() interface{} { 135 return p.Req 136 } 137 138 type ScalarsMethodTestResult struct { 139 Success *example.ExampleScalarsResp 140 } 141 142 var ScalarsMethodTestResult_Success_DEFAULT *example.ExampleScalarsResp 143 144 func (p *ScalarsMethodTestResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 145 if !p.IsSetSuccess() { 146 p.Success = new(example.ExampleScalarsResp) 147 } 148 return p.Success.FastRead(buf, _type, number) 149 } 150 151 func (p *ScalarsMethodTestResult) FastWrite(buf []byte) (n int) { 152 if !p.IsSetSuccess() { 153 return 0 154 } 155 return p.Success.FastWrite(buf) 156 } 157 158 func (p *ScalarsMethodTestResult) Size() (n int) { 159 if !p.IsSetSuccess() { 160 return 0 161 } 162 return p.Success.Size() 163 } 164 165 func (p *ScalarsMethodTestResult) Marshal(out []byte) ([]byte, error) { 166 if !p.IsSetSuccess() { 167 return out, fmt.Errorf("No req in ScalarsMethodTestResult") 168 } 169 return proto.Marshal(p.Success) 170 } 171 172 func (p *ScalarsMethodTestResult) Unmarshal(in []byte) error { 173 msg := new(example.ExampleScalarsResp) 174 if err := proto.Unmarshal(in, msg); err != nil { 175 return err 176 } 177 p.Success = msg 178 return nil 179 } 180 181 func (p *ScalarsMethodTestResult) GetSuccess() *example.ExampleScalarsResp { 182 if !p.IsSetSuccess() { 183 return ScalarsMethodTestResult_Success_DEFAULT 184 } 185 return p.Success 186 } 187 188 func (p *ScalarsMethodTestResult) SetSuccess(x interface{}) { 189 p.Success = x.(*example.ExampleScalarsResp) 190 } 191 192 func (p *ScalarsMethodTestResult) IsSetSuccess() bool { 193 return p.Success != nil 194 } 195 196 func (p *ScalarsMethodTestResult) GetResult() interface{} { 197 return p.Success 198 } 199 200 func messageMethodTestHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { 201 switch s := arg.(type) { 202 case *streaming.Args: 203 st := s.Stream 204 req := new(example.ExampleMessageReq) 205 if err := st.RecvMsg(req); err != nil { 206 return err 207 } 208 resp, err := handler.(example.TestService).MessageMethodTest(ctx, req) 209 if err != nil { 210 return err 211 } 212 if err := st.SendMsg(resp); err != nil { 213 return err 214 } 215 case *MessageMethodTestArgs: 216 success, err := handler.(example.TestService).MessageMethodTest(ctx, s.Req) 217 if err != nil { 218 return err 219 } 220 realResult := result.(*MessageMethodTestResult) 221 realResult.Success = success 222 } 223 return nil 224 } 225 func newMessageMethodTestArgs() interface{} { 226 return &MessageMethodTestArgs{} 227 } 228 229 func newMessageMethodTestResult() interface{} { 230 return &MessageMethodTestResult{} 231 } 232 233 type MessageMethodTestArgs struct { 234 Req *example.ExampleMessageReq 235 } 236 237 func (p *MessageMethodTestArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 238 if !p.IsSetReq() { 239 p.Req = new(example.ExampleMessageReq) 240 } 241 return p.Req.FastRead(buf, _type, number) 242 } 243 244 func (p *MessageMethodTestArgs) FastWrite(buf []byte) (n int) { 245 if !p.IsSetReq() { 246 return 0 247 } 248 return p.Req.FastWrite(buf) 249 } 250 251 func (p *MessageMethodTestArgs) Size() (n int) { 252 if !p.IsSetReq() { 253 return 0 254 } 255 return p.Req.Size() 256 } 257 258 func (p *MessageMethodTestArgs) Marshal(out []byte) ([]byte, error) { 259 if !p.IsSetReq() { 260 return out, fmt.Errorf("No req in MessageMethodTestArgs") 261 } 262 return proto.Marshal(p.Req) 263 } 264 265 func (p *MessageMethodTestArgs) Unmarshal(in []byte) error { 266 msg := new(example.ExampleMessageReq) 267 if err := proto.Unmarshal(in, msg); err != nil { 268 return err 269 } 270 p.Req = msg 271 return nil 272 } 273 274 var MessageMethodTestArgs_Req_DEFAULT *example.ExampleMessageReq 275 276 func (p *MessageMethodTestArgs) GetReq() *example.ExampleMessageReq { 277 if !p.IsSetReq() { 278 return MessageMethodTestArgs_Req_DEFAULT 279 } 280 return p.Req 281 } 282 283 func (p *MessageMethodTestArgs) IsSetReq() bool { 284 return p.Req != nil 285 } 286 287 func (p *MessageMethodTestArgs) GetFirstArgument() interface{} { 288 return p.Req 289 } 290 291 type MessageMethodTestResult struct { 292 Success *example.ExampleMessageResp 293 } 294 295 var MessageMethodTestResult_Success_DEFAULT *example.ExampleMessageResp 296 297 func (p *MessageMethodTestResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 298 if !p.IsSetSuccess() { 299 p.Success = new(example.ExampleMessageResp) 300 } 301 return p.Success.FastRead(buf, _type, number) 302 } 303 304 func (p *MessageMethodTestResult) FastWrite(buf []byte) (n int) { 305 if !p.IsSetSuccess() { 306 return 0 307 } 308 return p.Success.FastWrite(buf) 309 } 310 311 func (p *MessageMethodTestResult) Size() (n int) { 312 if !p.IsSetSuccess() { 313 return 0 314 } 315 return p.Success.Size() 316 } 317 318 func (p *MessageMethodTestResult) Marshal(out []byte) ([]byte, error) { 319 if !p.IsSetSuccess() { 320 return out, fmt.Errorf("No req in MessageMethodTestResult") 321 } 322 return proto.Marshal(p.Success) 323 } 324 325 func (p *MessageMethodTestResult) Unmarshal(in []byte) error { 326 msg := new(example.ExampleMessageResp) 327 if err := proto.Unmarshal(in, msg); err != nil { 328 return err 329 } 330 p.Success = msg 331 return nil 332 } 333 334 func (p *MessageMethodTestResult) GetSuccess() *example.ExampleMessageResp { 335 if !p.IsSetSuccess() { 336 return MessageMethodTestResult_Success_DEFAULT 337 } 338 return p.Success 339 } 340 341 func (p *MessageMethodTestResult) SetSuccess(x interface{}) { 342 p.Success = x.(*example.ExampleMessageResp) 343 } 344 345 func (p *MessageMethodTestResult) IsSetSuccess() bool { 346 return p.Success != nil 347 } 348 349 func (p *MessageMethodTestResult) GetResult() interface{} { 350 return p.Success 351 } 352 353 func nestedMethodTestHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { 354 switch s := arg.(type) { 355 case *streaming.Args: 356 st := s.Stream 357 req := new(example.ExampleNestedReq) 358 if err := st.RecvMsg(req); err != nil { 359 return err 360 } 361 resp, err := handler.(example.TestService).NestedMethodTest(ctx, req) 362 if err != nil { 363 return err 364 } 365 if err := st.SendMsg(resp); err != nil { 366 return err 367 } 368 case *NestedMethodTestArgs: 369 success, err := handler.(example.TestService).NestedMethodTest(ctx, s.Req) 370 if err != nil { 371 return err 372 } 373 realResult := result.(*NestedMethodTestResult) 374 realResult.Success = success 375 } 376 return nil 377 } 378 func newNestedMethodTestArgs() interface{} { 379 return &NestedMethodTestArgs{} 380 } 381 382 func newNestedMethodTestResult() interface{} { 383 return &NestedMethodTestResult{} 384 } 385 386 type NestedMethodTestArgs struct { 387 Req *example.ExampleNestedReq 388 } 389 390 func (p *NestedMethodTestArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 391 if !p.IsSetReq() { 392 p.Req = new(example.ExampleNestedReq) 393 } 394 return p.Req.FastRead(buf, _type, number) 395 } 396 397 func (p *NestedMethodTestArgs) FastWrite(buf []byte) (n int) { 398 if !p.IsSetReq() { 399 return 0 400 } 401 return p.Req.FastWrite(buf) 402 } 403 404 func (p *NestedMethodTestArgs) Size() (n int) { 405 if !p.IsSetReq() { 406 return 0 407 } 408 return p.Req.Size() 409 } 410 411 func (p *NestedMethodTestArgs) Marshal(out []byte) ([]byte, error) { 412 if !p.IsSetReq() { 413 return out, fmt.Errorf("No req in NestedMethodTestArgs") 414 } 415 return proto.Marshal(p.Req) 416 } 417 418 func (p *NestedMethodTestArgs) Unmarshal(in []byte) error { 419 msg := new(example.ExampleNestedReq) 420 if err := proto.Unmarshal(in, msg); err != nil { 421 return err 422 } 423 p.Req = msg 424 return nil 425 } 426 427 var NestedMethodTestArgs_Req_DEFAULT *example.ExampleNestedReq 428 429 func (p *NestedMethodTestArgs) GetReq() *example.ExampleNestedReq { 430 if !p.IsSetReq() { 431 return NestedMethodTestArgs_Req_DEFAULT 432 } 433 return p.Req 434 } 435 436 func (p *NestedMethodTestArgs) IsSetReq() bool { 437 return p.Req != nil 438 } 439 440 func (p *NestedMethodTestArgs) GetFirstArgument() interface{} { 441 return p.Req 442 } 443 444 type NestedMethodTestResult struct { 445 Success *example.ExampleNestedResp 446 } 447 448 var NestedMethodTestResult_Success_DEFAULT *example.ExampleNestedResp 449 450 func (p *NestedMethodTestResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 451 if !p.IsSetSuccess() { 452 p.Success = new(example.ExampleNestedResp) 453 } 454 return p.Success.FastRead(buf, _type, number) 455 } 456 457 func (p *NestedMethodTestResult) FastWrite(buf []byte) (n int) { 458 if !p.IsSetSuccess() { 459 return 0 460 } 461 return p.Success.FastWrite(buf) 462 } 463 464 func (p *NestedMethodTestResult) Size() (n int) { 465 if !p.IsSetSuccess() { 466 return 0 467 } 468 return p.Success.Size() 469 } 470 471 func (p *NestedMethodTestResult) Marshal(out []byte) ([]byte, error) { 472 if !p.IsSetSuccess() { 473 return out, fmt.Errorf("No req in NestedMethodTestResult") 474 } 475 return proto.Marshal(p.Success) 476 } 477 478 func (p *NestedMethodTestResult) Unmarshal(in []byte) error { 479 msg := new(example.ExampleNestedResp) 480 if err := proto.Unmarshal(in, msg); err != nil { 481 return err 482 } 483 p.Success = msg 484 return nil 485 } 486 487 func (p *NestedMethodTestResult) GetSuccess() *example.ExampleNestedResp { 488 if !p.IsSetSuccess() { 489 return NestedMethodTestResult_Success_DEFAULT 490 } 491 return p.Success 492 } 493 494 func (p *NestedMethodTestResult) SetSuccess(x interface{}) { 495 p.Success = x.(*example.ExampleNestedResp) 496 } 497 498 func (p *NestedMethodTestResult) IsSetSuccess() bool { 499 return p.Success != nil 500 } 501 502 func (p *NestedMethodTestResult) GetResult() interface{} { 503 return p.Success 504 } 505 506 func partialMethodTestHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { 507 switch s := arg.(type) { 508 case *streaming.Args: 509 st := s.Stream 510 req := new(example.ExampleParitalReq) 511 if err := st.RecvMsg(req); err != nil { 512 return err 513 } 514 resp, err := handler.(example.TestService).PartialMethodTest(ctx, req) 515 if err != nil { 516 return err 517 } 518 if err := st.SendMsg(resp); err != nil { 519 return err 520 } 521 case *PartialMethodTestArgs: 522 success, err := handler.(example.TestService).PartialMethodTest(ctx, s.Req) 523 if err != nil { 524 return err 525 } 526 realResult := result.(*PartialMethodTestResult) 527 realResult.Success = success 528 } 529 return nil 530 } 531 func newPartialMethodTestArgs() interface{} { 532 return &PartialMethodTestArgs{} 533 } 534 535 func newPartialMethodTestResult() interface{} { 536 return &PartialMethodTestResult{} 537 } 538 539 type PartialMethodTestArgs struct { 540 Req *example.ExampleParitalReq 541 } 542 543 func (p *PartialMethodTestArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 544 if !p.IsSetReq() { 545 p.Req = new(example.ExampleParitalReq) 546 } 547 return p.Req.FastRead(buf, _type, number) 548 } 549 550 func (p *PartialMethodTestArgs) FastWrite(buf []byte) (n int) { 551 if !p.IsSetReq() { 552 return 0 553 } 554 return p.Req.FastWrite(buf) 555 } 556 557 func (p *PartialMethodTestArgs) Size() (n int) { 558 if !p.IsSetReq() { 559 return 0 560 } 561 return p.Req.Size() 562 } 563 564 func (p *PartialMethodTestArgs) Marshal(out []byte) ([]byte, error) { 565 if !p.IsSetReq() { 566 return out, fmt.Errorf("No req in PartialMethodTestArgs") 567 } 568 return proto.Marshal(p.Req) 569 } 570 571 func (p *PartialMethodTestArgs) Unmarshal(in []byte) error { 572 msg := new(example.ExampleParitalReq) 573 if err := proto.Unmarshal(in, msg); err != nil { 574 return err 575 } 576 p.Req = msg 577 return nil 578 } 579 580 var PartialMethodTestArgs_Req_DEFAULT *example.ExampleParitalReq 581 582 func (p *PartialMethodTestArgs) GetReq() *example.ExampleParitalReq { 583 if !p.IsSetReq() { 584 return PartialMethodTestArgs_Req_DEFAULT 585 } 586 return p.Req 587 } 588 589 func (p *PartialMethodTestArgs) IsSetReq() bool { 590 return p.Req != nil 591 } 592 593 func (p *PartialMethodTestArgs) GetFirstArgument() interface{} { 594 return p.Req 595 } 596 597 type PartialMethodTestResult struct { 598 Success *example.ExamplePartialResp 599 } 600 601 var PartialMethodTestResult_Success_DEFAULT *example.ExamplePartialResp 602 603 func (p *PartialMethodTestResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 604 if !p.IsSetSuccess() { 605 p.Success = new(example.ExamplePartialResp) 606 } 607 return p.Success.FastRead(buf, _type, number) 608 } 609 610 func (p *PartialMethodTestResult) FastWrite(buf []byte) (n int) { 611 if !p.IsSetSuccess() { 612 return 0 613 } 614 return p.Success.FastWrite(buf) 615 } 616 617 func (p *PartialMethodTestResult) Size() (n int) { 618 if !p.IsSetSuccess() { 619 return 0 620 } 621 return p.Success.Size() 622 } 623 624 func (p *PartialMethodTestResult) Marshal(out []byte) ([]byte, error) { 625 if !p.IsSetSuccess() { 626 return out, fmt.Errorf("No req in PartialMethodTestResult") 627 } 628 return proto.Marshal(p.Success) 629 } 630 631 func (p *PartialMethodTestResult) Unmarshal(in []byte) error { 632 msg := new(example.ExamplePartialResp) 633 if err := proto.Unmarshal(in, msg); err != nil { 634 return err 635 } 636 p.Success = msg 637 return nil 638 } 639 640 func (p *PartialMethodTestResult) GetSuccess() *example.ExamplePartialResp { 641 if !p.IsSetSuccess() { 642 return PartialMethodTestResult_Success_DEFAULT 643 } 644 return p.Success 645 } 646 647 func (p *PartialMethodTestResult) SetSuccess(x interface{}) { 648 p.Success = x.(*example.ExamplePartialResp) 649 } 650 651 func (p *PartialMethodTestResult) IsSetSuccess() bool { 652 return p.Success != nil 653 } 654 655 func (p *PartialMethodTestResult) GetResult() interface{} { 656 return p.Success 657 } 658 659 func listMethodTestHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { 660 switch s := arg.(type) { 661 case *streaming.Args: 662 st := s.Stream 663 req := new(example.ExampleListReq) 664 if err := st.RecvMsg(req); err != nil { 665 return err 666 } 667 resp, err := handler.(example.TestService).ListMethodTest(ctx, req) 668 if err != nil { 669 return err 670 } 671 if err := st.SendMsg(resp); err != nil { 672 return err 673 } 674 case *ListMethodTestArgs: 675 success, err := handler.(example.TestService).ListMethodTest(ctx, s.Req) 676 if err != nil { 677 return err 678 } 679 realResult := result.(*ListMethodTestResult) 680 realResult.Success = success 681 } 682 return nil 683 } 684 func newListMethodTestArgs() interface{} { 685 return &ListMethodTestArgs{} 686 } 687 688 func newListMethodTestResult() interface{} { 689 return &ListMethodTestResult{} 690 } 691 692 type ListMethodTestArgs struct { 693 Req *example.ExampleListReq 694 } 695 696 func (p *ListMethodTestArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 697 if !p.IsSetReq() { 698 p.Req = new(example.ExampleListReq) 699 } 700 return p.Req.FastRead(buf, _type, number) 701 } 702 703 func (p *ListMethodTestArgs) FastWrite(buf []byte) (n int) { 704 if !p.IsSetReq() { 705 return 0 706 } 707 return p.Req.FastWrite(buf) 708 } 709 710 func (p *ListMethodTestArgs) Size() (n int) { 711 if !p.IsSetReq() { 712 return 0 713 } 714 return p.Req.Size() 715 } 716 717 func (p *ListMethodTestArgs) Marshal(out []byte) ([]byte, error) { 718 if !p.IsSetReq() { 719 return out, fmt.Errorf("No req in ListMethodTestArgs") 720 } 721 return proto.Marshal(p.Req) 722 } 723 724 func (p *ListMethodTestArgs) Unmarshal(in []byte) error { 725 msg := new(example.ExampleListReq) 726 if err := proto.Unmarshal(in, msg); err != nil { 727 return err 728 } 729 p.Req = msg 730 return nil 731 } 732 733 var ListMethodTestArgs_Req_DEFAULT *example.ExampleListReq 734 735 func (p *ListMethodTestArgs) GetReq() *example.ExampleListReq { 736 if !p.IsSetReq() { 737 return ListMethodTestArgs_Req_DEFAULT 738 } 739 return p.Req 740 } 741 742 func (p *ListMethodTestArgs) IsSetReq() bool { 743 return p.Req != nil 744 } 745 746 func (p *ListMethodTestArgs) GetFirstArgument() interface{} { 747 return p.Req 748 } 749 750 type ListMethodTestResult struct { 751 Success *example.ExampleListResp 752 } 753 754 var ListMethodTestResult_Success_DEFAULT *example.ExampleListResp 755 756 func (p *ListMethodTestResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 757 if !p.IsSetSuccess() { 758 p.Success = new(example.ExampleListResp) 759 } 760 return p.Success.FastRead(buf, _type, number) 761 } 762 763 func (p *ListMethodTestResult) FastWrite(buf []byte) (n int) { 764 if !p.IsSetSuccess() { 765 return 0 766 } 767 return p.Success.FastWrite(buf) 768 } 769 770 func (p *ListMethodTestResult) Size() (n int) { 771 if !p.IsSetSuccess() { 772 return 0 773 } 774 return p.Success.Size() 775 } 776 777 func (p *ListMethodTestResult) Marshal(out []byte) ([]byte, error) { 778 if !p.IsSetSuccess() { 779 return out, fmt.Errorf("No req in ListMethodTestResult") 780 } 781 return proto.Marshal(p.Success) 782 } 783 784 func (p *ListMethodTestResult) Unmarshal(in []byte) error { 785 msg := new(example.ExampleListResp) 786 if err := proto.Unmarshal(in, msg); err != nil { 787 return err 788 } 789 p.Success = msg 790 return nil 791 } 792 793 func (p *ListMethodTestResult) GetSuccess() *example.ExampleListResp { 794 if !p.IsSetSuccess() { 795 return ListMethodTestResult_Success_DEFAULT 796 } 797 return p.Success 798 } 799 800 func (p *ListMethodTestResult) SetSuccess(x interface{}) { 801 p.Success = x.(*example.ExampleListResp) 802 } 803 804 func (p *ListMethodTestResult) IsSetSuccess() bool { 805 return p.Success != nil 806 } 807 808 func (p *ListMethodTestResult) GetResult() interface{} { 809 return p.Success 810 } 811 812 func mapMethodTestHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { 813 switch s := arg.(type) { 814 case *streaming.Args: 815 st := s.Stream 816 req := new(example.ExampleMapReq) 817 if err := st.RecvMsg(req); err != nil { 818 return err 819 } 820 resp, err := handler.(example.TestService).MapMethodTest(ctx, req) 821 if err != nil { 822 return err 823 } 824 if err := st.SendMsg(resp); err != nil { 825 return err 826 } 827 case *MapMethodTestArgs: 828 success, err := handler.(example.TestService).MapMethodTest(ctx, s.Req) 829 if err != nil { 830 return err 831 } 832 realResult := result.(*MapMethodTestResult) 833 realResult.Success = success 834 } 835 return nil 836 } 837 func newMapMethodTestArgs() interface{} { 838 return &MapMethodTestArgs{} 839 } 840 841 func newMapMethodTestResult() interface{} { 842 return &MapMethodTestResult{} 843 } 844 845 type MapMethodTestArgs struct { 846 Req *example.ExampleMapReq 847 } 848 849 func (p *MapMethodTestArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 850 if !p.IsSetReq() { 851 p.Req = new(example.ExampleMapReq) 852 } 853 return p.Req.FastRead(buf, _type, number) 854 } 855 856 func (p *MapMethodTestArgs) FastWrite(buf []byte) (n int) { 857 if !p.IsSetReq() { 858 return 0 859 } 860 return p.Req.FastWrite(buf) 861 } 862 863 func (p *MapMethodTestArgs) Size() (n int) { 864 if !p.IsSetReq() { 865 return 0 866 } 867 return p.Req.Size() 868 } 869 870 func (p *MapMethodTestArgs) Marshal(out []byte) ([]byte, error) { 871 if !p.IsSetReq() { 872 return out, fmt.Errorf("No req in MapMethodTestArgs") 873 } 874 return proto.Marshal(p.Req) 875 } 876 877 func (p *MapMethodTestArgs) Unmarshal(in []byte) error { 878 msg := new(example.ExampleMapReq) 879 if err := proto.Unmarshal(in, msg); err != nil { 880 return err 881 } 882 p.Req = msg 883 return nil 884 } 885 886 var MapMethodTestArgs_Req_DEFAULT *example.ExampleMapReq 887 888 func (p *MapMethodTestArgs) GetReq() *example.ExampleMapReq { 889 if !p.IsSetReq() { 890 return MapMethodTestArgs_Req_DEFAULT 891 } 892 return p.Req 893 } 894 895 func (p *MapMethodTestArgs) IsSetReq() bool { 896 return p.Req != nil 897 } 898 899 func (p *MapMethodTestArgs) GetFirstArgument() interface{} { 900 return p.Req 901 } 902 903 type MapMethodTestResult struct { 904 Success *example.ExampleMapResp 905 } 906 907 var MapMethodTestResult_Success_DEFAULT *example.ExampleMapResp 908 909 func (p *MapMethodTestResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 910 if !p.IsSetSuccess() { 911 p.Success = new(example.ExampleMapResp) 912 } 913 return p.Success.FastRead(buf, _type, number) 914 } 915 916 func (p *MapMethodTestResult) FastWrite(buf []byte) (n int) { 917 if !p.IsSetSuccess() { 918 return 0 919 } 920 return p.Success.FastWrite(buf) 921 } 922 923 func (p *MapMethodTestResult) Size() (n int) { 924 if !p.IsSetSuccess() { 925 return 0 926 } 927 return p.Success.Size() 928 } 929 930 func (p *MapMethodTestResult) Marshal(out []byte) ([]byte, error) { 931 if !p.IsSetSuccess() { 932 return out, fmt.Errorf("No req in MapMethodTestResult") 933 } 934 return proto.Marshal(p.Success) 935 } 936 937 func (p *MapMethodTestResult) Unmarshal(in []byte) error { 938 msg := new(example.ExampleMapResp) 939 if err := proto.Unmarshal(in, msg); err != nil { 940 return err 941 } 942 p.Success = msg 943 return nil 944 } 945 946 func (p *MapMethodTestResult) GetSuccess() *example.ExampleMapResp { 947 if !p.IsSetSuccess() { 948 return MapMethodTestResult_Success_DEFAULT 949 } 950 return p.Success 951 } 952 953 func (p *MapMethodTestResult) SetSuccess(x interface{}) { 954 p.Success = x.(*example.ExampleMapResp) 955 } 956 957 func (p *MapMethodTestResult) IsSetSuccess() bool { 958 return p.Success != nil 959 } 960 961 func (p *MapMethodTestResult) GetResult() interface{} { 962 return p.Success 963 } 964 965 func oneofMethodTestHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { 966 switch s := arg.(type) { 967 case *streaming.Args: 968 st := s.Stream 969 req := new(example.ExampleOneofReq) 970 if err := st.RecvMsg(req); err != nil { 971 return err 972 } 973 resp, err := handler.(example.TestService).OneofMethodTest(ctx, req) 974 if err != nil { 975 return err 976 } 977 if err := st.SendMsg(resp); err != nil { 978 return err 979 } 980 case *OneofMethodTestArgs: 981 success, err := handler.(example.TestService).OneofMethodTest(ctx, s.Req) 982 if err != nil { 983 return err 984 } 985 realResult := result.(*OneofMethodTestResult) 986 realResult.Success = success 987 } 988 return nil 989 } 990 func newOneofMethodTestArgs() interface{} { 991 return &OneofMethodTestArgs{} 992 } 993 994 func newOneofMethodTestResult() interface{} { 995 return &OneofMethodTestResult{} 996 } 997 998 type OneofMethodTestArgs struct { 999 Req *example.ExampleOneofReq 1000 } 1001 1002 func (p *OneofMethodTestArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 1003 if !p.IsSetReq() { 1004 p.Req = new(example.ExampleOneofReq) 1005 } 1006 return p.Req.FastRead(buf, _type, number) 1007 } 1008 1009 func (p *OneofMethodTestArgs) FastWrite(buf []byte) (n int) { 1010 if !p.IsSetReq() { 1011 return 0 1012 } 1013 return p.Req.FastWrite(buf) 1014 } 1015 1016 func (p *OneofMethodTestArgs) Size() (n int) { 1017 if !p.IsSetReq() { 1018 return 0 1019 } 1020 return p.Req.Size() 1021 } 1022 1023 func (p *OneofMethodTestArgs) Marshal(out []byte) ([]byte, error) { 1024 if !p.IsSetReq() { 1025 return out, fmt.Errorf("No req in OneofMethodTestArgs") 1026 } 1027 return proto.Marshal(p.Req) 1028 } 1029 1030 func (p *OneofMethodTestArgs) Unmarshal(in []byte) error { 1031 msg := new(example.ExampleOneofReq) 1032 if err := proto.Unmarshal(in, msg); err != nil { 1033 return err 1034 } 1035 p.Req = msg 1036 return nil 1037 } 1038 1039 var OneofMethodTestArgs_Req_DEFAULT *example.ExampleOneofReq 1040 1041 func (p *OneofMethodTestArgs) GetReq() *example.ExampleOneofReq { 1042 if !p.IsSetReq() { 1043 return OneofMethodTestArgs_Req_DEFAULT 1044 } 1045 return p.Req 1046 } 1047 1048 func (p *OneofMethodTestArgs) IsSetReq() bool { 1049 return p.Req != nil 1050 } 1051 1052 func (p *OneofMethodTestArgs) GetFirstArgument() interface{} { 1053 return p.Req 1054 } 1055 1056 type OneofMethodTestResult struct { 1057 Success *example.ExampleOneofResp 1058 } 1059 1060 var OneofMethodTestResult_Success_DEFAULT *example.ExampleOneofResp 1061 1062 func (p *OneofMethodTestResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 1063 if !p.IsSetSuccess() { 1064 p.Success = new(example.ExampleOneofResp) 1065 } 1066 return p.Success.FastRead(buf, _type, number) 1067 } 1068 1069 func (p *OneofMethodTestResult) FastWrite(buf []byte) (n int) { 1070 if !p.IsSetSuccess() { 1071 return 0 1072 } 1073 return p.Success.FastWrite(buf) 1074 } 1075 1076 func (p *OneofMethodTestResult) Size() (n int) { 1077 if !p.IsSetSuccess() { 1078 return 0 1079 } 1080 return p.Success.Size() 1081 } 1082 1083 func (p *OneofMethodTestResult) Marshal(out []byte) ([]byte, error) { 1084 if !p.IsSetSuccess() { 1085 return out, fmt.Errorf("No req in OneofMethodTestResult") 1086 } 1087 return proto.Marshal(p.Success) 1088 } 1089 1090 func (p *OneofMethodTestResult) Unmarshal(in []byte) error { 1091 msg := new(example.ExampleOneofResp) 1092 if err := proto.Unmarshal(in, msg); err != nil { 1093 return err 1094 } 1095 p.Success = msg 1096 return nil 1097 } 1098 1099 func (p *OneofMethodTestResult) GetSuccess() *example.ExampleOneofResp { 1100 if !p.IsSetSuccess() { 1101 return OneofMethodTestResult_Success_DEFAULT 1102 } 1103 return p.Success 1104 } 1105 1106 func (p *OneofMethodTestResult) SetSuccess(x interface{}) { 1107 p.Success = x.(*example.ExampleOneofResp) 1108 } 1109 1110 func (p *OneofMethodTestResult) IsSetSuccess() bool { 1111 return p.Success != nil 1112 } 1113 1114 func (p *OneofMethodTestResult) GetResult() interface{} { 1115 return p.Success 1116 } 1117 1118 type kClient struct { 1119 c client.Client 1120 } 1121 1122 func newServiceClient(c client.Client) *kClient { 1123 return &kClient{ 1124 c: c, 1125 } 1126 } 1127 1128 func (p *kClient) ScalarsMethodTest(ctx context.Context, Req *example.ExampleScalarsReq) (r *example.ExampleScalarsResp, err error) { 1129 var _args ScalarsMethodTestArgs 1130 _args.Req = Req 1131 var _result ScalarsMethodTestResult 1132 if err = p.c.Call(ctx, "ScalarsMethodTest", &_args, &_result); err != nil { 1133 return 1134 } 1135 return _result.GetSuccess(), nil 1136 } 1137 1138 func (p *kClient) MessageMethodTest(ctx context.Context, Req *example.ExampleMessageReq) (r *example.ExampleMessageResp, err error) { 1139 var _args MessageMethodTestArgs 1140 _args.Req = Req 1141 var _result MessageMethodTestResult 1142 if err = p.c.Call(ctx, "MessageMethodTest", &_args, &_result); err != nil { 1143 return 1144 } 1145 return _result.GetSuccess(), nil 1146 } 1147 1148 func (p *kClient) NestedMethodTest(ctx context.Context, Req *example.ExampleNestedReq) (r *example.ExampleNestedResp, err error) { 1149 var _args NestedMethodTestArgs 1150 _args.Req = Req 1151 var _result NestedMethodTestResult 1152 if err = p.c.Call(ctx, "NestedMethodTest", &_args, &_result); err != nil { 1153 return 1154 } 1155 return _result.GetSuccess(), nil 1156 } 1157 1158 func (p *kClient) PartialMethodTest(ctx context.Context, Req *example.ExampleParitalReq) (r *example.ExamplePartialResp, err error) { 1159 var _args PartialMethodTestArgs 1160 _args.Req = Req 1161 var _result PartialMethodTestResult 1162 if err = p.c.Call(ctx, "PartialMethodTest", &_args, &_result); err != nil { 1163 return 1164 } 1165 return _result.GetSuccess(), nil 1166 } 1167 1168 func (p *kClient) ListMethodTest(ctx context.Context, Req *example.ExampleListReq) (r *example.ExampleListResp, err error) { 1169 var _args ListMethodTestArgs 1170 _args.Req = Req 1171 var _result ListMethodTestResult 1172 if err = p.c.Call(ctx, "ListMethodTest", &_args, &_result); err != nil { 1173 return 1174 } 1175 return _result.GetSuccess(), nil 1176 } 1177 1178 func (p *kClient) MapMethodTest(ctx context.Context, Req *example.ExampleMapReq) (r *example.ExampleMapResp, err error) { 1179 var _args MapMethodTestArgs 1180 _args.Req = Req 1181 var _result MapMethodTestResult 1182 if err = p.c.Call(ctx, "MapMethodTest", &_args, &_result); err != nil { 1183 return 1184 } 1185 return _result.GetSuccess(), nil 1186 } 1187 1188 func (p *kClient) OneofMethodTest(ctx context.Context, Req *example.ExampleOneofReq) (r *example.ExampleOneofResp, err error) { 1189 var _args OneofMethodTestArgs 1190 _args.Req = Req 1191 var _result OneofMethodTestResult 1192 if err = p.c.Call(ctx, "OneofMethodTest", &_args, &_result); err != nil { 1193 return 1194 } 1195 return _result.GetSuccess(), nil 1196 }