github.com/cloudwego/dynamicgo@v0.2.6-0.20240519101509-707f41b6b834/testdata/kitex_gen/pb/example2/testservice2/testservice2.go (about) 1 // Code generated by Kitex v0.7.2. DO NOT EDIT. 2 3 package testservice2 4 5 import ( 6 "context" 7 example2 "github.com/cloudwego/dynamicgo/testdata/kitex_gen/pb/example2" 8 client "github.com/cloudwego/kitex/client" 9 kitex "github.com/cloudwego/kitex/pkg/serviceinfo" 10 streaming "github.com/cloudwego/kitex/pkg/streaming" 11 proto "google.golang.org/protobuf/proto" 12 ) 13 14 func serviceInfo() *kitex.ServiceInfo { 15 return testService2ServiceInfo 16 } 17 18 var testService2ServiceInfo = NewServiceInfo() 19 20 func NewServiceInfo() *kitex.ServiceInfo { 21 serviceName := "TestService2" 22 handlerType := (*example2.TestService2)(nil) 23 methods := map[string]kitex.MethodInfo{ 24 "ExampleMethod": kitex.NewMethodInfo(exampleMethodHandler, newExampleMethodArgs, newExampleMethodResult, false), 25 "ExamplePartialMethod": kitex.NewMethodInfo(examplePartialMethodHandler, newExamplePartialMethodArgs, newExamplePartialMethodResult, false), 26 "ExamplePartialMethod2": kitex.NewMethodInfo(examplePartialMethod2Handler, newExamplePartialMethod2Args, newExamplePartialMethod2Result, false), 27 "ExampleSuperMethod": kitex.NewMethodInfo(exampleSuperMethodHandler, newExampleSuperMethodArgs, newExampleSuperMethodResult, false), 28 "Int2FloatMethod": kitex.NewMethodInfo(int2FloatMethodHandler, newInt2FloatMethodArgs, newInt2FloatMethodResult, false), 29 "Foo": kitex.NewMethodInfo(fooHandler, newFooArgs, newFooResult, false), 30 "Ping": kitex.NewMethodInfo(pingHandler, newPingArgs, newPingResult, false), 31 "Oneway": kitex.NewMethodInfo(onewayHandler, newOnewayArgs, newOnewayResult, false), 32 "Void": kitex.NewMethodInfo(voidHandler, newVoidArgs, newVoidResult, false), 33 } 34 extra := map[string]interface{}{ 35 "PackageName": "pb3", 36 "ServiceFilePath": ``, 37 } 38 svcInfo := &kitex.ServiceInfo{ 39 ServiceName: serviceName, 40 HandlerType: handlerType, 41 Methods: methods, 42 PayloadCodec: kitex.Protobuf, 43 KiteXGenVersion: "v0.7.2", 44 Extra: extra, 45 } 46 return svcInfo 47 } 48 49 func exampleMethodHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { 50 switch s := arg.(type) { 51 case *streaming.Args: 52 st := s.Stream 53 req := new(example2.ExampleReq) 54 if err := st.RecvMsg(req); err != nil { 55 return err 56 } 57 resp, err := handler.(example2.TestService2).ExampleMethod(ctx, req) 58 if err != nil { 59 return err 60 } 61 if err := st.SendMsg(resp); err != nil { 62 return err 63 } 64 case *ExampleMethodArgs: 65 success, err := handler.(example2.TestService2).ExampleMethod(ctx, s.Req) 66 if err != nil { 67 return err 68 } 69 realResult := result.(*ExampleMethodResult) 70 realResult.Success = success 71 } 72 return nil 73 } 74 func newExampleMethodArgs() interface{} { 75 return &ExampleMethodArgs{} 76 } 77 78 func newExampleMethodResult() interface{} { 79 return &ExampleMethodResult{} 80 } 81 82 type ExampleMethodArgs struct { 83 Req *example2.ExampleReq 84 } 85 86 func (p *ExampleMethodArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 87 if !p.IsSetReq() { 88 p.Req = new(example2.ExampleReq) 89 } 90 return p.Req.FastRead(buf, _type, number) 91 } 92 93 func (p *ExampleMethodArgs) FastWrite(buf []byte) (n int) { 94 if !p.IsSetReq() { 95 return 0 96 } 97 return p.Req.FastWrite(buf) 98 } 99 100 func (p *ExampleMethodArgs) Size() (n int) { 101 if !p.IsSetReq() { 102 return 0 103 } 104 return p.Req.Size() 105 } 106 107 func (p *ExampleMethodArgs) Marshal(out []byte) ([]byte, error) { 108 if !p.IsSetReq() { 109 return out, nil 110 } 111 return proto.Marshal(p.Req) 112 } 113 114 func (p *ExampleMethodArgs) Unmarshal(in []byte) error { 115 msg := new(example2.ExampleReq) 116 if err := proto.Unmarshal(in, msg); err != nil { 117 return err 118 } 119 p.Req = msg 120 return nil 121 } 122 123 var ExampleMethodArgs_Req_DEFAULT *example2.ExampleReq 124 125 func (p *ExampleMethodArgs) GetReq() *example2.ExampleReq { 126 if !p.IsSetReq() { 127 return ExampleMethodArgs_Req_DEFAULT 128 } 129 return p.Req 130 } 131 132 func (p *ExampleMethodArgs) IsSetReq() bool { 133 return p.Req != nil 134 } 135 136 func (p *ExampleMethodArgs) GetFirstArgument() interface{} { 137 return p.Req 138 } 139 140 type ExampleMethodResult struct { 141 Success *example2.ExampleResp 142 } 143 144 var ExampleMethodResult_Success_DEFAULT *example2.ExampleResp 145 146 func (p *ExampleMethodResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 147 if !p.IsSetSuccess() { 148 p.Success = new(example2.ExampleResp) 149 } 150 return p.Success.FastRead(buf, _type, number) 151 } 152 153 func (p *ExampleMethodResult) FastWrite(buf []byte) (n int) { 154 if !p.IsSetSuccess() { 155 return 0 156 } 157 return p.Success.FastWrite(buf) 158 } 159 160 func (p *ExampleMethodResult) Size() (n int) { 161 if !p.IsSetSuccess() { 162 return 0 163 } 164 return p.Success.Size() 165 } 166 167 func (p *ExampleMethodResult) Marshal(out []byte) ([]byte, error) { 168 if !p.IsSetSuccess() { 169 return out, nil 170 } 171 return proto.Marshal(p.Success) 172 } 173 174 func (p *ExampleMethodResult) Unmarshal(in []byte) error { 175 msg := new(example2.ExampleResp) 176 if err := proto.Unmarshal(in, msg); err != nil { 177 return err 178 } 179 p.Success = msg 180 return nil 181 } 182 183 func (p *ExampleMethodResult) GetSuccess() *example2.ExampleResp { 184 if !p.IsSetSuccess() { 185 return ExampleMethodResult_Success_DEFAULT 186 } 187 return p.Success 188 } 189 190 func (p *ExampleMethodResult) SetSuccess(x interface{}) { 191 p.Success = x.(*example2.ExampleResp) 192 } 193 194 func (p *ExampleMethodResult) IsSetSuccess() bool { 195 return p.Success != nil 196 } 197 198 func (p *ExampleMethodResult) GetResult() interface{} { 199 return p.Success 200 } 201 202 func examplePartialMethodHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { 203 switch s := arg.(type) { 204 case *streaming.Args: 205 st := s.Stream 206 req := new(example2.ExampleReqPartial) 207 if err := st.RecvMsg(req); err != nil { 208 return err 209 } 210 resp, err := handler.(example2.TestService2).ExamplePartialMethod(ctx, req) 211 if err != nil { 212 return err 213 } 214 if err := st.SendMsg(resp); err != nil { 215 return err 216 } 217 case *ExamplePartialMethodArgs: 218 success, err := handler.(example2.TestService2).ExamplePartialMethod(ctx, s.Req) 219 if err != nil { 220 return err 221 } 222 realResult := result.(*ExamplePartialMethodResult) 223 realResult.Success = success 224 } 225 return nil 226 } 227 func newExamplePartialMethodArgs() interface{} { 228 return &ExamplePartialMethodArgs{} 229 } 230 231 func newExamplePartialMethodResult() interface{} { 232 return &ExamplePartialMethodResult{} 233 } 234 235 type ExamplePartialMethodArgs struct { 236 Req *example2.ExampleReqPartial 237 } 238 239 func (p *ExamplePartialMethodArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 240 if !p.IsSetReq() { 241 p.Req = new(example2.ExampleReqPartial) 242 } 243 return p.Req.FastRead(buf, _type, number) 244 } 245 246 func (p *ExamplePartialMethodArgs) FastWrite(buf []byte) (n int) { 247 if !p.IsSetReq() { 248 return 0 249 } 250 return p.Req.FastWrite(buf) 251 } 252 253 func (p *ExamplePartialMethodArgs) Size() (n int) { 254 if !p.IsSetReq() { 255 return 0 256 } 257 return p.Req.Size() 258 } 259 260 func (p *ExamplePartialMethodArgs) Marshal(out []byte) ([]byte, error) { 261 if !p.IsSetReq() { 262 return out, nil 263 } 264 return proto.Marshal(p.Req) 265 } 266 267 func (p *ExamplePartialMethodArgs) Unmarshal(in []byte) error { 268 msg := new(example2.ExampleReqPartial) 269 if err := proto.Unmarshal(in, msg); err != nil { 270 return err 271 } 272 p.Req = msg 273 return nil 274 } 275 276 var ExamplePartialMethodArgs_Req_DEFAULT *example2.ExampleReqPartial 277 278 func (p *ExamplePartialMethodArgs) GetReq() *example2.ExampleReqPartial { 279 if !p.IsSetReq() { 280 return ExamplePartialMethodArgs_Req_DEFAULT 281 } 282 return p.Req 283 } 284 285 func (p *ExamplePartialMethodArgs) IsSetReq() bool { 286 return p.Req != nil 287 } 288 289 func (p *ExamplePartialMethodArgs) GetFirstArgument() interface{} { 290 return p.Req 291 } 292 293 type ExamplePartialMethodResult struct { 294 Success *example2.A 295 } 296 297 var ExamplePartialMethodResult_Success_DEFAULT *example2.A 298 299 func (p *ExamplePartialMethodResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 300 if !p.IsSetSuccess() { 301 p.Success = new(example2.A) 302 } 303 return p.Success.FastRead(buf, _type, number) 304 } 305 306 func (p *ExamplePartialMethodResult) FastWrite(buf []byte) (n int) { 307 if !p.IsSetSuccess() { 308 return 0 309 } 310 return p.Success.FastWrite(buf) 311 } 312 313 func (p *ExamplePartialMethodResult) Size() (n int) { 314 if !p.IsSetSuccess() { 315 return 0 316 } 317 return p.Success.Size() 318 } 319 320 func (p *ExamplePartialMethodResult) Marshal(out []byte) ([]byte, error) { 321 if !p.IsSetSuccess() { 322 return out, nil 323 } 324 return proto.Marshal(p.Success) 325 } 326 327 func (p *ExamplePartialMethodResult) Unmarshal(in []byte) error { 328 msg := new(example2.A) 329 if err := proto.Unmarshal(in, msg); err != nil { 330 return err 331 } 332 p.Success = msg 333 return nil 334 } 335 336 func (p *ExamplePartialMethodResult) GetSuccess() *example2.A { 337 if !p.IsSetSuccess() { 338 return ExamplePartialMethodResult_Success_DEFAULT 339 } 340 return p.Success 341 } 342 343 func (p *ExamplePartialMethodResult) SetSuccess(x interface{}) { 344 p.Success = x.(*example2.A) 345 } 346 347 func (p *ExamplePartialMethodResult) IsSetSuccess() bool { 348 return p.Success != nil 349 } 350 351 func (p *ExamplePartialMethodResult) GetResult() interface{} { 352 return p.Success 353 } 354 355 func examplePartialMethod2Handler(ctx context.Context, handler interface{}, arg, result interface{}) error { 356 switch s := arg.(type) { 357 case *streaming.Args: 358 st := s.Stream 359 req := new(example2.ExampleReqPartial) 360 if err := st.RecvMsg(req); err != nil { 361 return err 362 } 363 resp, err := handler.(example2.TestService2).ExamplePartialMethod2(ctx, req) 364 if err != nil { 365 return err 366 } 367 if err := st.SendMsg(resp); err != nil { 368 return err 369 } 370 case *ExamplePartialMethod2Args: 371 success, err := handler.(example2.TestService2).ExamplePartialMethod2(ctx, s.Req) 372 if err != nil { 373 return err 374 } 375 realResult := result.(*ExamplePartialMethod2Result) 376 realResult.Success = success 377 } 378 return nil 379 } 380 func newExamplePartialMethod2Args() interface{} { 381 return &ExamplePartialMethod2Args{} 382 } 383 384 func newExamplePartialMethod2Result() interface{} { 385 return &ExamplePartialMethod2Result{} 386 } 387 388 type ExamplePartialMethod2Args struct { 389 Req *example2.ExampleReqPartial 390 } 391 392 func (p *ExamplePartialMethod2Args) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 393 if !p.IsSetReq() { 394 p.Req = new(example2.ExampleReqPartial) 395 } 396 return p.Req.FastRead(buf, _type, number) 397 } 398 399 func (p *ExamplePartialMethod2Args) FastWrite(buf []byte) (n int) { 400 if !p.IsSetReq() { 401 return 0 402 } 403 return p.Req.FastWrite(buf) 404 } 405 406 func (p *ExamplePartialMethod2Args) Size() (n int) { 407 if !p.IsSetReq() { 408 return 0 409 } 410 return p.Req.Size() 411 } 412 413 func (p *ExamplePartialMethod2Args) Marshal(out []byte) ([]byte, error) { 414 if !p.IsSetReq() { 415 return out, nil 416 } 417 return proto.Marshal(p.Req) 418 } 419 420 func (p *ExamplePartialMethod2Args) Unmarshal(in []byte) error { 421 msg := new(example2.ExampleReqPartial) 422 if err := proto.Unmarshal(in, msg); err != nil { 423 return err 424 } 425 p.Req = msg 426 return nil 427 } 428 429 var ExamplePartialMethod2Args_Req_DEFAULT *example2.ExampleReqPartial 430 431 func (p *ExamplePartialMethod2Args) GetReq() *example2.ExampleReqPartial { 432 if !p.IsSetReq() { 433 return ExamplePartialMethod2Args_Req_DEFAULT 434 } 435 return p.Req 436 } 437 438 func (p *ExamplePartialMethod2Args) IsSetReq() bool { 439 return p.Req != nil 440 } 441 442 func (p *ExamplePartialMethod2Args) GetFirstArgument() interface{} { 443 return p.Req 444 } 445 446 type ExamplePartialMethod2Result struct { 447 Success *example2.ExampleRespPartial 448 } 449 450 var ExamplePartialMethod2Result_Success_DEFAULT *example2.ExampleRespPartial 451 452 func (p *ExamplePartialMethod2Result) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 453 if !p.IsSetSuccess() { 454 p.Success = new(example2.ExampleRespPartial) 455 } 456 return p.Success.FastRead(buf, _type, number) 457 } 458 459 func (p *ExamplePartialMethod2Result) FastWrite(buf []byte) (n int) { 460 if !p.IsSetSuccess() { 461 return 0 462 } 463 return p.Success.FastWrite(buf) 464 } 465 466 func (p *ExamplePartialMethod2Result) Size() (n int) { 467 if !p.IsSetSuccess() { 468 return 0 469 } 470 return p.Success.Size() 471 } 472 473 func (p *ExamplePartialMethod2Result) Marshal(out []byte) ([]byte, error) { 474 if !p.IsSetSuccess() { 475 return out, nil 476 } 477 return proto.Marshal(p.Success) 478 } 479 480 func (p *ExamplePartialMethod2Result) Unmarshal(in []byte) error { 481 msg := new(example2.ExampleRespPartial) 482 if err := proto.Unmarshal(in, msg); err != nil { 483 return err 484 } 485 p.Success = msg 486 return nil 487 } 488 489 func (p *ExamplePartialMethod2Result) GetSuccess() *example2.ExampleRespPartial { 490 if !p.IsSetSuccess() { 491 return ExamplePartialMethod2Result_Success_DEFAULT 492 } 493 return p.Success 494 } 495 496 func (p *ExamplePartialMethod2Result) SetSuccess(x interface{}) { 497 p.Success = x.(*example2.ExampleRespPartial) 498 } 499 500 func (p *ExamplePartialMethod2Result) IsSetSuccess() bool { 501 return p.Success != nil 502 } 503 504 func (p *ExamplePartialMethod2Result) GetResult() interface{} { 505 return p.Success 506 } 507 508 func exampleSuperMethodHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { 509 switch s := arg.(type) { 510 case *streaming.Args: 511 st := s.Stream 512 req := new(example2.ExampleSuper) 513 if err := st.RecvMsg(req); err != nil { 514 return err 515 } 516 resp, err := handler.(example2.TestService2).ExampleSuperMethod(ctx, req) 517 if err != nil { 518 return err 519 } 520 if err := st.SendMsg(resp); err != nil { 521 return err 522 } 523 case *ExampleSuperMethodArgs: 524 success, err := handler.(example2.TestService2).ExampleSuperMethod(ctx, s.Req) 525 if err != nil { 526 return err 527 } 528 realResult := result.(*ExampleSuperMethodResult) 529 realResult.Success = success 530 } 531 return nil 532 } 533 func newExampleSuperMethodArgs() interface{} { 534 return &ExampleSuperMethodArgs{} 535 } 536 537 func newExampleSuperMethodResult() interface{} { 538 return &ExampleSuperMethodResult{} 539 } 540 541 type ExampleSuperMethodArgs struct { 542 Req *example2.ExampleSuper 543 } 544 545 func (p *ExampleSuperMethodArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 546 if !p.IsSetReq() { 547 p.Req = new(example2.ExampleSuper) 548 } 549 return p.Req.FastRead(buf, _type, number) 550 } 551 552 func (p *ExampleSuperMethodArgs) FastWrite(buf []byte) (n int) { 553 if !p.IsSetReq() { 554 return 0 555 } 556 return p.Req.FastWrite(buf) 557 } 558 559 func (p *ExampleSuperMethodArgs) Size() (n int) { 560 if !p.IsSetReq() { 561 return 0 562 } 563 return p.Req.Size() 564 } 565 566 func (p *ExampleSuperMethodArgs) Marshal(out []byte) ([]byte, error) { 567 if !p.IsSetReq() { 568 return out, nil 569 } 570 return proto.Marshal(p.Req) 571 } 572 573 func (p *ExampleSuperMethodArgs) Unmarshal(in []byte) error { 574 msg := new(example2.ExampleSuper) 575 if err := proto.Unmarshal(in, msg); err != nil { 576 return err 577 } 578 p.Req = msg 579 return nil 580 } 581 582 var ExampleSuperMethodArgs_Req_DEFAULT *example2.ExampleSuper 583 584 func (p *ExampleSuperMethodArgs) GetReq() *example2.ExampleSuper { 585 if !p.IsSetReq() { 586 return ExampleSuperMethodArgs_Req_DEFAULT 587 } 588 return p.Req 589 } 590 591 func (p *ExampleSuperMethodArgs) IsSetReq() bool { 592 return p.Req != nil 593 } 594 595 func (p *ExampleSuperMethodArgs) GetFirstArgument() interface{} { 596 return p.Req 597 } 598 599 type ExampleSuperMethodResult struct { 600 Success *example2.A 601 } 602 603 var ExampleSuperMethodResult_Success_DEFAULT *example2.A 604 605 func (p *ExampleSuperMethodResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 606 if !p.IsSetSuccess() { 607 p.Success = new(example2.A) 608 } 609 return p.Success.FastRead(buf, _type, number) 610 } 611 612 func (p *ExampleSuperMethodResult) FastWrite(buf []byte) (n int) { 613 if !p.IsSetSuccess() { 614 return 0 615 } 616 return p.Success.FastWrite(buf) 617 } 618 619 func (p *ExampleSuperMethodResult) Size() (n int) { 620 if !p.IsSetSuccess() { 621 return 0 622 } 623 return p.Success.Size() 624 } 625 626 func (p *ExampleSuperMethodResult) Marshal(out []byte) ([]byte, error) { 627 if !p.IsSetSuccess() { 628 return out, nil 629 } 630 return proto.Marshal(p.Success) 631 } 632 633 func (p *ExampleSuperMethodResult) Unmarshal(in []byte) error { 634 msg := new(example2.A) 635 if err := proto.Unmarshal(in, msg); err != nil { 636 return err 637 } 638 p.Success = msg 639 return nil 640 } 641 642 func (p *ExampleSuperMethodResult) GetSuccess() *example2.A { 643 if !p.IsSetSuccess() { 644 return ExampleSuperMethodResult_Success_DEFAULT 645 } 646 return p.Success 647 } 648 649 func (p *ExampleSuperMethodResult) SetSuccess(x interface{}) { 650 p.Success = x.(*example2.A) 651 } 652 653 func (p *ExampleSuperMethodResult) IsSetSuccess() bool { 654 return p.Success != nil 655 } 656 657 func (p *ExampleSuperMethodResult) GetResult() interface{} { 658 return p.Success 659 } 660 661 func int2FloatMethodHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { 662 switch s := arg.(type) { 663 case *streaming.Args: 664 st := s.Stream 665 req := new(example2.ExampleInt2Float) 666 if err := st.RecvMsg(req); err != nil { 667 return err 668 } 669 resp, err := handler.(example2.TestService2).Int2FloatMethod(ctx, req) 670 if err != nil { 671 return err 672 } 673 if err := st.SendMsg(resp); err != nil { 674 return err 675 } 676 case *Int2FloatMethodArgs: 677 success, err := handler.(example2.TestService2).Int2FloatMethod(ctx, s.Req) 678 if err != nil { 679 return err 680 } 681 realResult := result.(*Int2FloatMethodResult) 682 realResult.Success = success 683 } 684 return nil 685 } 686 func newInt2FloatMethodArgs() interface{} { 687 return &Int2FloatMethodArgs{} 688 } 689 690 func newInt2FloatMethodResult() interface{} { 691 return &Int2FloatMethodResult{} 692 } 693 694 type Int2FloatMethodArgs struct { 695 Req *example2.ExampleInt2Float 696 } 697 698 func (p *Int2FloatMethodArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 699 if !p.IsSetReq() { 700 p.Req = new(example2.ExampleInt2Float) 701 } 702 return p.Req.FastRead(buf, _type, number) 703 } 704 705 func (p *Int2FloatMethodArgs) FastWrite(buf []byte) (n int) { 706 if !p.IsSetReq() { 707 return 0 708 } 709 return p.Req.FastWrite(buf) 710 } 711 712 func (p *Int2FloatMethodArgs) Size() (n int) { 713 if !p.IsSetReq() { 714 return 0 715 } 716 return p.Req.Size() 717 } 718 719 func (p *Int2FloatMethodArgs) Marshal(out []byte) ([]byte, error) { 720 if !p.IsSetReq() { 721 return out, nil 722 } 723 return proto.Marshal(p.Req) 724 } 725 726 func (p *Int2FloatMethodArgs) Unmarshal(in []byte) error { 727 msg := new(example2.ExampleInt2Float) 728 if err := proto.Unmarshal(in, msg); err != nil { 729 return err 730 } 731 p.Req = msg 732 return nil 733 } 734 735 var Int2FloatMethodArgs_Req_DEFAULT *example2.ExampleInt2Float 736 737 func (p *Int2FloatMethodArgs) GetReq() *example2.ExampleInt2Float { 738 if !p.IsSetReq() { 739 return Int2FloatMethodArgs_Req_DEFAULT 740 } 741 return p.Req 742 } 743 744 func (p *Int2FloatMethodArgs) IsSetReq() bool { 745 return p.Req != nil 746 } 747 748 func (p *Int2FloatMethodArgs) GetFirstArgument() interface{} { 749 return p.Req 750 } 751 752 type Int2FloatMethodResult struct { 753 Success *example2.ExampleInt2Float 754 } 755 756 var Int2FloatMethodResult_Success_DEFAULT *example2.ExampleInt2Float 757 758 func (p *Int2FloatMethodResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 759 if !p.IsSetSuccess() { 760 p.Success = new(example2.ExampleInt2Float) 761 } 762 return p.Success.FastRead(buf, _type, number) 763 } 764 765 func (p *Int2FloatMethodResult) FastWrite(buf []byte) (n int) { 766 if !p.IsSetSuccess() { 767 return 0 768 } 769 return p.Success.FastWrite(buf) 770 } 771 772 func (p *Int2FloatMethodResult) Size() (n int) { 773 if !p.IsSetSuccess() { 774 return 0 775 } 776 return p.Success.Size() 777 } 778 779 func (p *Int2FloatMethodResult) Marshal(out []byte) ([]byte, error) { 780 if !p.IsSetSuccess() { 781 return out, nil 782 } 783 return proto.Marshal(p.Success) 784 } 785 786 func (p *Int2FloatMethodResult) Unmarshal(in []byte) error { 787 msg := new(example2.ExampleInt2Float) 788 if err := proto.Unmarshal(in, msg); err != nil { 789 return err 790 } 791 p.Success = msg 792 return nil 793 } 794 795 func (p *Int2FloatMethodResult) GetSuccess() *example2.ExampleInt2Float { 796 if !p.IsSetSuccess() { 797 return Int2FloatMethodResult_Success_DEFAULT 798 } 799 return p.Success 800 } 801 802 func (p *Int2FloatMethodResult) SetSuccess(x interface{}) { 803 p.Success = x.(*example2.ExampleInt2Float) 804 } 805 806 func (p *Int2FloatMethodResult) IsSetSuccess() bool { 807 return p.Success != nil 808 } 809 810 func (p *Int2FloatMethodResult) GetResult() interface{} { 811 return p.Success 812 } 813 814 func fooHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { 815 switch s := arg.(type) { 816 case *streaming.Args: 817 st := s.Stream 818 req := new(example2.A) 819 if err := st.RecvMsg(req); err != nil { 820 return err 821 } 822 resp, err := handler.(example2.TestService2).Foo(ctx, req) 823 if err != nil { 824 return err 825 } 826 if err := st.SendMsg(resp); err != nil { 827 return err 828 } 829 case *FooArgs: 830 success, err := handler.(example2.TestService2).Foo(ctx, s.Req) 831 if err != nil { 832 return err 833 } 834 realResult := result.(*FooResult) 835 realResult.Success = success 836 } 837 return nil 838 } 839 func newFooArgs() interface{} { 840 return &FooArgs{} 841 } 842 843 func newFooResult() interface{} { 844 return &FooResult{} 845 } 846 847 type FooArgs struct { 848 Req *example2.A 849 } 850 851 func (p *FooArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 852 if !p.IsSetReq() { 853 p.Req = new(example2.A) 854 } 855 return p.Req.FastRead(buf, _type, number) 856 } 857 858 func (p *FooArgs) FastWrite(buf []byte) (n int) { 859 if !p.IsSetReq() { 860 return 0 861 } 862 return p.Req.FastWrite(buf) 863 } 864 865 func (p *FooArgs) Size() (n int) { 866 if !p.IsSetReq() { 867 return 0 868 } 869 return p.Req.Size() 870 } 871 872 func (p *FooArgs) Marshal(out []byte) ([]byte, error) { 873 if !p.IsSetReq() { 874 return out, nil 875 } 876 return proto.Marshal(p.Req) 877 } 878 879 func (p *FooArgs) Unmarshal(in []byte) error { 880 msg := new(example2.A) 881 if err := proto.Unmarshal(in, msg); err != nil { 882 return err 883 } 884 p.Req = msg 885 return nil 886 } 887 888 var FooArgs_Req_DEFAULT *example2.A 889 890 func (p *FooArgs) GetReq() *example2.A { 891 if !p.IsSetReq() { 892 return FooArgs_Req_DEFAULT 893 } 894 return p.Req 895 } 896 897 func (p *FooArgs) IsSetReq() bool { 898 return p.Req != nil 899 } 900 901 func (p *FooArgs) GetFirstArgument() interface{} { 902 return p.Req 903 } 904 905 type FooResult struct { 906 Success *example2.A 907 } 908 909 var FooResult_Success_DEFAULT *example2.A 910 911 func (p *FooResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 912 if !p.IsSetSuccess() { 913 p.Success = new(example2.A) 914 } 915 return p.Success.FastRead(buf, _type, number) 916 } 917 918 func (p *FooResult) FastWrite(buf []byte) (n int) { 919 if !p.IsSetSuccess() { 920 return 0 921 } 922 return p.Success.FastWrite(buf) 923 } 924 925 func (p *FooResult) Size() (n int) { 926 if !p.IsSetSuccess() { 927 return 0 928 } 929 return p.Success.Size() 930 } 931 932 func (p *FooResult) Marshal(out []byte) ([]byte, error) { 933 if !p.IsSetSuccess() { 934 return out, nil 935 } 936 return proto.Marshal(p.Success) 937 } 938 939 func (p *FooResult) Unmarshal(in []byte) error { 940 msg := new(example2.A) 941 if err := proto.Unmarshal(in, msg); err != nil { 942 return err 943 } 944 p.Success = msg 945 return nil 946 } 947 948 func (p *FooResult) GetSuccess() *example2.A { 949 if !p.IsSetSuccess() { 950 return FooResult_Success_DEFAULT 951 } 952 return p.Success 953 } 954 955 func (p *FooResult) SetSuccess(x interface{}) { 956 p.Success = x.(*example2.A) 957 } 958 959 func (p *FooResult) IsSetSuccess() bool { 960 return p.Success != nil 961 } 962 963 func (p *FooResult) GetResult() interface{} { 964 return p.Success 965 } 966 967 func pingHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { 968 switch s := arg.(type) { 969 case *streaming.Args: 970 st := s.Stream 971 req := new(example2.A) 972 if err := st.RecvMsg(req); err != nil { 973 return err 974 } 975 resp, err := handler.(example2.TestService2).Ping(ctx, req) 976 if err != nil { 977 return err 978 } 979 if err := st.SendMsg(resp); err != nil { 980 return err 981 } 982 case *PingArgs: 983 success, err := handler.(example2.TestService2).Ping(ctx, s.Req) 984 if err != nil { 985 return err 986 } 987 realResult := result.(*PingResult) 988 realResult.Success = success 989 } 990 return nil 991 } 992 func newPingArgs() interface{} { 993 return &PingArgs{} 994 } 995 996 func newPingResult() interface{} { 997 return &PingResult{} 998 } 999 1000 type PingArgs struct { 1001 Req *example2.A 1002 } 1003 1004 func (p *PingArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 1005 if !p.IsSetReq() { 1006 p.Req = new(example2.A) 1007 } 1008 return p.Req.FastRead(buf, _type, number) 1009 } 1010 1011 func (p *PingArgs) FastWrite(buf []byte) (n int) { 1012 if !p.IsSetReq() { 1013 return 0 1014 } 1015 return p.Req.FastWrite(buf) 1016 } 1017 1018 func (p *PingArgs) Size() (n int) { 1019 if !p.IsSetReq() { 1020 return 0 1021 } 1022 return p.Req.Size() 1023 } 1024 1025 func (p *PingArgs) Marshal(out []byte) ([]byte, error) { 1026 if !p.IsSetReq() { 1027 return out, nil 1028 } 1029 return proto.Marshal(p.Req) 1030 } 1031 1032 func (p *PingArgs) Unmarshal(in []byte) error { 1033 msg := new(example2.A) 1034 if err := proto.Unmarshal(in, msg); err != nil { 1035 return err 1036 } 1037 p.Req = msg 1038 return nil 1039 } 1040 1041 var PingArgs_Req_DEFAULT *example2.A 1042 1043 func (p *PingArgs) GetReq() *example2.A { 1044 if !p.IsSetReq() { 1045 return PingArgs_Req_DEFAULT 1046 } 1047 return p.Req 1048 } 1049 1050 func (p *PingArgs) IsSetReq() bool { 1051 return p.Req != nil 1052 } 1053 1054 func (p *PingArgs) GetFirstArgument() interface{} { 1055 return p.Req 1056 } 1057 1058 type PingResult struct { 1059 Success *example2.PingResponse 1060 } 1061 1062 var PingResult_Success_DEFAULT *example2.PingResponse 1063 1064 func (p *PingResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 1065 if !p.IsSetSuccess() { 1066 p.Success = new(example2.PingResponse) 1067 } 1068 return p.Success.FastRead(buf, _type, number) 1069 } 1070 1071 func (p *PingResult) FastWrite(buf []byte) (n int) { 1072 if !p.IsSetSuccess() { 1073 return 0 1074 } 1075 return p.Success.FastWrite(buf) 1076 } 1077 1078 func (p *PingResult) Size() (n int) { 1079 if !p.IsSetSuccess() { 1080 return 0 1081 } 1082 return p.Success.Size() 1083 } 1084 1085 func (p *PingResult) Marshal(out []byte) ([]byte, error) { 1086 if !p.IsSetSuccess() { 1087 return out, nil 1088 } 1089 return proto.Marshal(p.Success) 1090 } 1091 1092 func (p *PingResult) Unmarshal(in []byte) error { 1093 msg := new(example2.PingResponse) 1094 if err := proto.Unmarshal(in, msg); err != nil { 1095 return err 1096 } 1097 p.Success = msg 1098 return nil 1099 } 1100 1101 func (p *PingResult) GetSuccess() *example2.PingResponse { 1102 if !p.IsSetSuccess() { 1103 return PingResult_Success_DEFAULT 1104 } 1105 return p.Success 1106 } 1107 1108 func (p *PingResult) SetSuccess(x interface{}) { 1109 p.Success = x.(*example2.PingResponse) 1110 } 1111 1112 func (p *PingResult) IsSetSuccess() bool { 1113 return p.Success != nil 1114 } 1115 1116 func (p *PingResult) GetResult() interface{} { 1117 return p.Success 1118 } 1119 1120 func onewayHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { 1121 switch s := arg.(type) { 1122 case *streaming.Args: 1123 st := s.Stream 1124 req := new(example2.OnewayRequest) 1125 if err := st.RecvMsg(req); err != nil { 1126 return err 1127 } 1128 resp, err := handler.(example2.TestService2).Oneway(ctx, req) 1129 if err != nil { 1130 return err 1131 } 1132 if err := st.SendMsg(resp); err != nil { 1133 return err 1134 } 1135 case *OnewayArgs: 1136 success, err := handler.(example2.TestService2).Oneway(ctx, s.Req) 1137 if err != nil { 1138 return err 1139 } 1140 realResult := result.(*OnewayResult) 1141 realResult.Success = success 1142 } 1143 return nil 1144 } 1145 func newOnewayArgs() interface{} { 1146 return &OnewayArgs{} 1147 } 1148 1149 func newOnewayResult() interface{} { 1150 return &OnewayResult{} 1151 } 1152 1153 type OnewayArgs struct { 1154 Req *example2.OnewayRequest 1155 } 1156 1157 func (p *OnewayArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 1158 if !p.IsSetReq() { 1159 p.Req = new(example2.OnewayRequest) 1160 } 1161 return p.Req.FastRead(buf, _type, number) 1162 } 1163 1164 func (p *OnewayArgs) FastWrite(buf []byte) (n int) { 1165 if !p.IsSetReq() { 1166 return 0 1167 } 1168 return p.Req.FastWrite(buf) 1169 } 1170 1171 func (p *OnewayArgs) Size() (n int) { 1172 if !p.IsSetReq() { 1173 return 0 1174 } 1175 return p.Req.Size() 1176 } 1177 1178 func (p *OnewayArgs) Marshal(out []byte) ([]byte, error) { 1179 if !p.IsSetReq() { 1180 return out, nil 1181 } 1182 return proto.Marshal(p.Req) 1183 } 1184 1185 func (p *OnewayArgs) Unmarshal(in []byte) error { 1186 msg := new(example2.OnewayRequest) 1187 if err := proto.Unmarshal(in, msg); err != nil { 1188 return err 1189 } 1190 p.Req = msg 1191 return nil 1192 } 1193 1194 var OnewayArgs_Req_DEFAULT *example2.OnewayRequest 1195 1196 func (p *OnewayArgs) GetReq() *example2.OnewayRequest { 1197 if !p.IsSetReq() { 1198 return OnewayArgs_Req_DEFAULT 1199 } 1200 return p.Req 1201 } 1202 1203 func (p *OnewayArgs) IsSetReq() bool { 1204 return p.Req != nil 1205 } 1206 1207 func (p *OnewayArgs) GetFirstArgument() interface{} { 1208 return p.Req 1209 } 1210 1211 type OnewayResult struct { 1212 Success *example2.VoidResponse 1213 } 1214 1215 var OnewayResult_Success_DEFAULT *example2.VoidResponse 1216 1217 func (p *OnewayResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 1218 if !p.IsSetSuccess() { 1219 p.Success = new(example2.VoidResponse) 1220 } 1221 return p.Success.FastRead(buf, _type, number) 1222 } 1223 1224 func (p *OnewayResult) FastWrite(buf []byte) (n int) { 1225 if !p.IsSetSuccess() { 1226 return 0 1227 } 1228 return p.Success.FastWrite(buf) 1229 } 1230 1231 func (p *OnewayResult) Size() (n int) { 1232 if !p.IsSetSuccess() { 1233 return 0 1234 } 1235 return p.Success.Size() 1236 } 1237 1238 func (p *OnewayResult) Marshal(out []byte) ([]byte, error) { 1239 if !p.IsSetSuccess() { 1240 return out, nil 1241 } 1242 return proto.Marshal(p.Success) 1243 } 1244 1245 func (p *OnewayResult) Unmarshal(in []byte) error { 1246 msg := new(example2.VoidResponse) 1247 if err := proto.Unmarshal(in, msg); err != nil { 1248 return err 1249 } 1250 p.Success = msg 1251 return nil 1252 } 1253 1254 func (p *OnewayResult) GetSuccess() *example2.VoidResponse { 1255 if !p.IsSetSuccess() { 1256 return OnewayResult_Success_DEFAULT 1257 } 1258 return p.Success 1259 } 1260 1261 func (p *OnewayResult) SetSuccess(x interface{}) { 1262 p.Success = x.(*example2.VoidResponse) 1263 } 1264 1265 func (p *OnewayResult) IsSetSuccess() bool { 1266 return p.Success != nil 1267 } 1268 1269 func (p *OnewayResult) GetResult() interface{} { 1270 return p.Success 1271 } 1272 1273 func voidHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { 1274 switch s := arg.(type) { 1275 case *streaming.Args: 1276 st := s.Stream 1277 req := new(example2.VoidRequest) 1278 if err := st.RecvMsg(req); err != nil { 1279 return err 1280 } 1281 resp, err := handler.(example2.TestService2).Void(ctx, req) 1282 if err != nil { 1283 return err 1284 } 1285 if err := st.SendMsg(resp); err != nil { 1286 return err 1287 } 1288 case *VoidArgs: 1289 success, err := handler.(example2.TestService2).Void(ctx, s.Req) 1290 if err != nil { 1291 return err 1292 } 1293 realResult := result.(*VoidResult) 1294 realResult.Success = success 1295 } 1296 return nil 1297 } 1298 func newVoidArgs() interface{} { 1299 return &VoidArgs{} 1300 } 1301 1302 func newVoidResult() interface{} { 1303 return &VoidResult{} 1304 } 1305 1306 type VoidArgs struct { 1307 Req *example2.VoidRequest 1308 } 1309 1310 func (p *VoidArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 1311 if !p.IsSetReq() { 1312 p.Req = new(example2.VoidRequest) 1313 } 1314 return p.Req.FastRead(buf, _type, number) 1315 } 1316 1317 func (p *VoidArgs) FastWrite(buf []byte) (n int) { 1318 if !p.IsSetReq() { 1319 return 0 1320 } 1321 return p.Req.FastWrite(buf) 1322 } 1323 1324 func (p *VoidArgs) Size() (n int) { 1325 if !p.IsSetReq() { 1326 return 0 1327 } 1328 return p.Req.Size() 1329 } 1330 1331 func (p *VoidArgs) Marshal(out []byte) ([]byte, error) { 1332 if !p.IsSetReq() { 1333 return out, nil 1334 } 1335 return proto.Marshal(p.Req) 1336 } 1337 1338 func (p *VoidArgs) Unmarshal(in []byte) error { 1339 msg := new(example2.VoidRequest) 1340 if err := proto.Unmarshal(in, msg); err != nil { 1341 return err 1342 } 1343 p.Req = msg 1344 return nil 1345 } 1346 1347 var VoidArgs_Req_DEFAULT *example2.VoidRequest 1348 1349 func (p *VoidArgs) GetReq() *example2.VoidRequest { 1350 if !p.IsSetReq() { 1351 return VoidArgs_Req_DEFAULT 1352 } 1353 return p.Req 1354 } 1355 1356 func (p *VoidArgs) IsSetReq() bool { 1357 return p.Req != nil 1358 } 1359 1360 func (p *VoidArgs) GetFirstArgument() interface{} { 1361 return p.Req 1362 } 1363 1364 type VoidResult struct { 1365 Success *example2.VoidResponse 1366 } 1367 1368 var VoidResult_Success_DEFAULT *example2.VoidResponse 1369 1370 func (p *VoidResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { 1371 if !p.IsSetSuccess() { 1372 p.Success = new(example2.VoidResponse) 1373 } 1374 return p.Success.FastRead(buf, _type, number) 1375 } 1376 1377 func (p *VoidResult) FastWrite(buf []byte) (n int) { 1378 if !p.IsSetSuccess() { 1379 return 0 1380 } 1381 return p.Success.FastWrite(buf) 1382 } 1383 1384 func (p *VoidResult) Size() (n int) { 1385 if !p.IsSetSuccess() { 1386 return 0 1387 } 1388 return p.Success.Size() 1389 } 1390 1391 func (p *VoidResult) Marshal(out []byte) ([]byte, error) { 1392 if !p.IsSetSuccess() { 1393 return out, nil 1394 } 1395 return proto.Marshal(p.Success) 1396 } 1397 1398 func (p *VoidResult) Unmarshal(in []byte) error { 1399 msg := new(example2.VoidResponse) 1400 if err := proto.Unmarshal(in, msg); err != nil { 1401 return err 1402 } 1403 p.Success = msg 1404 return nil 1405 } 1406 1407 func (p *VoidResult) GetSuccess() *example2.VoidResponse { 1408 if !p.IsSetSuccess() { 1409 return VoidResult_Success_DEFAULT 1410 } 1411 return p.Success 1412 } 1413 1414 func (p *VoidResult) SetSuccess(x interface{}) { 1415 p.Success = x.(*example2.VoidResponse) 1416 } 1417 1418 func (p *VoidResult) IsSetSuccess() bool { 1419 return p.Success != nil 1420 } 1421 1422 func (p *VoidResult) GetResult() interface{} { 1423 return p.Success 1424 } 1425 1426 type kClient struct { 1427 c client.Client 1428 } 1429 1430 func newServiceClient(c client.Client) *kClient { 1431 return &kClient{ 1432 c: c, 1433 } 1434 } 1435 1436 func (p *kClient) ExampleMethod(ctx context.Context, Req *example2.ExampleReq) (r *example2.ExampleResp, err error) { 1437 var _args ExampleMethodArgs 1438 _args.Req = Req 1439 var _result ExampleMethodResult 1440 if err = p.c.Call(ctx, "ExampleMethod", &_args, &_result); err != nil { 1441 return 1442 } 1443 return _result.GetSuccess(), nil 1444 } 1445 1446 func (p *kClient) ExamplePartialMethod(ctx context.Context, Req *example2.ExampleReqPartial) (r *example2.A, err error) { 1447 var _args ExamplePartialMethodArgs 1448 _args.Req = Req 1449 var _result ExamplePartialMethodResult 1450 if err = p.c.Call(ctx, "ExamplePartialMethod", &_args, &_result); err != nil { 1451 return 1452 } 1453 return _result.GetSuccess(), nil 1454 } 1455 1456 func (p *kClient) ExamplePartialMethod2(ctx context.Context, Req *example2.ExampleReqPartial) (r *example2.ExampleRespPartial, err error) { 1457 var _args ExamplePartialMethod2Args 1458 _args.Req = Req 1459 var _result ExamplePartialMethod2Result 1460 if err = p.c.Call(ctx, "ExamplePartialMethod2", &_args, &_result); err != nil { 1461 return 1462 } 1463 return _result.GetSuccess(), nil 1464 } 1465 1466 func (p *kClient) ExampleSuperMethod(ctx context.Context, Req *example2.ExampleSuper) (r *example2.A, err error) { 1467 var _args ExampleSuperMethodArgs 1468 _args.Req = Req 1469 var _result ExampleSuperMethodResult 1470 if err = p.c.Call(ctx, "ExampleSuperMethod", &_args, &_result); err != nil { 1471 return 1472 } 1473 return _result.GetSuccess(), nil 1474 } 1475 1476 func (p *kClient) Int2FloatMethod(ctx context.Context, Req *example2.ExampleInt2Float) (r *example2.ExampleInt2Float, err error) { 1477 var _args Int2FloatMethodArgs 1478 _args.Req = Req 1479 var _result Int2FloatMethodResult 1480 if err = p.c.Call(ctx, "Int2FloatMethod", &_args, &_result); err != nil { 1481 return 1482 } 1483 return _result.GetSuccess(), nil 1484 } 1485 1486 func (p *kClient) Foo(ctx context.Context, Req *example2.A) (r *example2.A, err error) { 1487 var _args FooArgs 1488 _args.Req = Req 1489 var _result FooResult 1490 if err = p.c.Call(ctx, "Foo", &_args, &_result); err != nil { 1491 return 1492 } 1493 return _result.GetSuccess(), nil 1494 } 1495 1496 func (p *kClient) Ping(ctx context.Context, Req *example2.A) (r *example2.PingResponse, err error) { 1497 var _args PingArgs 1498 _args.Req = Req 1499 var _result PingResult 1500 if err = p.c.Call(ctx, "Ping", &_args, &_result); err != nil { 1501 return 1502 } 1503 return _result.GetSuccess(), nil 1504 } 1505 1506 func (p *kClient) Oneway(ctx context.Context, Req *example2.OnewayRequest) (r *example2.VoidResponse, err error) { 1507 var _args OnewayArgs 1508 _args.Req = Req 1509 var _result OnewayResult 1510 if err = p.c.Call(ctx, "Oneway", &_args, &_result); err != nil { 1511 return 1512 } 1513 return _result.GetSuccess(), nil 1514 } 1515 1516 func (p *kClient) Void(ctx context.Context, Req *example2.VoidRequest) (r *example2.VoidResponse, err error) { 1517 var _args VoidArgs 1518 _args.Req = Req 1519 var _result VoidResult 1520 if err = p.c.Call(ctx, "Void", &_args, &_result); err != nil { 1521 return 1522 } 1523 return _result.GetSuccess(), nil 1524 }