From 3d87114b98aa8dcfd6d330fe9367234487a9e7ba Mon Sep 17 00:00:00 2001 From: Felix021 Date: Thu, 11 Jan 2024 17:50:15 +0800 Subject: [PATCH 1/7] fix: run thrift-streaming codegen without LOCAL_REPO (#48) --- run.sh | 5 ++--- thrift_streaming/generate.sh | 4 ++-- thrift_streaming/kitex_gen/echo/echoservice/echoservice.go | 2 -- thrift_streaming/kitex_gen/grpc_pb/pbservice/pbservice.go | 2 -- thrift_streaming/kitex_gen/kitex_pb/pbservice/pbservice.go | 2 -- .../kitex_gen_slim/echo/echoservice/echoservice.go | 2 -- 6 files changed, 4 insertions(+), 13 deletions(-) diff --git a/run.sh b/run.sh index d74f348..a81b68f 100755 --- a/run.sh +++ b/run.sh @@ -128,11 +128,10 @@ packages=( ./thrift_streaming/... ) +LOCAL_REPO=$LOCAL_REPO ./thrift_streaming/generate.sh + for pkg in ${packages[@]} do - if [ "$pkg" == "./thrift_streaming/..." ]; then - LOCAL_REPO=$LOCAL_REPO ./thrift_streaming/generate.sh - fi if [[ -n $LOCAL_REPO ]]; then go test -covermode=atomic -coverprofile=${LOCAL_REPO}/coverage.txt.tmp -coverpkg=github.com/cloudwego/kitex/... $pkg if [[ "$OSTYPE" =~ ^darwin ]]; diff --git a/thrift_streaming/generate.sh b/thrift_streaming/generate.sh index 1f89cf2..539cd06 100755 --- a/thrift_streaming/generate.sh +++ b/thrift_streaming/generate.sh @@ -21,6 +21,7 @@ cd `dirname $0` ROOT=`pwd` set -e +set -x # Old binaries: kitex <= v0.8.0 && thriftgo <= v0.3.4 OLD=$ROOT/binaries/github-old @@ -66,8 +67,7 @@ function generate_new() { cd $LOCAL_REPO/tool/cmd/kitex && go build && cp kitex $dir cd $SAVE_DIR else - echo -e "[ERROR] Please set local kitex directory in the environment variable $LOCAL_REPO\n" - exit 1 + GOBIN=$dir go install github.com/cloudwego/kitex/tool/cmd/kitex@develop fi GOBIN=$dir go install github.com/cloudwego/thriftgo@latest diff --git a/thrift_streaming/kitex_gen/echo/echoservice/echoservice.go b/thrift_streaming/kitex_gen/echo/echoservice/echoservice.go index cd20618..ddd8b3e 100644 --- a/thrift_streaming/kitex_gen/echo/echoservice/echoservice.go +++ b/thrift_streaming/kitex_gen/echo/echoservice/echoservice.go @@ -14,8 +14,6 @@ import ( var errInvalidMessageType = errors.New("invalid message type for service method handler") -var _ = streaming.KitexUnusedProtection - var serviceMethods = map[string]kitex.MethodInfo{ "EchoBidirectional": kitex.NewMethodInfo( echoBidirectionalHandler, diff --git a/thrift_streaming/kitex_gen/grpc_pb/pbservice/pbservice.go b/thrift_streaming/kitex_gen/grpc_pb/pbservice/pbservice.go index 3b8c52e..c18e62c 100644 --- a/thrift_streaming/kitex_gen/grpc_pb/pbservice/pbservice.go +++ b/thrift_streaming/kitex_gen/grpc_pb/pbservice/pbservice.go @@ -15,8 +15,6 @@ import ( var errInvalidMessageType = errors.New("invalid message type for service method handler") -var _ = streaming.KitexUnusedProtection - var serviceMethods = map[string]kitex.MethodInfo{ "Echo": kitex.NewMethodInfo( echoHandler, diff --git a/thrift_streaming/kitex_gen/kitex_pb/pbservice/pbservice.go b/thrift_streaming/kitex_gen/kitex_pb/pbservice/pbservice.go index e2fce69..618851e 100644 --- a/thrift_streaming/kitex_gen/kitex_pb/pbservice/pbservice.go +++ b/thrift_streaming/kitex_gen/kitex_pb/pbservice/pbservice.go @@ -14,8 +14,6 @@ import ( var errInvalidMessageType = errors.New("invalid message type for service method handler") -var _ = streaming.KitexUnusedProtection - var serviceMethods = map[string]kitex.MethodInfo{ "EchoPingPong": kitex.NewMethodInfo( echoPingPongHandler, diff --git a/thrift_streaming/kitex_gen_slim/echo/echoservice/echoservice.go b/thrift_streaming/kitex_gen_slim/echo/echoservice/echoservice.go index ab9ef60..6afc6dc 100644 --- a/thrift_streaming/kitex_gen_slim/echo/echoservice/echoservice.go +++ b/thrift_streaming/kitex_gen_slim/echo/echoservice/echoservice.go @@ -14,8 +14,6 @@ import ( var errInvalidMessageType = errors.New("invalid message type for service method handler") -var _ = streaming.KitexUnusedProtection - var serviceMethods = map[string]kitex.MethodInfo{ "EchoBidirectional": kitex.NewMethodInfo( echoBidirectionalHandler, From ccf63c82c29f5810b906a683cbdd9a0989d8f4fb Mon Sep 17 00:00:00 2001 From: Felix021 Date: Tue, 16 Jan 2024 22:12:21 +0800 Subject: [PATCH 2/7] fix: streaming support --combine-service (#50) --- thrift_streaming/combine_handler.go | 49 + thrift_streaming/generate.sh | 2 + thrift_streaming/idl/api.thrift | 10 + thrift_streaming/idl/combine.thrift | 31 + thrift_streaming/kitex_gen/echo/api.go | 900 +++++++++++++++++ thrift_streaming/kitex_gen/echo/k-api.go | 532 ++++++++++ thrift_streaming/kitex_gen/grpc_pb/api.pb.go | 2 +- .../kitex_gen/kitex_pb/api_no_stream.pb.go | 2 +- thrift_streaming/kitex_gen_cross/echo/api.go | 538 ++++++++++ .../kitex_gen_cross/echo/k-api.go | 266 +++++ .../echo/pingpongonlyservice/client.go | 49 + .../echo/pingpongonlyservice/invoker.go | 24 + .../pingpongonlyservice.go | 75 ++ .../echo/pingpongonlyservice/server.go | 20 + .../echo/streamonlyservice/client.go | 40 + .../echo/streamonlyservice/invoker.go | 24 + .../echo/streamonlyservice/server.go | 20 + .../streamonlyservice/streamonlyservice.go | 44 + thrift_streaming/kitex_gen_old/echo/api.go | 938 ++++++++++++++++++ thrift_streaming/kitex_gen_old/echo/k-api.go | 532 ++++++++++ .../echo/pingpongonlyservice/client.go | 49 + .../echo/pingpongonlyservice/invoker.go | 24 + .../pingpongonlyservice.go | 75 ++ .../echo/pingpongonlyservice/server.go | 20 + .../echo/streamonlyservice/client.go | 49 + .../echo/streamonlyservice/invoker.go | 24 + .../echo/streamonlyservice/server.go | 20 + .../streamonlyservice/streamonlyservice.go | 75 ++ .../kitex_gen_slim/combine/a/a.go | 125 +++ .../kitex_gen_slim/combine/a/client.go | 49 + .../kitex_gen_slim/combine/a/invoker.go | 24 + .../kitex_gen_slim/combine/a/server.go | 21 + .../kitex_gen_slim/combine/b/b.go | 155 +++ .../kitex_gen_slim/combine/b/client.go | 92 ++ .../kitex_gen_slim/combine/b/invoker.go | 24 + .../kitex_gen_slim/combine/b/server.go | 21 + .../kitex_gen_slim/combine/combine.go | 77 ++ .../combine/combineservice/client.go | 99 ++ .../combine/combineservice/combineservice.go | 197 ++++ .../combine/combineservice/invoker.go | 23 + .../combine/combineservice/server.go | 20 + .../kitex_gen_slim/combine/k-combine.go | 173 ++++ .../kitex_gen_slim/combine/k-consts.go | 4 + thrift_streaming/kitex_gen_slim/echo/api.go | 16 + thrift_streaming/kitex_gen_slim/echo/k-api.go | 152 +++ .../echo/pingpongonlyservice/client.go | 49 + .../echo/pingpongonlyservice/invoker.go | 24 + .../pingpongonlyservice.go | 125 +++ .../echo/pingpongonlyservice/server.go | 21 + .../echo/streamonlyservice/client.go | 92 ++ .../echo/streamonlyservice/invoker.go | 24 + .../echo/streamonlyservice/server.go | 21 + .../streamonlyservice/streamonlyservice.go | 155 +++ thrift_streaming/main_test.go | 20 +- thrift_streaming/thrift_test.go | 23 + 55 files changed, 6257 insertions(+), 3 deletions(-) create mode 100644 thrift_streaming/combine_handler.go create mode 100644 thrift_streaming/idl/combine.thrift create mode 100644 thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/client.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/invoker.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/pingpongonlyservice.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/server.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/streamonlyservice/client.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/streamonlyservice/invoker.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/streamonlyservice/server.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/streamonlyservice/streamonlyservice.go create mode 100644 thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/client.go create mode 100644 thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/invoker.go create mode 100644 thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/pingpongonlyservice.go create mode 100644 thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/server.go create mode 100644 thrift_streaming/kitex_gen_old/echo/streamonlyservice/client.go create mode 100644 thrift_streaming/kitex_gen_old/echo/streamonlyservice/invoker.go create mode 100644 thrift_streaming/kitex_gen_old/echo/streamonlyservice/server.go create mode 100644 thrift_streaming/kitex_gen_old/echo/streamonlyservice/streamonlyservice.go create mode 100644 thrift_streaming/kitex_gen_slim/combine/a/a.go create mode 100644 thrift_streaming/kitex_gen_slim/combine/a/client.go create mode 100644 thrift_streaming/kitex_gen_slim/combine/a/invoker.go create mode 100644 thrift_streaming/kitex_gen_slim/combine/a/server.go create mode 100644 thrift_streaming/kitex_gen_slim/combine/b/b.go create mode 100644 thrift_streaming/kitex_gen_slim/combine/b/client.go create mode 100644 thrift_streaming/kitex_gen_slim/combine/b/invoker.go create mode 100644 thrift_streaming/kitex_gen_slim/combine/b/server.go create mode 100644 thrift_streaming/kitex_gen_slim/combine/combine.go create mode 100644 thrift_streaming/kitex_gen_slim/combine/combineservice/client.go create mode 100644 thrift_streaming/kitex_gen_slim/combine/combineservice/combineservice.go create mode 100644 thrift_streaming/kitex_gen_slim/combine/combineservice/invoker.go create mode 100644 thrift_streaming/kitex_gen_slim/combine/combineservice/server.go create mode 100644 thrift_streaming/kitex_gen_slim/combine/k-combine.go create mode 100644 thrift_streaming/kitex_gen_slim/combine/k-consts.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/client.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/invoker.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/pingpongonlyservice.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/server.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/streamonlyservice/client.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/streamonlyservice/invoker.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/streamonlyservice/server.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/streamonlyservice/streamonlyservice.go diff --git a/thrift_streaming/combine_handler.go b/thrift_streaming/combine_handler.go new file mode 100644 index 0000000..15d0c11 --- /dev/null +++ b/thrift_streaming/combine_handler.go @@ -0,0 +1,49 @@ +// Copyright 2023 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package thrift_streaming + +import ( + "context" + "io" + + "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine/combineservice" +) + +var _ combineservice.CombineService = new(CombineServiceImpl) + +type CombineServiceImpl struct{} + +func (c CombineServiceImpl) Foo(ctx context.Context, req *combine.Req) (rsp *combine.Rsp, err error) { + rsp = &combine.Rsp{Message: req.Message} + return +} + +func (c CombineServiceImpl) Bar(stream combine.B_BarServer) (err error) { + for { + req, err := stream.Recv() + if err == io.EOF { + return nil + } + if err != nil { + return err + } + + err = stream.Send(&combine.Rsp{Message: req.Message}) + if err != nil { + return err + } + } +} diff --git a/thrift_streaming/generate.sh b/thrift_streaming/generate.sh index 539cd06..ce63f42 100755 --- a/thrift_streaming/generate.sh +++ b/thrift_streaming/generate.sh @@ -80,9 +80,11 @@ function generate_new() { # Thrift kitex $module $idl + kitex $module --combine-service idl/combine.thrift # Thrift Slim kitex -thrift template=slim -gen-path kitex_gen_slim $module $idl + kitex -thrift template=slim -gen-path kitex_gen_slim $module --combine-service idl/combine.thrift # KitexPB kitex $module idl/api.proto diff --git a/thrift_streaming/idl/api.thrift b/thrift_streaming/idl/api.thrift index db57dd4..9c91870 100644 --- a/thrift_streaming/idl/api.thrift +++ b/thrift_streaming/idl/api.thrift @@ -39,3 +39,13 @@ service EchoService { void EchoOneway(1: EchoRequest req1), void Ping(), } + +// for checking whether the generated code is ok +service PingPongOnlyService { + EchoResponse EchoPingPong (1: EchoRequest req1), +} + +// for checking whether the generated code is ok +service StreamOnlyService { + EchoResponse EchoBidirectional (1: EchoRequest req1) (streaming.mode="bidirectional"), +} diff --git a/thrift_streaming/idl/combine.thrift b/thrift_streaming/idl/combine.thrift new file mode 100644 index 0000000..59ff4d1 --- /dev/null +++ b/thrift_streaming/idl/combine.thrift @@ -0,0 +1,31 @@ +// Copyright 2023 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace go combine + +struct Req { + 1: required string message, +} + +struct Rsp { + 1: required string message, +} + +service A { + Rsp Foo(1: Req req), +} + +service B { + Rsp Bar(1: Req req) (streaming.mode="bidirectional"), +} diff --git a/thrift_streaming/kitex_gen/echo/api.go b/thrift_streaming/kitex_gen/echo/api.go index edd4aae..804e889 100644 --- a/thrift_streaming/kitex_gen/echo/api.go +++ b/thrift_streaming/kitex_gen/echo/api.go @@ -626,6 +626,88 @@ func (p *EchoServiceClient) Ping(ctx context.Context) (err error) { return nil } +type PingPongOnlyService interface { + EchoPingPong(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) +} + +type PingPongOnlyServiceClient struct { + c thrift.TClient +} + +func NewPingPongOnlyServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *PingPongOnlyServiceClient { + return &PingPongOnlyServiceClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewPingPongOnlyServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *PingPongOnlyServiceClient { + return &PingPongOnlyServiceClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewPingPongOnlyServiceClient(c thrift.TClient) *PingPongOnlyServiceClient { + return &PingPongOnlyServiceClient{ + c: c, + } +} + +func (p *PingPongOnlyServiceClient) Client_() thrift.TClient { + return p.c +} + +func (p *PingPongOnlyServiceClient) EchoPingPong(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) { + var _args PingPongOnlyServiceEchoPingPongArgs + _args.Req1 = req1 + var _result PingPongOnlyServiceEchoPingPongResult + if err = p.Client_().Call(ctx, "EchoPingPong", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +type StreamOnlyService interface { + EchoBidirectional(stream StreamOnlyService_EchoBidirectionalServer) (err error) +} + +type StreamOnlyServiceClient struct { + c thrift.TClient +} + +func NewStreamOnlyServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *StreamOnlyServiceClient { + return &StreamOnlyServiceClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewStreamOnlyServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *StreamOnlyServiceClient { + return &StreamOnlyServiceClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewStreamOnlyServiceClient(c thrift.TClient) *StreamOnlyServiceClient { + return &StreamOnlyServiceClient{ + c: c, + } +} + +func (p *StreamOnlyServiceClient) Client_() thrift.TClient { + return p.c +} + +func (p *StreamOnlyServiceClient) EchoBidirectional(stream StreamOnlyService_EchoBidirectionalServer) (err error) { + panic("streaming method StreamOnlyService.EchoBidirectional(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") +} + +type StreamOnlyService_EchoBidirectionalServer interface { + streaming.Stream + + Recv() (*EchoRequest, error) + + Send(*EchoResponse) error +} + type EchoServiceProcessor struct { processorMap map[string]thrift.TProcessorFunction handler EchoService @@ -3125,3 +3207,821 @@ func (p *EchoServicePingResult) DeepEqual(ano *EchoServicePingResult) bool { } return true } + +type PingPongOnlyServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler PingPongOnlyService +} + +func (p *PingPongOnlyServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *PingPongOnlyServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *PingPongOnlyServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewPingPongOnlyServiceProcessor(handler PingPongOnlyService) *PingPongOnlyServiceProcessor { + self := &PingPongOnlyServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self.AddToProcessorMap("EchoPingPong", &pingPongOnlyServiceProcessorEchoPingPong{handler: handler}) + return self +} +func (p *PingPongOnlyServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} + +type pingPongOnlyServiceProcessorEchoPingPong struct { + handler PingPongOnlyService +} + +func (p *pingPongOnlyServiceProcessorEchoPingPong) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := PingPongOnlyServiceEchoPingPongArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("EchoPingPong", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := PingPongOnlyServiceEchoPingPongResult{} + var retval *EchoResponse + if retval, err2 = p.handler.EchoPingPong(ctx, args.Req1); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoPingPong: "+err2.Error()) + oprot.WriteMessageBegin("EchoPingPong", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("EchoPingPong", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type PingPongOnlyServiceEchoPingPongArgs struct { + Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` +} + +func NewPingPongOnlyServiceEchoPingPongArgs() *PingPongOnlyServiceEchoPingPongArgs { + return &PingPongOnlyServiceEchoPingPongArgs{} +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) InitDefault() { + *p = PingPongOnlyServiceEchoPingPongArgs{} +} + +var PingPongOnlyServiceEchoPingPongArgs_Req1_DEFAULT *EchoRequest + +func (p *PingPongOnlyServiceEchoPingPongArgs) GetReq1() (v *EchoRequest) { + if !p.IsSetReq1() { + return PingPongOnlyServiceEchoPingPongArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *PingPongOnlyServiceEchoPingPongArgs) SetReq1(val *EchoRequest) { + p.Req1 = val +} + +var fieldIDToName_PingPongOnlyServiceEchoPingPongArgs = map[int16]string{ + 1: "req1", +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = NewEchoRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoPingPong_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PingPongOnlyServiceEchoPingPongArgs(%+v)", *p) + +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) DeepEqual(ano *PingPongOnlyServiceEchoPingPongArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) Field1DeepEqual(src *EchoRequest) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type PingPongOnlyServiceEchoPingPongResult struct { + Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` +} + +func NewPingPongOnlyServiceEchoPingPongResult() *PingPongOnlyServiceEchoPingPongResult { + return &PingPongOnlyServiceEchoPingPongResult{} +} + +func (p *PingPongOnlyServiceEchoPingPongResult) InitDefault() { + *p = PingPongOnlyServiceEchoPingPongResult{} +} + +var PingPongOnlyServiceEchoPingPongResult_Success_DEFAULT *EchoResponse + +func (p *PingPongOnlyServiceEchoPingPongResult) GetSuccess() (v *EchoResponse) { + if !p.IsSetSuccess() { + return PingPongOnlyServiceEchoPingPongResult_Success_DEFAULT + } + return p.Success +} +func (p *PingPongOnlyServiceEchoPingPongResult) SetSuccess(x interface{}) { + p.Success = x.(*EchoResponse) +} + +var fieldIDToName_PingPongOnlyServiceEchoPingPongResult = map[int16]string{ + 0: "success", +} + +func (p *PingPongOnlyServiceEchoPingPongResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *PingPongOnlyServiceEchoPingPongResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = NewEchoResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *PingPongOnlyServiceEchoPingPongResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoPingPong_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PingPongOnlyServiceEchoPingPongResult(%+v)", *p) + +} + +func (p *PingPongOnlyServiceEchoPingPongResult) DeepEqual(ano *PingPongOnlyServiceEchoPingPongResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *PingPongOnlyServiceEchoPingPongResult) Field0DeepEqual(src *EchoResponse) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type StreamOnlyServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler StreamOnlyService +} + +func (p *StreamOnlyServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *StreamOnlyServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *StreamOnlyServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewStreamOnlyServiceProcessor(handler StreamOnlyService) *StreamOnlyServiceProcessor { + self := &StreamOnlyServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self.AddToProcessorMap("EchoBidirectional", &streamOnlyServiceProcessorEchoBidirectional{handler: handler}) + return self +} +func (p *StreamOnlyServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} + +type streamOnlyServiceProcessorEchoBidirectional struct { + handler StreamOnlyService +} + +func (p *streamOnlyServiceProcessorEchoBidirectional) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + panic("streaming method StreamOnlyService.EchoBidirectional(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") +} + +type StreamOnlyServiceEchoBidirectionalArgs struct { + Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` +} + +func NewStreamOnlyServiceEchoBidirectionalArgs() *StreamOnlyServiceEchoBidirectionalArgs { + return &StreamOnlyServiceEchoBidirectionalArgs{} +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) InitDefault() { + *p = StreamOnlyServiceEchoBidirectionalArgs{} +} + +var StreamOnlyServiceEchoBidirectionalArgs_Req1_DEFAULT *EchoRequest + +func (p *StreamOnlyServiceEchoBidirectionalArgs) GetReq1() (v *EchoRequest) { + if !p.IsSetReq1() { + return StreamOnlyServiceEchoBidirectionalArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *StreamOnlyServiceEchoBidirectionalArgs) SetReq1(val *EchoRequest) { + p.Req1 = val +} + +var fieldIDToName_StreamOnlyServiceEchoBidirectionalArgs = map[int16]string{ + 1: "req1", +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = NewEchoRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoBidirectional_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalArgs(%+v)", *p) + +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) DeepEqual(ano *StreamOnlyServiceEchoBidirectionalArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) Field1DeepEqual(src *EchoRequest) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type StreamOnlyServiceEchoBidirectionalResult struct { + Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` +} + +func NewStreamOnlyServiceEchoBidirectionalResult() *StreamOnlyServiceEchoBidirectionalResult { + return &StreamOnlyServiceEchoBidirectionalResult{} +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) InitDefault() { + *p = StreamOnlyServiceEchoBidirectionalResult{} +} + +var StreamOnlyServiceEchoBidirectionalResult_Success_DEFAULT *EchoResponse + +func (p *StreamOnlyServiceEchoBidirectionalResult) GetSuccess() (v *EchoResponse) { + if !p.IsSetSuccess() { + return StreamOnlyServiceEchoBidirectionalResult_Success_DEFAULT + } + return p.Success +} +func (p *StreamOnlyServiceEchoBidirectionalResult) SetSuccess(x interface{}) { + p.Success = x.(*EchoResponse) +} + +var fieldIDToName_StreamOnlyServiceEchoBidirectionalResult = map[int16]string{ + 0: "success", +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = NewEchoResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoBidirectional_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalResult(%+v)", *p) + +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) DeepEqual(ano *StreamOnlyServiceEchoBidirectionalResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) Field0DeepEqual(src *EchoResponse) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} diff --git a/thrift_streaming/kitex_gen/echo/k-api.go b/thrift_streaming/kitex_gen/echo/k-api.go index 8d6dc2b..d0db499 100644 --- a/thrift_streaming/kitex_gen/echo/k-api.go +++ b/thrift_streaming/kitex_gen/echo/k-api.go @@ -2171,6 +2171,522 @@ func (p *EchoServicePingResult) BLength() int { return l } +func (p *PingPongOnlyServiceEchoPingPongArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *PingPongOnlyServiceEchoPingPongArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPong_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoPingPong_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *PingPongOnlyServiceEchoPingPongResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *PingPongOnlyServiceEchoPingPongResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *PingPongOnlyServiceEchoPingPongResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPong_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *PingPongOnlyServiceEchoPingPongResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoPingPong_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *PingPongOnlyServiceEchoPingPongResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *PingPongOnlyServiceEchoPingPongResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *StreamOnlyServiceEchoBidirectionalArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectional_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoBidirectional_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *StreamOnlyServiceEchoBidirectionalResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectional_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoBidirectional_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + func (p *EchoServiceEchoBidirectionalArgs) GetFirstArgument() interface{} { return p.Req1 } @@ -2226,3 +2742,19 @@ func (p *EchoServicePingArgs) GetFirstArgument() interface{} { func (p *EchoServicePingResult) GetResult() interface{} { return nil } + +func (p *PingPongOnlyServiceEchoPingPongArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *PingPongOnlyServiceEchoPingPongResult) GetResult() interface{} { + return p.Success +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) GetResult() interface{} { + return p.Success +} diff --git a/thrift_streaming/kitex_gen/grpc_pb/api.pb.go b/thrift_streaming/kitex_gen/grpc_pb/api.pb.go index a46c9e4..73fd9b1 100644 --- a/thrift_streaming/kitex_gen/grpc_pb/api.pb.go +++ b/thrift_streaming/kitex_gen/grpc_pb/api.pb.go @@ -15,7 +15,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc v3.13.0 // source: idl/api.proto package grpc_pb diff --git a/thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.go b/thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.go index 12e1add..9fcf6f5 100644 --- a/thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.go +++ b/thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.go @@ -15,7 +15,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc v3.13.0 // source: idl/api_no_stream.proto package kitex_pb diff --git a/thrift_streaming/kitex_gen_cross/echo/api.go b/thrift_streaming/kitex_gen_cross/echo/api.go index ff1c0f4..0a1fd28 100644 --- a/thrift_streaming/kitex_gen_cross/echo/api.go +++ b/thrift_streaming/kitex_gen_cross/echo/api.go @@ -580,6 +580,75 @@ func (p *EchoServiceClient) Ping(ctx context.Context) (err error) { return nil } +type PingPongOnlyService interface { + EchoPingPong(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) +} + +type PingPongOnlyServiceClient struct { + c thrift.TClient +} + +func NewPingPongOnlyServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *PingPongOnlyServiceClient { + return &PingPongOnlyServiceClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewPingPongOnlyServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *PingPongOnlyServiceClient { + return &PingPongOnlyServiceClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewPingPongOnlyServiceClient(c thrift.TClient) *PingPongOnlyServiceClient { + return &PingPongOnlyServiceClient{ + c: c, + } +} + +func (p *PingPongOnlyServiceClient) Client_() thrift.TClient { + return p.c +} + +func (p *PingPongOnlyServiceClient) EchoPingPong(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) { + var _args PingPongOnlyServiceEchoPingPongArgs + _args.Req1 = req1 + var _result PingPongOnlyServiceEchoPingPongResult + if err = p.Client_().Call(ctx, "EchoPingPong", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +type StreamOnlyService interface { +} + +type StreamOnlyServiceClient struct { + c thrift.TClient +} + +func NewStreamOnlyServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *StreamOnlyServiceClient { + return &StreamOnlyServiceClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewStreamOnlyServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *StreamOnlyServiceClient { + return &StreamOnlyServiceClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewStreamOnlyServiceClient(c thrift.TClient) *StreamOnlyServiceClient { + return &StreamOnlyServiceClient{ + c: c, + } +} + +func (p *StreamOnlyServiceClient) Client_() thrift.TClient { + return p.c +} + type EchoServiceProcessor struct { processorMap map[string]thrift.TProcessorFunction handler EchoService @@ -1683,3 +1752,472 @@ func (p *EchoServicePingResult) DeepEqual(ano *EchoServicePingResult) bool { } return true } + +type PingPongOnlyServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler PingPongOnlyService +} + +func (p *PingPongOnlyServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *PingPongOnlyServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *PingPongOnlyServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewPingPongOnlyServiceProcessor(handler PingPongOnlyService) *PingPongOnlyServiceProcessor { + self := &PingPongOnlyServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self.AddToProcessorMap("EchoPingPong", &pingPongOnlyServiceProcessorEchoPingPong{handler: handler}) + return self +} +func (p *PingPongOnlyServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} + +type pingPongOnlyServiceProcessorEchoPingPong struct { + handler PingPongOnlyService +} + +func (p *pingPongOnlyServiceProcessorEchoPingPong) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := PingPongOnlyServiceEchoPingPongArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("EchoPingPong", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := PingPongOnlyServiceEchoPingPongResult{} + var retval *EchoResponse + if retval, err2 = p.handler.EchoPingPong(ctx, args.Req1); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoPingPong: "+err2.Error()) + oprot.WriteMessageBegin("EchoPingPong", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("EchoPingPong", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type PingPongOnlyServiceEchoPingPongArgs struct { + Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` +} + +func NewPingPongOnlyServiceEchoPingPongArgs() *PingPongOnlyServiceEchoPingPongArgs { + return &PingPongOnlyServiceEchoPingPongArgs{} +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) InitDefault() { + *p = PingPongOnlyServiceEchoPingPongArgs{} +} + +var PingPongOnlyServiceEchoPingPongArgs_Req1_DEFAULT *EchoRequest + +func (p *PingPongOnlyServiceEchoPingPongArgs) GetReq1() (v *EchoRequest) { + if !p.IsSetReq1() { + return PingPongOnlyServiceEchoPingPongArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *PingPongOnlyServiceEchoPingPongArgs) SetReq1(val *EchoRequest) { + p.Req1 = val +} + +var fieldIDToName_PingPongOnlyServiceEchoPingPongArgs = map[int16]string{ + 1: "req1", +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = NewEchoRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoPingPong_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PingPongOnlyServiceEchoPingPongArgs(%+v)", *p) + +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) DeepEqual(ano *PingPongOnlyServiceEchoPingPongArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) Field1DeepEqual(src *EchoRequest) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type PingPongOnlyServiceEchoPingPongResult struct { + Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` +} + +func NewPingPongOnlyServiceEchoPingPongResult() *PingPongOnlyServiceEchoPingPongResult { + return &PingPongOnlyServiceEchoPingPongResult{} +} + +func (p *PingPongOnlyServiceEchoPingPongResult) InitDefault() { + *p = PingPongOnlyServiceEchoPingPongResult{} +} + +var PingPongOnlyServiceEchoPingPongResult_Success_DEFAULT *EchoResponse + +func (p *PingPongOnlyServiceEchoPingPongResult) GetSuccess() (v *EchoResponse) { + if !p.IsSetSuccess() { + return PingPongOnlyServiceEchoPingPongResult_Success_DEFAULT + } + return p.Success +} +func (p *PingPongOnlyServiceEchoPingPongResult) SetSuccess(x interface{}) { + p.Success = x.(*EchoResponse) +} + +var fieldIDToName_PingPongOnlyServiceEchoPingPongResult = map[int16]string{ + 0: "success", +} + +func (p *PingPongOnlyServiceEchoPingPongResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *PingPongOnlyServiceEchoPingPongResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = NewEchoResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *PingPongOnlyServiceEchoPingPongResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoPingPong_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PingPongOnlyServiceEchoPingPongResult(%+v)", *p) + +} + +func (p *PingPongOnlyServiceEchoPingPongResult) DeepEqual(ano *PingPongOnlyServiceEchoPingPongResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *PingPongOnlyServiceEchoPingPongResult) Field0DeepEqual(src *EchoResponse) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type StreamOnlyServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler StreamOnlyService +} + +func (p *StreamOnlyServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *StreamOnlyServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *StreamOnlyServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewStreamOnlyServiceProcessor(handler StreamOnlyService) *StreamOnlyServiceProcessor { + self := &StreamOnlyServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + return self +} +func (p *StreamOnlyServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} diff --git a/thrift_streaming/kitex_gen_cross/echo/k-api.go b/thrift_streaming/kitex_gen_cross/echo/k-api.go index 4715987..91facb6 100644 --- a/thrift_streaming/kitex_gen_cross/echo/k-api.go +++ b/thrift_streaming/kitex_gen_cross/echo/k-api.go @@ -1139,6 +1139,264 @@ func (p *EchoServicePingResult) BLength() int { return l } +func (p *PingPongOnlyServiceEchoPingPongArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *PingPongOnlyServiceEchoPingPongArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPong_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoPingPong_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *PingPongOnlyServiceEchoPingPongResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *PingPongOnlyServiceEchoPingPongResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *PingPongOnlyServiceEchoPingPongResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPong_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *PingPongOnlyServiceEchoPingPongResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoPingPong_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *PingPongOnlyServiceEchoPingPongResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *PingPongOnlyServiceEchoPingPongResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + func (p *EchoServiceEchoPingPongArgs) GetFirstArgument() interface{} { return p.Req1 } @@ -1162,3 +1420,11 @@ func (p *EchoServicePingArgs) GetFirstArgument() interface{} { func (p *EchoServicePingResult) GetResult() interface{} { return nil } + +func (p *PingPongOnlyServiceEchoPingPongArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *PingPongOnlyServiceEchoPingPongResult) GetResult() interface{} { + return p.Success +} diff --git a/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/client.go b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/client.go new file mode 100644 index 0000000..5dcb3ca --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/client.go @@ -0,0 +1,49 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservice + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfo(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceClient) EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPong(ctx, req1) +} diff --git a/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/invoker.go b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/invoker.go new file mode 100644 index 0000000..1f68c53 --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.PingPongOnlyService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/pingpongonlyservice.go b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/pingpongonlyservice.go new file mode 100644 index 0000000..6f2f57b --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/pingpongonlyservice.go @@ -0,0 +1,75 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservice + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +func serviceInfo() *kitex.ServiceInfo { + return pingPongOnlyServiceServiceInfo +} + +var pingPongOnlyServiceServiceInfo = NewServiceInfo() + +func NewServiceInfo() *kitex.ServiceInfo { + serviceName := "PingPongOnlyService" + handlerType := (*echo.PingPongOnlyService)(nil) + methods := map[string]kitex.MethodInfo{ + "EchoPingPong": kitex.NewMethodInfo(echoPingPongHandler, newPingPongOnlyServiceEchoPingPongArgs, newPingPongOnlyServiceEchoPingPongResult, false), + } + extra := map[string]interface{}{ + "PackageName": "echo", + "ServiceFilePath": `idl/api.thrift`, + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPong(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceEchoPingPongArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongArgs() +} + +func newPingPongOnlyServiceEchoPingPongResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPong(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceEchoPingPongResult + if err = p.c.Call(ctx, "EchoPingPong", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/server.go b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/server.go new file mode 100644 index 0000000..0135790 --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package pingpongonlyservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.PingPongOnlyService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_cross/echo/streamonlyservice/client.go b/thrift_streaming/kitex_gen_cross/echo/streamonlyservice/client.go new file mode 100644 index 0000000..9e18d8c --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/streamonlyservice/client.go @@ -0,0 +1,40 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservice + +import ( + client "github.com/cloudwego/kitex/client" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfo(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceClient struct { + *kClient +} diff --git a/thrift_streaming/kitex_gen_cross/echo/streamonlyservice/invoker.go b/thrift_streaming/kitex_gen_cross/echo/streamonlyservice/invoker.go new file mode 100644 index 0000000..cd4887a --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/streamonlyservice/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.StreamOnlyService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_cross/echo/streamonlyservice/server.go b/thrift_streaming/kitex_gen_cross/echo/streamonlyservice/server.go new file mode 100644 index 0000000..c91c294 --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/streamonlyservice/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package streamonlyservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.StreamOnlyService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_cross/echo/streamonlyservice/streamonlyservice.go b/thrift_streaming/kitex_gen_cross/echo/streamonlyservice/streamonlyservice.go new file mode 100644 index 0000000..5aae155 --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/streamonlyservice/streamonlyservice.go @@ -0,0 +1,44 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +func serviceInfo() *kitex.ServiceInfo { + return streamOnlyServiceServiceInfo +} + +var streamOnlyServiceServiceInfo = NewServiceInfo() + +func NewServiceInfo() *kitex.ServiceInfo { + serviceName := "StreamOnlyService" + handlerType := (*echo.StreamOnlyService)(nil) + methods := map[string]kitex.MethodInfo{} + extra := map[string]interface{}{ + "PackageName": "echo", + "ServiceFilePath": `idl/api.thrift`, + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} diff --git a/thrift_streaming/kitex_gen_old/echo/api.go b/thrift_streaming/kitex_gen_old/echo/api.go index ddc7867..62dba46 100644 --- a/thrift_streaming/kitex_gen_old/echo/api.go +++ b/thrift_streaming/kitex_gen_old/echo/api.go @@ -624,6 +624,86 @@ func (p *EchoServiceClient) Ping(ctx context.Context) (err error) { return nil } +type PingPongOnlyService interface { + EchoPingPong(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) +} + +type PingPongOnlyServiceClient struct { + c thrift.TClient +} + +func NewPingPongOnlyServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *PingPongOnlyServiceClient { + return &PingPongOnlyServiceClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewPingPongOnlyServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *PingPongOnlyServiceClient { + return &PingPongOnlyServiceClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewPingPongOnlyServiceClient(c thrift.TClient) *PingPongOnlyServiceClient { + return &PingPongOnlyServiceClient{ + c: c, + } +} + +func (p *PingPongOnlyServiceClient) Client_() thrift.TClient { + return p.c +} + +func (p *PingPongOnlyServiceClient) EchoPingPong(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) { + var _args PingPongOnlyServiceEchoPingPongArgs + _args.Req1 = req1 + var _result PingPongOnlyServiceEchoPingPongResult + if err = p.Client_().Call(ctx, "EchoPingPong", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +type StreamOnlyService interface { + EchoBidirectional(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) +} + +type StreamOnlyServiceClient struct { + c thrift.TClient +} + +func NewStreamOnlyServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *StreamOnlyServiceClient { + return &StreamOnlyServiceClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewStreamOnlyServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *StreamOnlyServiceClient { + return &StreamOnlyServiceClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewStreamOnlyServiceClient(c thrift.TClient) *StreamOnlyServiceClient { + return &StreamOnlyServiceClient{ + c: c, + } +} + +func (p *StreamOnlyServiceClient) Client_() thrift.TClient { + return p.c +} + +func (p *StreamOnlyServiceClient) EchoBidirectional(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) { + var _args StreamOnlyServiceEchoBidirectionalArgs + _args.Req1 = req1 + var _result StreamOnlyServiceEchoBidirectionalResult + if err = p.Client_().Call(ctx, "EchoBidirectional", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + type EchoServiceProcessor struct { processorMap map[string]thrift.TProcessorFunction handler EchoService @@ -3283,3 +3363,861 @@ func (p *EchoServicePingResult) DeepEqual(ano *EchoServicePingResult) bool { } return true } + +type PingPongOnlyServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler PingPongOnlyService +} + +func (p *PingPongOnlyServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *PingPongOnlyServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *PingPongOnlyServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewPingPongOnlyServiceProcessor(handler PingPongOnlyService) *PingPongOnlyServiceProcessor { + self := &PingPongOnlyServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self.AddToProcessorMap("EchoPingPong", &pingPongOnlyServiceProcessorEchoPingPong{handler: handler}) + return self +} +func (p *PingPongOnlyServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} + +type pingPongOnlyServiceProcessorEchoPingPong struct { + handler PingPongOnlyService +} + +func (p *pingPongOnlyServiceProcessorEchoPingPong) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := PingPongOnlyServiceEchoPingPongArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("EchoPingPong", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := PingPongOnlyServiceEchoPingPongResult{} + var retval *EchoResponse + if retval, err2 = p.handler.EchoPingPong(ctx, args.Req1); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoPingPong: "+err2.Error()) + oprot.WriteMessageBegin("EchoPingPong", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("EchoPingPong", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type PingPongOnlyServiceEchoPingPongArgs struct { + Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` +} + +func NewPingPongOnlyServiceEchoPingPongArgs() *PingPongOnlyServiceEchoPingPongArgs { + return &PingPongOnlyServiceEchoPingPongArgs{} +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) InitDefault() { + *p = PingPongOnlyServiceEchoPingPongArgs{} +} + +var PingPongOnlyServiceEchoPingPongArgs_Req1_DEFAULT *EchoRequest + +func (p *PingPongOnlyServiceEchoPingPongArgs) GetReq1() (v *EchoRequest) { + if !p.IsSetReq1() { + return PingPongOnlyServiceEchoPingPongArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *PingPongOnlyServiceEchoPingPongArgs) SetReq1(val *EchoRequest) { + p.Req1 = val +} + +var fieldIDToName_PingPongOnlyServiceEchoPingPongArgs = map[int16]string{ + 1: "req1", +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = NewEchoRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoPingPong_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PingPongOnlyServiceEchoPingPongArgs(%+v)", *p) + +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) DeepEqual(ano *PingPongOnlyServiceEchoPingPongArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) Field1DeepEqual(src *EchoRequest) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type PingPongOnlyServiceEchoPingPongResult struct { + Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` +} + +func NewPingPongOnlyServiceEchoPingPongResult() *PingPongOnlyServiceEchoPingPongResult { + return &PingPongOnlyServiceEchoPingPongResult{} +} + +func (p *PingPongOnlyServiceEchoPingPongResult) InitDefault() { + *p = PingPongOnlyServiceEchoPingPongResult{} +} + +var PingPongOnlyServiceEchoPingPongResult_Success_DEFAULT *EchoResponse + +func (p *PingPongOnlyServiceEchoPingPongResult) GetSuccess() (v *EchoResponse) { + if !p.IsSetSuccess() { + return PingPongOnlyServiceEchoPingPongResult_Success_DEFAULT + } + return p.Success +} +func (p *PingPongOnlyServiceEchoPingPongResult) SetSuccess(x interface{}) { + p.Success = x.(*EchoResponse) +} + +var fieldIDToName_PingPongOnlyServiceEchoPingPongResult = map[int16]string{ + 0: "success", +} + +func (p *PingPongOnlyServiceEchoPingPongResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *PingPongOnlyServiceEchoPingPongResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = NewEchoResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *PingPongOnlyServiceEchoPingPongResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoPingPong_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PingPongOnlyServiceEchoPingPongResult(%+v)", *p) + +} + +func (p *PingPongOnlyServiceEchoPingPongResult) DeepEqual(ano *PingPongOnlyServiceEchoPingPongResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *PingPongOnlyServiceEchoPingPongResult) Field0DeepEqual(src *EchoResponse) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type StreamOnlyServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler StreamOnlyService +} + +func (p *StreamOnlyServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *StreamOnlyServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *StreamOnlyServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewStreamOnlyServiceProcessor(handler StreamOnlyService) *StreamOnlyServiceProcessor { + self := &StreamOnlyServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self.AddToProcessorMap("EchoBidirectional", &streamOnlyServiceProcessorEchoBidirectional{handler: handler}) + return self +} +func (p *StreamOnlyServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} + +type streamOnlyServiceProcessorEchoBidirectional struct { + handler StreamOnlyService +} + +func (p *streamOnlyServiceProcessorEchoBidirectional) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := StreamOnlyServiceEchoBidirectionalArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("EchoBidirectional", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := StreamOnlyServiceEchoBidirectionalResult{} + var retval *EchoResponse + if retval, err2 = p.handler.EchoBidirectional(ctx, args.Req1); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoBidirectional: "+err2.Error()) + oprot.WriteMessageBegin("EchoBidirectional", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("EchoBidirectional", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type StreamOnlyServiceEchoBidirectionalArgs struct { + Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` +} + +func NewStreamOnlyServiceEchoBidirectionalArgs() *StreamOnlyServiceEchoBidirectionalArgs { + return &StreamOnlyServiceEchoBidirectionalArgs{} +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) InitDefault() { + *p = StreamOnlyServiceEchoBidirectionalArgs{} +} + +var StreamOnlyServiceEchoBidirectionalArgs_Req1_DEFAULT *EchoRequest + +func (p *StreamOnlyServiceEchoBidirectionalArgs) GetReq1() (v *EchoRequest) { + if !p.IsSetReq1() { + return StreamOnlyServiceEchoBidirectionalArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *StreamOnlyServiceEchoBidirectionalArgs) SetReq1(val *EchoRequest) { + p.Req1 = val +} + +var fieldIDToName_StreamOnlyServiceEchoBidirectionalArgs = map[int16]string{ + 1: "req1", +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = NewEchoRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoBidirectional_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalArgs(%+v)", *p) + +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) DeepEqual(ano *StreamOnlyServiceEchoBidirectionalArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) Field1DeepEqual(src *EchoRequest) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type StreamOnlyServiceEchoBidirectionalResult struct { + Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` +} + +func NewStreamOnlyServiceEchoBidirectionalResult() *StreamOnlyServiceEchoBidirectionalResult { + return &StreamOnlyServiceEchoBidirectionalResult{} +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) InitDefault() { + *p = StreamOnlyServiceEchoBidirectionalResult{} +} + +var StreamOnlyServiceEchoBidirectionalResult_Success_DEFAULT *EchoResponse + +func (p *StreamOnlyServiceEchoBidirectionalResult) GetSuccess() (v *EchoResponse) { + if !p.IsSetSuccess() { + return StreamOnlyServiceEchoBidirectionalResult_Success_DEFAULT + } + return p.Success +} +func (p *StreamOnlyServiceEchoBidirectionalResult) SetSuccess(x interface{}) { + p.Success = x.(*EchoResponse) +} + +var fieldIDToName_StreamOnlyServiceEchoBidirectionalResult = map[int16]string{ + 0: "success", +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = NewEchoResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoBidirectional_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalResult(%+v)", *p) + +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) DeepEqual(ano *StreamOnlyServiceEchoBidirectionalResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) Field0DeepEqual(src *EchoResponse) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} diff --git a/thrift_streaming/kitex_gen_old/echo/k-api.go b/thrift_streaming/kitex_gen_old/echo/k-api.go index 8d6dc2b..d0db499 100644 --- a/thrift_streaming/kitex_gen_old/echo/k-api.go +++ b/thrift_streaming/kitex_gen_old/echo/k-api.go @@ -2171,6 +2171,522 @@ func (p *EchoServicePingResult) BLength() int { return l } +func (p *PingPongOnlyServiceEchoPingPongArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *PingPongOnlyServiceEchoPingPongArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPong_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoPingPong_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *PingPongOnlyServiceEchoPingPongResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *PingPongOnlyServiceEchoPingPongResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *PingPongOnlyServiceEchoPingPongResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPong_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *PingPongOnlyServiceEchoPingPongResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoPingPong_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *PingPongOnlyServiceEchoPingPongResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *PingPongOnlyServiceEchoPingPongResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *StreamOnlyServiceEchoBidirectionalArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectional_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoBidirectional_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *StreamOnlyServiceEchoBidirectionalResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectional_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoBidirectional_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + func (p *EchoServiceEchoBidirectionalArgs) GetFirstArgument() interface{} { return p.Req1 } @@ -2226,3 +2742,19 @@ func (p *EchoServicePingArgs) GetFirstArgument() interface{} { func (p *EchoServicePingResult) GetResult() interface{} { return nil } + +func (p *PingPongOnlyServiceEchoPingPongArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *PingPongOnlyServiceEchoPingPongResult) GetResult() interface{} { + return p.Success +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) GetResult() interface{} { + return p.Success +} diff --git a/thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/client.go b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/client.go new file mode 100644 index 0000000..0a49be0 --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/client.go @@ -0,0 +1,49 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservice + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfo(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceClient) EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPong(ctx, req1) +} diff --git a/thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/invoker.go b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/invoker.go new file mode 100644 index 0000000..895c00a --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.PingPongOnlyService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/pingpongonlyservice.go b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/pingpongonlyservice.go new file mode 100644 index 0000000..498d0a3 --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/pingpongonlyservice.go @@ -0,0 +1,75 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservice + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +func serviceInfo() *kitex.ServiceInfo { + return pingPongOnlyServiceServiceInfo +} + +var pingPongOnlyServiceServiceInfo = NewServiceInfo() + +func NewServiceInfo() *kitex.ServiceInfo { + serviceName := "PingPongOnlyService" + handlerType := (*echo.PingPongOnlyService)(nil) + methods := map[string]kitex.MethodInfo{ + "EchoPingPong": kitex.NewMethodInfo(echoPingPongHandler, newPingPongOnlyServiceEchoPingPongArgs, newPingPongOnlyServiceEchoPingPongResult, false), + } + extra := map[string]interface{}{ + "PackageName": "echo", + "ServiceFilePath": `idl/api.thrift`, + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPong(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceEchoPingPongArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongArgs() +} + +func newPingPongOnlyServiceEchoPingPongResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPong(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceEchoPingPongResult + if err = p.c.Call(ctx, "EchoPingPong", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/server.go b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/server.go new file mode 100644 index 0000000..9cee197 --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package pingpongonlyservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.PingPongOnlyService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_old/echo/streamonlyservice/client.go b/thrift_streaming/kitex_gen_old/echo/streamonlyservice/client.go new file mode 100644 index 0000000..bb5c0b6 --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/streamonlyservice/client.go @@ -0,0 +1,49 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservice + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoBidirectional(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfo(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceClient struct { + *kClient +} + +func (p *kStreamOnlyServiceClient) EchoBidirectional(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoBidirectional(ctx, req1) +} diff --git a/thrift_streaming/kitex_gen_old/echo/streamonlyservice/invoker.go b/thrift_streaming/kitex_gen_old/echo/streamonlyservice/invoker.go new file mode 100644 index 0000000..61e659e --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/streamonlyservice/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.StreamOnlyService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_old/echo/streamonlyservice/server.go b/thrift_streaming/kitex_gen_old/echo/streamonlyservice/server.go new file mode 100644 index 0000000..0195105 --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/streamonlyservice/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package streamonlyservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.StreamOnlyService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_old/echo/streamonlyservice/streamonlyservice.go b/thrift_streaming/kitex_gen_old/echo/streamonlyservice/streamonlyservice.go new file mode 100644 index 0000000..147b8f8 --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/streamonlyservice/streamonlyservice.go @@ -0,0 +1,75 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservice + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +func serviceInfo() *kitex.ServiceInfo { + return streamOnlyServiceServiceInfo +} + +var streamOnlyServiceServiceInfo = NewServiceInfo() + +func NewServiceInfo() *kitex.ServiceInfo { + serviceName := "StreamOnlyService" + handlerType := (*echo.StreamOnlyService)(nil) + methods := map[string]kitex.MethodInfo{ + "EchoBidirectional": kitex.NewMethodInfo(echoBidirectionalHandler, newStreamOnlyServiceEchoBidirectionalArgs, newStreamOnlyServiceEchoBidirectionalResult, false), + } + extra := map[string]interface{}{ + "PackageName": "echo", + "ServiceFilePath": `idl/api.thrift`, + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoBidirectionalHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.StreamOnlyServiceEchoBidirectionalArgs) + realResult := result.(*echo.StreamOnlyServiceEchoBidirectionalResult) + success, err := handler.(echo.StreamOnlyService).EchoBidirectional(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newStreamOnlyServiceEchoBidirectionalArgs() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalArgs() +} + +func newStreamOnlyServiceEchoBidirectionalResult() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoBidirectional(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.StreamOnlyServiceEchoBidirectionalArgs + _args.Req1 = req1 + var _result echo.StreamOnlyServiceEchoBidirectionalResult + if err = p.c.Call(ctx, "EchoBidirectional", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen_slim/combine/a/a.go b/thrift_streaming/kitex_gen_slim/combine/a/a.go new file mode 100644 index 0000000..bdca2bb --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine/a/a.go @@ -0,0 +1,125 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package a + +import ( + "context" + "errors" + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/combine" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "Foo": kitex.NewMethodInfo( + fooHandler, + newAFooArgs, + newAFooResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), +} + +var ( + aServiceInfo = NewServiceInfo() + aServiceInfoForClient = NewServiceInfoForClient() + aServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return aServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return aServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return aServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "A" + handlerType := (*combine.A)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "combine", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func fooHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*combine.AFooArgs) + realResult := result.(*combine.AFooResult) + success, err := handler.(combine.A).Foo(ctx, realArg.Req) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newAFooArgs() interface{} { + return combine.NewAFooArgs() +} + +func newAFooResult() interface{} { + return combine.NewAFooResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) Foo(ctx context.Context, req *combine.Req) (r *combine.Rsp, err error) { + var _args combine.AFooArgs + _args.Req = req + var _result combine.AFooResult + if err = p.c.Call(ctx, "Foo", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen_slim/combine/a/client.go b/thrift_streaming/kitex_gen_slim/combine/a/client.go new file mode 100644 index 0000000..2dd27ff --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine/a/client.go @@ -0,0 +1,49 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package a + +import ( + "context" + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/combine" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + Foo(ctx context.Context, req *combine.Req, callOptions ...callopt.Option) (r *combine.Rsp, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kAClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kAClient struct { + *kClient +} + +func (p *kAClient) Foo(ctx context.Context, req *combine.Req, callOptions ...callopt.Option) (r *combine.Rsp, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.Foo(ctx, req) +} diff --git a/thrift_streaming/kitex_gen_slim/combine/a/invoker.go b/thrift_streaming/kitex_gen_slim/combine/a/invoker.go new file mode 100644 index 0000000..2019b6a --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine/a/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package a + +import ( + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/combine" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler combine.A, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_slim/combine/a/server.go b/thrift_streaming/kitex_gen_slim/combine/a/server.go new file mode 100644 index 0000000..2e41031 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine/a/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package a + +import ( + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/combine" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler combine.A, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_slim/combine/b/b.go b/thrift_streaming/kitex_gen_slim/combine/b/b.go new file mode 100644 index 0000000..a6b0c99 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine/b/b.go @@ -0,0 +1,155 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package b + +import ( + "context" + "errors" + "fmt" + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/combine" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "Bar": kitex.NewMethodInfo( + barHandler, + newBBarArgs, + newBBarResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + bServiceInfo = NewServiceInfo() + bServiceInfoForClient = NewServiceInfoForClient() + bServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return bServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return bServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return bServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "B" + handlerType := (*combine.B)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "combine", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func barHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("B.Bar is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &bBarServer{st.Stream} + return handler.(combine.B).Bar(stream) +} + +type bBarClient struct { + streaming.Stream +} + +func (x *bBarClient) Send(m *combine.Req) error { + return x.Stream.SendMsg(m) +} +func (x *bBarClient) Recv() (*combine.Rsp, error) { + m := new(combine.Rsp) + return m, x.Stream.RecvMsg(m) +} + +type bBarServer struct { + streaming.Stream +} + +func (x *bBarServer) Send(m *combine.Rsp) error { + return x.Stream.SendMsg(m) +} + +func (x *bBarServer) Recv() (*combine.Req, error) { + m := new(combine.Req) + return m, x.Stream.RecvMsg(m) +} + +func newBBarArgs() interface{} { + return combine.NewBBarArgs() +} + +func newBBarResult() interface{} { + return combine.NewBBarResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) Bar(ctx context.Context) (B_BarClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "Bar", nil, res) + if err != nil { + return nil, err + } + stream := &bBarClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen_slim/combine/b/client.go b/thrift_streaming/kitex_gen_slim/combine/b/client.go new file mode 100644 index 0000000..14535a0 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine/b/client.go @@ -0,0 +1,92 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package b + +import ( + "context" + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/combine" + client "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + Bar(ctx context.Context, callOptions ...streamcall.Option) (stream B_BarClient, err error) +} + +type B_BarClient interface { + streaming.Stream + Send(*combine.Req) error + Recv() (*combine.Rsp, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kBClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kBClient struct { + *kClient +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kBStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kBStreamClient struct { + *kClient +} + +func (p *kBStreamClient) Bar(ctx context.Context, callOptions ...streamcall.Option) (stream B_BarClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.Bar(ctx) +} diff --git a/thrift_streaming/kitex_gen_slim/combine/b/invoker.go b/thrift_streaming/kitex_gen_slim/combine/b/invoker.go new file mode 100644 index 0000000..0873b32 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine/b/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package b + +import ( + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/combine" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler combine.B, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_slim/combine/b/server.go b/thrift_streaming/kitex_gen_slim/combine/b/server.go new file mode 100644 index 0000000..f3ae6fb --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine/b/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package b + +import ( + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/combine" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler combine.B, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_slim/combine/combine.go b/thrift_streaming/kitex_gen_slim/combine/combine.go new file mode 100644 index 0000000..5b8e843 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine/combine.go @@ -0,0 +1,77 @@ +// Code generated by thriftgo (0.3.5). DO NOT EDIT. + +package combine + +import ( + "context" + "fmt" + "github.com/cloudwego/kitex/pkg/streaming" +) + +type Req struct { + Message string `thrift:"message,1,required" frugal:"1,required,string" json:"message"` +} + +func NewReq() *Req { + return &Req{} +} + +func (p *Req) InitDefault() { + *p = Req{} +} + +func (p *Req) GetMessage() (v string) { + return p.Message +} +func (p *Req) SetMessage(val string) { + p.Message = val +} + +func (p *Req) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Req(%+v)", *p) +} + +type Rsp struct { + Message string `thrift:"message,1,required" frugal:"1,required,string" json:"message"` +} + +func NewRsp() *Rsp { + return &Rsp{} +} + +func (p *Rsp) InitDefault() { + *p = Rsp{} +} + +func (p *Rsp) GetMessage() (v string) { + return p.Message +} +func (p *Rsp) SetMessage(val string) { + p.Message = val +} + +func (p *Rsp) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Rsp(%+v)", *p) +} + +type A interface { + Foo(ctx context.Context, req *Req) (r *Rsp, err error) +} + +type B interface { + Bar(stream B_BarServer) (err error) +} + +type B_BarServer interface { + streaming.Stream + + Recv() (*Req, error) + + Send(*Rsp) error +} diff --git a/thrift_streaming/kitex_gen_slim/combine/combineservice/client.go b/thrift_streaming/kitex_gen_slim/combine/combineservice/client.go new file mode 100644 index 0000000..e4d3722 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine/combineservice/client.go @@ -0,0 +1,99 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combineservice + +import ( + "context" + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/combine" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + Foo(ctx context.Context, req *combine.Req, callOptions ...callopt.Option) (r *combine.Rsp, err error) +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + Bar(ctx context.Context, callOptions ...streamcall.Option) (stream B_BarClient, err error) +} + +type B_BarClient interface { + streaming.Stream + Send(*combine.Req) error + Recv() (*combine.Rsp, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kCombineServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kCombineServiceClient struct { + *kClient +} + +func (p *kCombineServiceClient) Foo(ctx context.Context, req *combine.Req, callOptions ...callopt.Option) (r *combine.Rsp, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.Foo(ctx, req) +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kCombineServiceStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kCombineServiceStreamClient struct { + *kClient +} + +func (p *kCombineServiceStreamClient) Bar(ctx context.Context, callOptions ...streamcall.Option) (stream B_BarClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.Bar(ctx) +} diff --git a/thrift_streaming/kitex_gen_slim/combine/combineservice/combineservice.go b/thrift_streaming/kitex_gen_slim/combine/combineservice/combineservice.go new file mode 100644 index 0000000..42222e0 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine/combineservice/combineservice.go @@ -0,0 +1,197 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combineservice + +import ( + "context" + "errors" + "fmt" + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/combine" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +type CombineService interface { + combine.A + combine.B +} + +var serviceMethods = map[string]kitex.MethodInfo{ + "Foo": kitex.NewMethodInfo( + fooHandler, + newAFooArgs, + newAFooResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "Bar": kitex.NewMethodInfo( + barHandler, + newBBarArgs, + newBBarResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + combineServiceServiceInfo = NewServiceInfo() + combineServiceServiceInfoForClient = NewServiceInfoForClient() + combineServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return combineServiceServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return combineServiceServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return combineServiceServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "CombineService" + handlerType := (*CombineService)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "combine", + } + extra["combine_service"] = true + extra["combined_service_list"] = []string{"A", "B"} + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func fooHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*combine.AFooArgs) + realResult := result.(*combine.AFooResult) + success, err := handler.(combine.A).Foo(ctx, realArg.Req) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newAFooArgs() interface{} { + return combine.NewAFooArgs() +} + +func newAFooResult() interface{} { + return combine.NewAFooResult() +} + +func barHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("B.Bar is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &bBarServer{st.Stream} + return handler.(combine.B).Bar(stream) +} + +type bBarClient struct { + streaming.Stream +} + +func (x *bBarClient) Send(m *combine.Req) error { + return x.Stream.SendMsg(m) +} +func (x *bBarClient) Recv() (*combine.Rsp, error) { + m := new(combine.Rsp) + return m, x.Stream.RecvMsg(m) +} + +type bBarServer struct { + streaming.Stream +} + +func (x *bBarServer) Send(m *combine.Rsp) error { + return x.Stream.SendMsg(m) +} + +func (x *bBarServer) Recv() (*combine.Req, error) { + m := new(combine.Req) + return m, x.Stream.RecvMsg(m) +} + +func newBBarArgs() interface{} { + return combine.NewBBarArgs() +} + +func newBBarResult() interface{} { + return combine.NewBBarResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) Foo(ctx context.Context, req *combine.Req) (r *combine.Rsp, err error) { + var _args combine.AFooArgs + _args.Req = req + var _result combine.AFooResult + if err = p.c.Call(ctx, "Foo", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) Bar(ctx context.Context) (B_BarClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "Bar", nil, res) + if err != nil { + return nil, err + } + stream := &bBarClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen_slim/combine/combineservice/invoker.go b/thrift_streaming/kitex_gen_slim/combine/combineservice/invoker.go new file mode 100644 index 0000000..5605702 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine/combineservice/invoker.go @@ -0,0 +1,23 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combineservice + +import ( + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler CombineService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_slim/combine/combineservice/server.go b/thrift_streaming/kitex_gen_slim/combine/combineservice/server.go new file mode 100644 index 0000000..39f663b --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine/combineservice/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package combineservice + +import ( + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler CombineService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_slim/combine/k-combine.go b/thrift_streaming/kitex_gen_slim/combine/k-combine.go new file mode 100644 index 0000000..ebc4ff2 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine/k-combine.go @@ -0,0 +1,173 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combine + +import ( + "bytes" + "fmt" + "reflect" + "strings" + + "github.com/apache/thrift/lib/go/thrift" +) + +// unused protection +var ( + _ = fmt.Formatter(nil) + _ = (*bytes.Buffer)(nil) + _ = (*strings.Builder)(nil) + _ = reflect.Type(nil) + _ = thrift.TProtocol(nil) +) + +type AFooArgs struct { + Req *Req `thrift:"req,1" frugal:"1,default,Req" json:"req"` +} + +func NewAFooArgs() *AFooArgs { + return &AFooArgs{} +} + +func (p *AFooArgs) InitDefault() { + *p = AFooArgs{} +} + +var AFooArgs_Req_DEFAULT *Req + +func (p *AFooArgs) GetReq() (v *Req) { + if !p.IsSetReq() { + return AFooArgs_Req_DEFAULT + } + return p.Req +} +func (p *AFooArgs) SetReq(val *Req) { + p.Req = val +} + +func (p *AFooArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *AFooArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AFooArgs(%+v)", *p) +} +func (p *AFooArgs) GetFirstArgument() interface{} { + return p.Req +} + +type AFooResult struct { + Success *Rsp `thrift:"success,0,optional" frugal:"0,optional,Rsp" json:"success,omitempty"` +} + +func NewAFooResult() *AFooResult { + return &AFooResult{} +} + +func (p *AFooResult) InitDefault() { + *p = AFooResult{} +} + +var AFooResult_Success_DEFAULT *Rsp + +func (p *AFooResult) GetSuccess() (v *Rsp) { + if !p.IsSetSuccess() { + return AFooResult_Success_DEFAULT + } + return p.Success +} +func (p *AFooResult) SetSuccess(x interface{}) { + p.Success = x.(*Rsp) +} + +func (p *AFooResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AFooResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AFooResult(%+v)", *p) +} +func (p *AFooResult) GetResult() interface{} { + return p.Success +} + +type BBarArgs struct { + Req *Req `thrift:"req,1" frugal:"1,default,Req" json:"req"` +} + +func NewBBarArgs() *BBarArgs { + return &BBarArgs{} +} + +func (p *BBarArgs) InitDefault() { + *p = BBarArgs{} +} + +var BBarArgs_Req_DEFAULT *Req + +func (p *BBarArgs) GetReq() (v *Req) { + if !p.IsSetReq() { + return BBarArgs_Req_DEFAULT + } + return p.Req +} +func (p *BBarArgs) SetReq(val *Req) { + p.Req = val +} + +func (p *BBarArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *BBarArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("BBarArgs(%+v)", *p) +} +func (p *BBarArgs) GetFirstArgument() interface{} { + return p.Req +} + +type BBarResult struct { + Success *Rsp `thrift:"success,0,optional" frugal:"0,optional,Rsp" json:"success,omitempty"` +} + +func NewBBarResult() *BBarResult { + return &BBarResult{} +} + +func (p *BBarResult) InitDefault() { + *p = BBarResult{} +} + +var BBarResult_Success_DEFAULT *Rsp + +func (p *BBarResult) GetSuccess() (v *Rsp) { + if !p.IsSetSuccess() { + return BBarResult_Success_DEFAULT + } + return p.Success +} +func (p *BBarResult) SetSuccess(x interface{}) { + p.Success = x.(*Rsp) +} + +func (p *BBarResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *BBarResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("BBarResult(%+v)", *p) +} +func (p *BBarResult) GetResult() interface{} { + return p.Success +} diff --git a/thrift_streaming/kitex_gen_slim/combine/k-consts.go b/thrift_streaming/kitex_gen_slim/combine/k-consts.go new file mode 100644 index 0000000..653b83e --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine/k-consts.go @@ -0,0 +1,4 @@ +package combine + +// KitexUnusedProtection is used to prevent 'imported and not used' error. +var KitexUnusedProtection = struct{}{} diff --git a/thrift_streaming/kitex_gen_slim/echo/api.go b/thrift_streaming/kitex_gen_slim/echo/api.go index f47ce7a..6dd1ccf 100644 --- a/thrift_streaming/kitex_gen_slim/echo/api.go +++ b/thrift_streaming/kitex_gen_slim/echo/api.go @@ -125,6 +125,22 @@ type EchoService_EchoServerServer interface { Send(*EchoResponse) error } +type PingPongOnlyService interface { + EchoPingPong(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) +} + +type StreamOnlyService interface { + EchoBidirectional(stream StreamOnlyService_EchoBidirectionalServer) (err error) +} + +type StreamOnlyService_EchoBidirectionalServer interface { + streaming.Stream + + Recv() (*EchoRequest, error) + + Send(*EchoResponse) error +} + // exceptions of methods in EchoService. var ( _ error = (*EchoException)(nil) diff --git a/thrift_streaming/kitex_gen_slim/echo/k-api.go b/thrift_streaming/kitex_gen_slim/echo/k-api.go index e2ba3f1..5a77980 100644 --- a/thrift_streaming/kitex_gen_slim/echo/k-api.go +++ b/thrift_streaming/kitex_gen_slim/echo/k-api.go @@ -534,3 +534,155 @@ func (p *EchoServicePingResult) String() string { func (p *EchoServicePingResult) GetResult() interface{} { return nil } + +type PingPongOnlyServiceEchoPingPongArgs struct { + Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` +} + +func NewPingPongOnlyServiceEchoPingPongArgs() *PingPongOnlyServiceEchoPingPongArgs { + return &PingPongOnlyServiceEchoPingPongArgs{} +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) InitDefault() { + *p = PingPongOnlyServiceEchoPingPongArgs{} +} + +var PingPongOnlyServiceEchoPingPongArgs_Req1_DEFAULT *EchoRequest + +func (p *PingPongOnlyServiceEchoPingPongArgs) GetReq1() (v *EchoRequest) { + if !p.IsSetReq1() { + return PingPongOnlyServiceEchoPingPongArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *PingPongOnlyServiceEchoPingPongArgs) SetReq1(val *EchoRequest) { + p.Req1 = val +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *PingPongOnlyServiceEchoPingPongArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PingPongOnlyServiceEchoPingPongArgs(%+v)", *p) +} +func (p *PingPongOnlyServiceEchoPingPongArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +type PingPongOnlyServiceEchoPingPongResult struct { + Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` +} + +func NewPingPongOnlyServiceEchoPingPongResult() *PingPongOnlyServiceEchoPingPongResult { + return &PingPongOnlyServiceEchoPingPongResult{} +} + +func (p *PingPongOnlyServiceEchoPingPongResult) InitDefault() { + *p = PingPongOnlyServiceEchoPingPongResult{} +} + +var PingPongOnlyServiceEchoPingPongResult_Success_DEFAULT *EchoResponse + +func (p *PingPongOnlyServiceEchoPingPongResult) GetSuccess() (v *EchoResponse) { + if !p.IsSetSuccess() { + return PingPongOnlyServiceEchoPingPongResult_Success_DEFAULT + } + return p.Success +} +func (p *PingPongOnlyServiceEchoPingPongResult) SetSuccess(x interface{}) { + p.Success = x.(*EchoResponse) +} + +func (p *PingPongOnlyServiceEchoPingPongResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *PingPongOnlyServiceEchoPingPongResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PingPongOnlyServiceEchoPingPongResult(%+v)", *p) +} +func (p *PingPongOnlyServiceEchoPingPongResult) GetResult() interface{} { + return p.Success +} + +type StreamOnlyServiceEchoBidirectionalArgs struct { + Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` +} + +func NewStreamOnlyServiceEchoBidirectionalArgs() *StreamOnlyServiceEchoBidirectionalArgs { + return &StreamOnlyServiceEchoBidirectionalArgs{} +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) InitDefault() { + *p = StreamOnlyServiceEchoBidirectionalArgs{} +} + +var StreamOnlyServiceEchoBidirectionalArgs_Req1_DEFAULT *EchoRequest + +func (p *StreamOnlyServiceEchoBidirectionalArgs) GetReq1() (v *EchoRequest) { + if !p.IsSetReq1() { + return StreamOnlyServiceEchoBidirectionalArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *StreamOnlyServiceEchoBidirectionalArgs) SetReq1(val *EchoRequest) { + p.Req1 = val +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *StreamOnlyServiceEchoBidirectionalArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalArgs(%+v)", *p) +} +func (p *StreamOnlyServiceEchoBidirectionalArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +type StreamOnlyServiceEchoBidirectionalResult struct { + Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` +} + +func NewStreamOnlyServiceEchoBidirectionalResult() *StreamOnlyServiceEchoBidirectionalResult { + return &StreamOnlyServiceEchoBidirectionalResult{} +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) InitDefault() { + *p = StreamOnlyServiceEchoBidirectionalResult{} +} + +var StreamOnlyServiceEchoBidirectionalResult_Success_DEFAULT *EchoResponse + +func (p *StreamOnlyServiceEchoBidirectionalResult) GetSuccess() (v *EchoResponse) { + if !p.IsSetSuccess() { + return StreamOnlyServiceEchoBidirectionalResult_Success_DEFAULT + } + return p.Success +} +func (p *StreamOnlyServiceEchoBidirectionalResult) SetSuccess(x interface{}) { + p.Success = x.(*EchoResponse) +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *StreamOnlyServiceEchoBidirectionalResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalResult(%+v)", *p) +} +func (p *StreamOnlyServiceEchoBidirectionalResult) GetResult() interface{} { + return p.Success +} diff --git a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/client.go b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/client.go new file mode 100644 index 0000000..ac9f6f8 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/client.go @@ -0,0 +1,49 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservice + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceClient) EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPong(ctx, req1) +} diff --git a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/invoker.go b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/invoker.go new file mode 100644 index 0000000..16af7d3 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.PingPongOnlyService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/pingpongonlyservice.go b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/pingpongonlyservice.go new file mode 100644 index 0000000..1c8ada6 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/pingpongonlyservice.go @@ -0,0 +1,125 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservice + +import ( + "context" + "errors" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoPingPong": kitex.NewMethodInfo( + echoPingPongHandler, + newPingPongOnlyServiceEchoPingPongArgs, + newPingPongOnlyServiceEchoPingPongResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), +} + +var ( + pingPongOnlyServiceServiceInfo = NewServiceInfo() + pingPongOnlyServiceServiceInfoForClient = NewServiceInfoForClient() + pingPongOnlyServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return pingPongOnlyServiceServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return pingPongOnlyServiceServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return pingPongOnlyServiceServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "PingPongOnlyService" + handlerType := (*echo.PingPongOnlyService)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "echo", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPong(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceEchoPingPongArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongArgs() +} + +func newPingPongOnlyServiceEchoPingPongResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPong(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceEchoPingPongResult + if err = p.c.Call(ctx, "EchoPingPong", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/server.go b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/server.go new file mode 100644 index 0000000..c9df7d4 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package pingpongonlyservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.PingPongOnlyService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/client.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/client.go new file mode 100644 index 0000000..618bc55 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/client.go @@ -0,0 +1,92 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservice + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + client "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectional(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalClient, err error) +} + +type StreamOnlyService_EchoBidirectionalClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceClient struct { + *kClient +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceStreamClient struct { + *kClient +} + +func (p *kStreamOnlyServiceStreamClient) EchoBidirectional(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectional(ctx) +} diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/invoker.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/invoker.go new file mode 100644 index 0000000..b46ad14 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.StreamOnlyService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/server.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/server.go new file mode 100644 index 0000000..b3d4f95 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package streamonlyservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.StreamOnlyService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/streamonlyservice.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/streamonlyservice.go new file mode 100644 index 0000000..6a65c23 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/streamonlyservice.go @@ -0,0 +1,155 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservice + +import ( + "context" + "errors" + "fmt" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoBidirectional": kitex.NewMethodInfo( + echoBidirectionalHandler, + newStreamOnlyServiceEchoBidirectionalArgs, + newStreamOnlyServiceEchoBidirectionalResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + streamOnlyServiceServiceInfo = NewServiceInfo() + streamOnlyServiceServiceInfoForClient = NewServiceInfoForClient() + streamOnlyServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return streamOnlyServiceServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return streamOnlyServiceServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return streamOnlyServiceServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "StreamOnlyService" + handlerType := (*echo.StreamOnlyService)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "echo", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoBidirectionalHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("StreamOnlyService.EchoBidirectional is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &streamOnlyServiceEchoBidirectionalServer{st.Stream} + return handler.(echo.StreamOnlyService).EchoBidirectional(stream) +} + +type streamOnlyServiceEchoBidirectionalClient struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *streamOnlyServiceEchoBidirectionalClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type streamOnlyServiceEchoBidirectionalServer struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *streamOnlyServiceEchoBidirectionalServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newStreamOnlyServiceEchoBidirectionalArgs() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalArgs() +} + +func newStreamOnlyServiceEchoBidirectionalResult() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoBidirectional(ctx context.Context) (StreamOnlyService_EchoBidirectionalClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectional", nil, res) + if err != nil { + return nil, err + } + stream := &streamOnlyServiceEchoBidirectionalClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/main_test.go b/thrift_streaming/main_test.go index 8b3c0e4..5c5e7c0 100644 --- a/thrift_streaming/main_test.go +++ b/thrift_streaming/main_test.go @@ -21,6 +21,7 @@ import ( "testing" "time" + "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine/combineservice" "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo/echoservice" "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/grpc_pb" @@ -64,6 +65,19 @@ func RunThriftServer(handler echo.EchoService, addr string, opts ...server.Optio return svr } +func RunCombineThriftServer(handler combineservice.CombineService, addr string, opts ...server.Option) server.Server { + opts = append(opts, WithServerAddr(addr)) + opts = append(opts, server.WithExitWaitTime(time.Millisecond*10)) + svr := combineservice.NewServer(handler, opts...) + go func() { + if err := svr.Run(); err != nil { + panic(err) + } + }() + WaitServer(addr) + return svr +} + func RunThriftCrossServer(handler cross_echo.EchoService, addr string, opts ...server.Option) server.Server { opts = append(opts, WithServerAddr(addr)) opts = append(opts, server.WithExitWaitTime(time.Millisecond*10)) @@ -110,6 +124,7 @@ var ( slimAddr = addrAllocator() grpcAddr = addrAllocator() pbAddr = addrAllocator() + combineAddr = addrAllocator() ) func addrAllocator() string { @@ -119,23 +134,26 @@ func addrAllocator() string { } func TestMain(m *testing.M) { - var thriftSvr, thriftCrossSvr, slimServer, grpcServer, pbServer server.Server + var thriftSvr, thriftCrossSvr, slimServer, grpcServer, pbServer, combineServer server.Server go func() { thriftSvr = RunThriftServer(&EchoServiceImpl{}, thriftAddr) }() go func() { thriftCrossSvr = RunThriftCrossServer(&CrossEchoServiceImpl{}, crossAddr) }() go func() { grpcServer = RunGRPCPBServer(&GRPCPBServiceImpl{}, grpcAddr) }() go func() { pbServer = RunKitexPBServer(&KitexPBServiceImpl{}, pbAddr) }() go func() { slimServer = RunSlimThriftServer(&SlimEchoServiceImpl{}, slimAddr) }() + go func() { combineServer = RunCombineThriftServer(&CombineServiceImpl{}, combineAddr) }() defer func() { go thriftSvr.Stop() go grpcServer.Stop() go pbServer.Stop() go slimServer.Stop() go thriftCrossSvr.Stop() + go combineServer.Stop() }() WaitServer(thriftAddr) WaitServer(crossAddr) WaitServer(grpcAddr) WaitServer(pbAddr) WaitServer(slimAddr) + WaitServer(combineAddr) m.Run() } diff --git a/thrift_streaming/thrift_test.go b/thrift_streaming/thrift_test.go index 48b649b..3345f53 100644 --- a/thrift_streaming/thrift_test.go +++ b/thrift_streaming/thrift_test.go @@ -26,6 +26,8 @@ import ( "time" "github.com/bytedance/gopkg/cloud/metainfo" + "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine/combineservice" "github.com/cloudwego/kitex/client" "github.com/cloudwego/kitex/client/streamclient" "github.com/cloudwego/kitex/pkg/endpoint" @@ -861,6 +863,27 @@ func TestThriftStreamingMetaData(t *testing.T) { }) } +func TestCombineService(t *testing.T) { + t.Run("combine-foo", func(t *testing.T) { + cli := combineservice.MustNewClient("combineservice", client.WithHostPorts(combineAddr)) + rsp, err := cli.Foo(context.Background(), &combine.Req{Message: "hello"}) + test.Assert(t, err == nil, err) + test.Assert(t, rsp.Message == "hello", rsp.Message) + }) + t.Run("combine-bar", func(t *testing.T) { + streamCli := combineservice.MustNewStreamClient("combineservice", streamclient.WithHostPorts(combineAddr)) + stream, err := streamCli.Bar(context.Background()) + test.Assert(t, err == nil, err) + err = stream.Send(&combine.Req{Message: "hello"}) + test.Assert(t, err == nil, err) + rsp, err := stream.Recv() + test.Assert(t, err == nil, err) + test.Assert(t, rsp.Message == "hello", rsp.Message) + err = stream.Close() + test.Assert(t, err == nil, err) + }) +} + func TestThriftStreamLogID(t *testing.T) { defer logid.SetLogIDGenerator(logid.DefaultLogIDGenerator) From 3b1ef78ec97adf1ffdecf04e86763cb40adbe3ef Mon Sep 17 00:00:00 2001 From: Felix021 Date: Wed, 17 Jan 2024 10:30:39 +0800 Subject: [PATCH 3/7] fix: commit missing files for combine-service (#51) --- thrift_streaming/kitex_gen/combine/a/a.go | 125 ++ .../kitex_gen/combine/a/client.go | 49 + .../kitex_gen/combine/a/invoker.go | 24 + .../kitex_gen/combine/a/server.go | 21 + thrift_streaming/kitex_gen/combine/b/b.go | 155 ++ .../kitex_gen/combine/b/client.go | 92 ++ .../kitex_gen/combine/b/invoker.go | 24 + .../kitex_gen/combine/b/server.go | 21 + thrift_streaming/kitex_gen/combine/combine.go | 1251 +++++++++++++++++ .../combine/combineservice/client.go | 99 ++ .../combine/combineservice/combineservice.go | 197 +++ .../combine/combineservice/invoker.go | 23 + .../combine/combineservice/server.go | 20 + .../kitex_gen/combine/k-combine.go | 832 +++++++++++ .../kitex_gen/combine/k-consts.go | 4 + .../echo/pingpongonlyservice/client.go | 49 + .../echo/pingpongonlyservice/invoker.go | 24 + .../pingpongonlyservice.go | 125 ++ .../echo/pingpongonlyservice/server.go | 21 + .../echo/streamonlyservice/client.go | 92 ++ .../echo/streamonlyservice/invoker.go | 24 + .../echo/streamonlyservice/server.go | 21 + .../streamonlyservice/streamonlyservice.go | 155 ++ 23 files changed, 3448 insertions(+) create mode 100644 thrift_streaming/kitex_gen/combine/a/a.go create mode 100644 thrift_streaming/kitex_gen/combine/a/client.go create mode 100644 thrift_streaming/kitex_gen/combine/a/invoker.go create mode 100644 thrift_streaming/kitex_gen/combine/a/server.go create mode 100644 thrift_streaming/kitex_gen/combine/b/b.go create mode 100644 thrift_streaming/kitex_gen/combine/b/client.go create mode 100644 thrift_streaming/kitex_gen/combine/b/invoker.go create mode 100644 thrift_streaming/kitex_gen/combine/b/server.go create mode 100644 thrift_streaming/kitex_gen/combine/combine.go create mode 100644 thrift_streaming/kitex_gen/combine/combineservice/client.go create mode 100644 thrift_streaming/kitex_gen/combine/combineservice/combineservice.go create mode 100644 thrift_streaming/kitex_gen/combine/combineservice/invoker.go create mode 100644 thrift_streaming/kitex_gen/combine/combineservice/server.go create mode 100644 thrift_streaming/kitex_gen/combine/k-combine.go create mode 100644 thrift_streaming/kitex_gen/combine/k-consts.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservice/client.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservice/invoker.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservice/pingpongonlyservice.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservice/server.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservice/client.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservice/invoker.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservice/server.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservice/streamonlyservice.go diff --git a/thrift_streaming/kitex_gen/combine/a/a.go b/thrift_streaming/kitex_gen/combine/a/a.go new file mode 100644 index 0000000..aac12d5 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/a/a.go @@ -0,0 +1,125 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package a + +import ( + "context" + "errors" + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "Foo": kitex.NewMethodInfo( + fooHandler, + newAFooArgs, + newAFooResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), +} + +var ( + aServiceInfo = NewServiceInfo() + aServiceInfoForClient = NewServiceInfoForClient() + aServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return aServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return aServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return aServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "A" + handlerType := (*combine.A)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "combine", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func fooHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*combine.AFooArgs) + realResult := result.(*combine.AFooResult) + success, err := handler.(combine.A).Foo(ctx, realArg.Req) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newAFooArgs() interface{} { + return combine.NewAFooArgs() +} + +func newAFooResult() interface{} { + return combine.NewAFooResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) Foo(ctx context.Context, req *combine.Req) (r *combine.Rsp, err error) { + var _args combine.AFooArgs + _args.Req = req + var _result combine.AFooResult + if err = p.c.Call(ctx, "Foo", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen/combine/a/client.go b/thrift_streaming/kitex_gen/combine/a/client.go new file mode 100644 index 0000000..dd7a1c2 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/a/client.go @@ -0,0 +1,49 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package a + +import ( + "context" + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + Foo(ctx context.Context, req *combine.Req, callOptions ...callopt.Option) (r *combine.Rsp, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kAClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kAClient struct { + *kClient +} + +func (p *kAClient) Foo(ctx context.Context, req *combine.Req, callOptions ...callopt.Option) (r *combine.Rsp, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.Foo(ctx, req) +} diff --git a/thrift_streaming/kitex_gen/combine/a/invoker.go b/thrift_streaming/kitex_gen/combine/a/invoker.go new file mode 100644 index 0000000..72c632c --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/a/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package a + +import ( + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler combine.A, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/combine/a/server.go b/thrift_streaming/kitex_gen/combine/a/server.go new file mode 100644 index 0000000..6b6a2d7 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/a/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package a + +import ( + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler combine.A, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/combine/b/b.go b/thrift_streaming/kitex_gen/combine/b/b.go new file mode 100644 index 0000000..75ea7e1 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/b/b.go @@ -0,0 +1,155 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package b + +import ( + "context" + "errors" + "fmt" + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "Bar": kitex.NewMethodInfo( + barHandler, + newBBarArgs, + newBBarResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + bServiceInfo = NewServiceInfo() + bServiceInfoForClient = NewServiceInfoForClient() + bServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return bServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return bServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return bServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "B" + handlerType := (*combine.B)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "combine", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func barHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("B.Bar is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &bBarServer{st.Stream} + return handler.(combine.B).Bar(stream) +} + +type bBarClient struct { + streaming.Stream +} + +func (x *bBarClient) Send(m *combine.Req) error { + return x.Stream.SendMsg(m) +} +func (x *bBarClient) Recv() (*combine.Rsp, error) { + m := new(combine.Rsp) + return m, x.Stream.RecvMsg(m) +} + +type bBarServer struct { + streaming.Stream +} + +func (x *bBarServer) Send(m *combine.Rsp) error { + return x.Stream.SendMsg(m) +} + +func (x *bBarServer) Recv() (*combine.Req, error) { + m := new(combine.Req) + return m, x.Stream.RecvMsg(m) +} + +func newBBarArgs() interface{} { + return combine.NewBBarArgs() +} + +func newBBarResult() interface{} { + return combine.NewBBarResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) Bar(ctx context.Context) (B_BarClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "Bar", nil, res) + if err != nil { + return nil, err + } + stream := &bBarClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen/combine/b/client.go b/thrift_streaming/kitex_gen/combine/b/client.go new file mode 100644 index 0000000..828cecf --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/b/client.go @@ -0,0 +1,92 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package b + +import ( + "context" + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + client "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + Bar(ctx context.Context, callOptions ...streamcall.Option) (stream B_BarClient, err error) +} + +type B_BarClient interface { + streaming.Stream + Send(*combine.Req) error + Recv() (*combine.Rsp, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kBClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kBClient struct { + *kClient +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kBStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kBStreamClient struct { + *kClient +} + +func (p *kBStreamClient) Bar(ctx context.Context, callOptions ...streamcall.Option) (stream B_BarClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.Bar(ctx) +} diff --git a/thrift_streaming/kitex_gen/combine/b/invoker.go b/thrift_streaming/kitex_gen/combine/b/invoker.go new file mode 100644 index 0000000..2a1760f --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/b/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package b + +import ( + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler combine.B, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/combine/b/server.go b/thrift_streaming/kitex_gen/combine/b/server.go new file mode 100644 index 0000000..0987a70 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/b/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package b + +import ( + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler combine.B, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/combine/combine.go b/thrift_streaming/kitex_gen/combine/combine.go new file mode 100644 index 0000000..5012c4f --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/combine.go @@ -0,0 +1,1251 @@ +// Code generated by thriftgo (0.3.5). DO NOT EDIT. + +package combine + +import ( + "context" + "fmt" + "github.com/apache/thrift/lib/go/thrift" + "github.com/cloudwego/kitex/pkg/streaming" + "strings" +) + +type Req struct { + Message string `thrift:"message,1,required" frugal:"1,required,string" json:"message"` +} + +func NewReq() *Req { + return &Req{} +} + +func (p *Req) InitDefault() { + *p = Req{} +} + +func (p *Req) GetMessage() (v string) { + return p.Message +} +func (p *Req) SetMessage(val string) { + p.Message = val +} + +var fieldIDToName_Req = map[int16]string{ + 1: "message", +} + +func (p *Req) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + var issetMessage bool = false + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + issetMessage = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + if !issetMessage { + fieldId = 1 + goto RequiredFieldNotSetError + } + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Req[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +RequiredFieldNotSetError: + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_Req[fieldId])) +} + +func (p *Req) ReadField1(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadString(); err != nil { + return err + } else { + p.Message = v + } + return nil +} + +func (p *Req) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Req"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *Req) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Message); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *Req) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Req(%+v)", *p) + +} + +func (p *Req) DeepEqual(ano *Req) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Message) { + return false + } + return true +} + +func (p *Req) Field1DeepEqual(src string) bool { + + if strings.Compare(p.Message, src) != 0 { + return false + } + return true +} + +type Rsp struct { + Message string `thrift:"message,1,required" frugal:"1,required,string" json:"message"` +} + +func NewRsp() *Rsp { + return &Rsp{} +} + +func (p *Rsp) InitDefault() { + *p = Rsp{} +} + +func (p *Rsp) GetMessage() (v string) { + return p.Message +} +func (p *Rsp) SetMessage(val string) { + p.Message = val +} + +var fieldIDToName_Rsp = map[int16]string{ + 1: "message", +} + +func (p *Rsp) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + var issetMessage bool = false + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + issetMessage = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + if !issetMessage { + fieldId = 1 + goto RequiredFieldNotSetError + } + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Rsp[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +RequiredFieldNotSetError: + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_Rsp[fieldId])) +} + +func (p *Rsp) ReadField1(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadString(); err != nil { + return err + } else { + p.Message = v + } + return nil +} + +func (p *Rsp) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Rsp"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *Rsp) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Message); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *Rsp) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Rsp(%+v)", *p) + +} + +func (p *Rsp) DeepEqual(ano *Rsp) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Message) { + return false + } + return true +} + +func (p *Rsp) Field1DeepEqual(src string) bool { + + if strings.Compare(p.Message, src) != 0 { + return false + } + return true +} + +type A interface { + Foo(ctx context.Context, req *Req) (r *Rsp, err error) +} + +type AClient struct { + c thrift.TClient +} + +func NewAClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *AClient { + return &AClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewAClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *AClient { + return &AClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewAClient(c thrift.TClient) *AClient { + return &AClient{ + c: c, + } +} + +func (p *AClient) Client_() thrift.TClient { + return p.c +} + +func (p *AClient) Foo(ctx context.Context, req *Req) (r *Rsp, err error) { + var _args AFooArgs + _args.Req = req + var _result AFooResult + if err = p.Client_().Call(ctx, "Foo", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +type B interface { + Bar(stream B_BarServer) (err error) +} + +type BClient struct { + c thrift.TClient +} + +func NewBClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *BClient { + return &BClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewBClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *BClient { + return &BClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewBClient(c thrift.TClient) *BClient { + return &BClient{ + c: c, + } +} + +func (p *BClient) Client_() thrift.TClient { + return p.c +} + +func (p *BClient) Bar(stream B_BarServer) (err error) { + panic("streaming method B.Bar(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") +} + +type B_BarServer interface { + streaming.Stream + + Recv() (*Req, error) + + Send(*Rsp) error +} + +type AProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler A +} + +func (p *AProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *AProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *AProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewAProcessor(handler A) *AProcessor { + self := &AProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self.AddToProcessorMap("Foo", &aProcessorFoo{handler: handler}) + return self +} +func (p *AProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} + +type aProcessorFoo struct { + handler A +} + +func (p *aProcessorFoo) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AFooArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("Foo", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := AFooResult{} + var retval *Rsp + if retval, err2 = p.handler.Foo(ctx, args.Req); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Foo: "+err2.Error()) + oprot.WriteMessageBegin("Foo", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("Foo", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type AFooArgs struct { + Req *Req `thrift:"req,1" frugal:"1,default,Req" json:"req"` +} + +func NewAFooArgs() *AFooArgs { + return &AFooArgs{} +} + +func (p *AFooArgs) InitDefault() { + *p = AFooArgs{} +} + +var AFooArgs_Req_DEFAULT *Req + +func (p *AFooArgs) GetReq() (v *Req) { + if !p.IsSetReq() { + return AFooArgs_Req_DEFAULT + } + return p.Req +} +func (p *AFooArgs) SetReq(val *Req) { + p.Req = val +} + +var fieldIDToName_AFooArgs = map[int16]string{ + 1: "req", +} + +func (p *AFooArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *AFooArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_AFooArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *AFooArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req = NewReq() + if err := p.Req.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *AFooArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Foo_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *AFooArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *AFooArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AFooArgs(%+v)", *p) + +} + +func (p *AFooArgs) DeepEqual(ano *AFooArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req) { + return false + } + return true +} + +func (p *AFooArgs) Field1DeepEqual(src *Req) bool { + + if !p.Req.DeepEqual(src) { + return false + } + return true +} + +type AFooResult struct { + Success *Rsp `thrift:"success,0,optional" frugal:"0,optional,Rsp" json:"success,omitempty"` +} + +func NewAFooResult() *AFooResult { + return &AFooResult{} +} + +func (p *AFooResult) InitDefault() { + *p = AFooResult{} +} + +var AFooResult_Success_DEFAULT *Rsp + +func (p *AFooResult) GetSuccess() (v *Rsp) { + if !p.IsSetSuccess() { + return AFooResult_Success_DEFAULT + } + return p.Success +} +func (p *AFooResult) SetSuccess(x interface{}) { + p.Success = x.(*Rsp) +} + +var fieldIDToName_AFooResult = map[int16]string{ + 0: "success", +} + +func (p *AFooResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AFooResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_AFooResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *AFooResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = NewRsp() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *AFooResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Foo_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *AFooResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *AFooResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AFooResult(%+v)", *p) + +} + +func (p *AFooResult) DeepEqual(ano *AFooResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *AFooResult) Field0DeepEqual(src *Rsp) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type BProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler B +} + +func (p *BProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *BProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *BProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewBProcessor(handler B) *BProcessor { + self := &BProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self.AddToProcessorMap("Bar", &bProcessorBar{handler: handler}) + return self +} +func (p *BProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} + +type bProcessorBar struct { + handler B +} + +func (p *bProcessorBar) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + panic("streaming method B.Bar(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") +} + +type BBarArgs struct { + Req *Req `thrift:"req,1" frugal:"1,default,Req" json:"req"` +} + +func NewBBarArgs() *BBarArgs { + return &BBarArgs{} +} + +func (p *BBarArgs) InitDefault() { + *p = BBarArgs{} +} + +var BBarArgs_Req_DEFAULT *Req + +func (p *BBarArgs) GetReq() (v *Req) { + if !p.IsSetReq() { + return BBarArgs_Req_DEFAULT + } + return p.Req +} +func (p *BBarArgs) SetReq(val *Req) { + p.Req = val +} + +var fieldIDToName_BBarArgs = map[int16]string{ + 1: "req", +} + +func (p *BBarArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *BBarArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BBarArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BBarArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req = NewReq() + if err := p.Req.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *BBarArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Bar_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *BBarArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *BBarArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("BBarArgs(%+v)", *p) + +} + +func (p *BBarArgs) DeepEqual(ano *BBarArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req) { + return false + } + return true +} + +func (p *BBarArgs) Field1DeepEqual(src *Req) bool { + + if !p.Req.DeepEqual(src) { + return false + } + return true +} + +type BBarResult struct { + Success *Rsp `thrift:"success,0,optional" frugal:"0,optional,Rsp" json:"success,omitempty"` +} + +func NewBBarResult() *BBarResult { + return &BBarResult{} +} + +func (p *BBarResult) InitDefault() { + *p = BBarResult{} +} + +var BBarResult_Success_DEFAULT *Rsp + +func (p *BBarResult) GetSuccess() (v *Rsp) { + if !p.IsSetSuccess() { + return BBarResult_Success_DEFAULT + } + return p.Success +} +func (p *BBarResult) SetSuccess(x interface{}) { + p.Success = x.(*Rsp) +} + +var fieldIDToName_BBarResult = map[int16]string{ + 0: "success", +} + +func (p *BBarResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *BBarResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BBarResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BBarResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = NewRsp() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *BBarResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Bar_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *BBarResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *BBarResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("BBarResult(%+v)", *p) + +} + +func (p *BBarResult) DeepEqual(ano *BBarResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *BBarResult) Field0DeepEqual(src *Rsp) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} diff --git a/thrift_streaming/kitex_gen/combine/combineservice/client.go b/thrift_streaming/kitex_gen/combine/combineservice/client.go new file mode 100644 index 0000000..701ff12 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/combineservice/client.go @@ -0,0 +1,99 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combineservice + +import ( + "context" + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + Foo(ctx context.Context, req *combine.Req, callOptions ...callopt.Option) (r *combine.Rsp, err error) +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + Bar(ctx context.Context, callOptions ...streamcall.Option) (stream B_BarClient, err error) +} + +type B_BarClient interface { + streaming.Stream + Send(*combine.Req) error + Recv() (*combine.Rsp, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kCombineServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kCombineServiceClient struct { + *kClient +} + +func (p *kCombineServiceClient) Foo(ctx context.Context, req *combine.Req, callOptions ...callopt.Option) (r *combine.Rsp, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.Foo(ctx, req) +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kCombineServiceStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kCombineServiceStreamClient struct { + *kClient +} + +func (p *kCombineServiceStreamClient) Bar(ctx context.Context, callOptions ...streamcall.Option) (stream B_BarClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.Bar(ctx) +} diff --git a/thrift_streaming/kitex_gen/combine/combineservice/combineservice.go b/thrift_streaming/kitex_gen/combine/combineservice/combineservice.go new file mode 100644 index 0000000..d6a31b5 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/combineservice/combineservice.go @@ -0,0 +1,197 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combineservice + +import ( + "context" + "errors" + "fmt" + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +type CombineService interface { + combine.A + combine.B +} + +var serviceMethods = map[string]kitex.MethodInfo{ + "Foo": kitex.NewMethodInfo( + fooHandler, + newAFooArgs, + newAFooResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "Bar": kitex.NewMethodInfo( + barHandler, + newBBarArgs, + newBBarResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + combineServiceServiceInfo = NewServiceInfo() + combineServiceServiceInfoForClient = NewServiceInfoForClient() + combineServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return combineServiceServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return combineServiceServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return combineServiceServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "CombineService" + handlerType := (*CombineService)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "combine", + } + extra["combine_service"] = true + extra["combined_service_list"] = []string{"A", "B"} + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func fooHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*combine.AFooArgs) + realResult := result.(*combine.AFooResult) + success, err := handler.(combine.A).Foo(ctx, realArg.Req) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newAFooArgs() interface{} { + return combine.NewAFooArgs() +} + +func newAFooResult() interface{} { + return combine.NewAFooResult() +} + +func barHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("B.Bar is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &bBarServer{st.Stream} + return handler.(combine.B).Bar(stream) +} + +type bBarClient struct { + streaming.Stream +} + +func (x *bBarClient) Send(m *combine.Req) error { + return x.Stream.SendMsg(m) +} +func (x *bBarClient) Recv() (*combine.Rsp, error) { + m := new(combine.Rsp) + return m, x.Stream.RecvMsg(m) +} + +type bBarServer struct { + streaming.Stream +} + +func (x *bBarServer) Send(m *combine.Rsp) error { + return x.Stream.SendMsg(m) +} + +func (x *bBarServer) Recv() (*combine.Req, error) { + m := new(combine.Req) + return m, x.Stream.RecvMsg(m) +} + +func newBBarArgs() interface{} { + return combine.NewBBarArgs() +} + +func newBBarResult() interface{} { + return combine.NewBBarResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) Foo(ctx context.Context, req *combine.Req) (r *combine.Rsp, err error) { + var _args combine.AFooArgs + _args.Req = req + var _result combine.AFooResult + if err = p.c.Call(ctx, "Foo", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) Bar(ctx context.Context) (B_BarClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "Bar", nil, res) + if err != nil { + return nil, err + } + stream := &bBarClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen/combine/combineservice/invoker.go b/thrift_streaming/kitex_gen/combine/combineservice/invoker.go new file mode 100644 index 0000000..5605702 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/combineservice/invoker.go @@ -0,0 +1,23 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combineservice + +import ( + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler CombineService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/combine/combineservice/server.go b/thrift_streaming/kitex_gen/combine/combineservice/server.go new file mode 100644 index 0000000..39f663b --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/combineservice/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package combineservice + +import ( + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler CombineService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/combine/k-combine.go b/thrift_streaming/kitex_gen/combine/k-combine.go new file mode 100644 index 0000000..eca2fed --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/k-combine.go @@ -0,0 +1,832 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combine + +import ( + "bytes" + "fmt" + "reflect" + "strings" + + "github.com/apache/thrift/lib/go/thrift" + + "github.com/cloudwego/kitex/pkg/protocol/bthrift" +) + +// unused protection +var ( + _ = fmt.Formatter(nil) + _ = (*bytes.Buffer)(nil) + _ = (*strings.Builder)(nil) + _ = reflect.Type(nil) + _ = thrift.TProtocol(nil) + _ = bthrift.BinaryWriter(nil) +) + +func (p *Req) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + var issetMessage bool = false + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + issetMessage = true + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + if !issetMessage { + fieldId = 1 + goto RequiredFieldNotSetError + } + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Req[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +RequiredFieldNotSetError: + return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_Req[fieldId])) +} + +func (p *Req) FastReadField1(buf []byte) (int, error) { + offset := 0 + + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.Message = v + + } + return offset, nil +} + +// for compatibility +func (p *Req) FastWrite(buf []byte) int { + return 0 +} + +func (p *Req) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Req") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *Req) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Req") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *Req) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) + + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Req) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) + l += bthrift.Binary.StringLengthNocopy(p.Message) + + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Rsp) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + var issetMessage bool = false + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + issetMessage = true + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + if !issetMessage { + fieldId = 1 + goto RequiredFieldNotSetError + } + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Rsp[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +RequiredFieldNotSetError: + return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_Rsp[fieldId])) +} + +func (p *Rsp) FastReadField1(buf []byte) (int, error) { + offset := 0 + + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.Message = v + + } + return offset, nil +} + +// for compatibility +func (p *Rsp) FastWrite(buf []byte) int { + return 0 +} + +func (p *Rsp) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Rsp") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *Rsp) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Rsp") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *Rsp) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) + + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Rsp) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) + l += bthrift.Binary.StringLengthNocopy(p.Message) + + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *AFooArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_AFooArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *AFooArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewReq() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req = tmp + return offset, nil +} + +// for compatibility +func (p *AFooArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *AFooArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Foo_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *AFooArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Foo_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *AFooArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *AFooArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += p.Req.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *AFooResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_AFooResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *AFooResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := NewRsp() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *AFooResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *AFooResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Foo_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *AFooResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Foo_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *AFooResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *AFooResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *BBarArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BBarArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BBarArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewReq() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req = tmp + return offset, nil +} + +// for compatibility +func (p *BBarArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *BBarArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Bar_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *BBarArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Bar_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *BBarArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *BBarArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += p.Req.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *BBarResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BBarResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BBarResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := NewRsp() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *BBarResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *BBarResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Bar_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *BBarResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Bar_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *BBarResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *BBarResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *AFooArgs) GetFirstArgument() interface{} { + return p.Req +} + +func (p *AFooResult) GetResult() interface{} { + return p.Success +} + +func (p *BBarArgs) GetFirstArgument() interface{} { + return p.Req +} + +func (p *BBarResult) GetResult() interface{} { + return p.Success +} diff --git a/thrift_streaming/kitex_gen/combine/k-consts.go b/thrift_streaming/kitex_gen/combine/k-consts.go new file mode 100644 index 0000000..653b83e --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/k-consts.go @@ -0,0 +1,4 @@ +package combine + +// KitexUnusedProtection is used to prevent 'imported and not used' error. +var KitexUnusedProtection = struct{}{} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservice/client.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/client.go new file mode 100644 index 0000000..8d34c24 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/client.go @@ -0,0 +1,49 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservice + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceClient) EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPong(ctx, req1) +} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservice/invoker.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/invoker.go new file mode 100644 index 0000000..da5064f --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.PingPongOnlyService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservice/pingpongonlyservice.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/pingpongonlyservice.go new file mode 100644 index 0000000..37bf1bd --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/pingpongonlyservice.go @@ -0,0 +1,125 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservice + +import ( + "context" + "errors" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoPingPong": kitex.NewMethodInfo( + echoPingPongHandler, + newPingPongOnlyServiceEchoPingPongArgs, + newPingPongOnlyServiceEchoPingPongResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), +} + +var ( + pingPongOnlyServiceServiceInfo = NewServiceInfo() + pingPongOnlyServiceServiceInfoForClient = NewServiceInfoForClient() + pingPongOnlyServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return pingPongOnlyServiceServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return pingPongOnlyServiceServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return pingPongOnlyServiceServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "PingPongOnlyService" + handlerType := (*echo.PingPongOnlyService)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "echo", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPong(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceEchoPingPongArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongArgs() +} + +func newPingPongOnlyServiceEchoPingPongResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPong(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceEchoPingPongResult + if err = p.c.Call(ctx, "EchoPingPong", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservice/server.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/server.go new file mode 100644 index 0000000..1c1f548 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package pingpongonlyservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.PingPongOnlyService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservice/client.go b/thrift_streaming/kitex_gen/echo/streamonlyservice/client.go new file mode 100644 index 0000000..a489e44 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservice/client.go @@ -0,0 +1,92 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservice + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectional(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalClient, err error) +} + +type StreamOnlyService_EchoBidirectionalClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceClient struct { + *kClient +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceStreamClient struct { + *kClient +} + +func (p *kStreamOnlyServiceStreamClient) EchoBidirectional(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectional(ctx) +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservice/invoker.go b/thrift_streaming/kitex_gen/echo/streamonlyservice/invoker.go new file mode 100644 index 0000000..3c8d70f --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservice/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.StreamOnlyService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservice/server.go b/thrift_streaming/kitex_gen/echo/streamonlyservice/server.go new file mode 100644 index 0000000..c5666b0 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservice/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package streamonlyservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.StreamOnlyService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservice/streamonlyservice.go b/thrift_streaming/kitex_gen/echo/streamonlyservice/streamonlyservice.go new file mode 100644 index 0000000..feb738c --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservice/streamonlyservice.go @@ -0,0 +1,155 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservice + +import ( + "context" + "errors" + "fmt" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoBidirectional": kitex.NewMethodInfo( + echoBidirectionalHandler, + newStreamOnlyServiceEchoBidirectionalArgs, + newStreamOnlyServiceEchoBidirectionalResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + streamOnlyServiceServiceInfo = NewServiceInfo() + streamOnlyServiceServiceInfoForClient = NewServiceInfoForClient() + streamOnlyServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return streamOnlyServiceServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return streamOnlyServiceServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return streamOnlyServiceServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "StreamOnlyService" + handlerType := (*echo.StreamOnlyService)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "echo", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoBidirectionalHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("StreamOnlyService.EchoBidirectional is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &streamOnlyServiceEchoBidirectionalServer{st.Stream} + return handler.(echo.StreamOnlyService).EchoBidirectional(stream) +} + +type streamOnlyServiceEchoBidirectionalClient struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *streamOnlyServiceEchoBidirectionalClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type streamOnlyServiceEchoBidirectionalServer struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *streamOnlyServiceEchoBidirectionalServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newStreamOnlyServiceEchoBidirectionalArgs() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalArgs() +} + +func newStreamOnlyServiceEchoBidirectionalResult() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoBidirectional(ctx context.Context) (StreamOnlyService_EchoBidirectionalClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectional", nil, res) + if err != nil { + return nil, err + } + stream := &streamOnlyServiceEchoBidirectionalClient{res.Stream} + return stream, nil +} From 41bc56645d87fbfee8f6aa430199330834124c1e Mon Sep 17 00:00:00 2001 From: Felix021 Date: Wed, 17 Jan 2024 21:41:45 +0800 Subject: [PATCH 4/7] test: streaming for extended services (#52) --- thrift_streaming/generate.sh | 18 +- thrift_streaming/idl/api.thrift | 18 +- thrift_streaming/idl/combine_extend.thrift | 22 + .../kitex_gen/combine_extend/a/a.go | 126 +++ .../kitex_gen/combine_extend/a/client.go | 49 ++ .../kitex_gen/combine_extend/a/invoker.go | 24 + .../kitex_gen/combine_extend/a/server.go | 21 + .../kitex_gen/combine_extend/b/b.go | 156 ++++ .../kitex_gen/combine_extend/b/client.go | 92 +++ .../kitex_gen/combine_extend/b/invoker.go | 24 + .../kitex_gen/combine_extend/b/server.go | 21 + .../combine_extend/combine_extend.go | 78 ++ .../combine_extend/combineservice/client.go | 99 +++ .../combineservice/combineservice.go | 198 +++++ .../combine_extend/combineservice/invoker.go | 23 + .../combine_extend/combineservice/server.go | 20 + .../combine_extend/k-combine_extend.go | 27 + .../kitex_gen/combine_extend/k-consts.go | 4 + thrift_streaming/kitex_gen/echo/api.go | 717 +++++++++++++--- thrift_streaming/kitex_gen/echo/k-api.go | 354 +++++++- .../echo/pingpongonlyservice/client.go | 6 +- .../pingpongonlyservice.go | 32 +- .../echo/pingpongonlyservicechild/client.go | 99 +++ .../echo/pingpongonlyservicechild/invoker.go | 24 + .../pingpongonlyservicechild.go | 190 +++++ .../echo/pingpongonlyservicechild/server.go | 21 + .../pingpongonlyservicechildchild/client.go | 99 +++ .../pingpongonlyservicechildchild/invoker.go | 24 + .../pingpongonlyservicechildchild.go | 190 +++++ .../pingpongonlyservicechildchild/server.go | 21 + .../echo/streamonlyservice/client.go | 8 +- .../streamonlyservice/streamonlyservice.go | 42 +- .../echo/streamonlyservicechild/client.go | 92 +++ .../echo/streamonlyservicechild/invoker.go | 24 + .../echo/streamonlyservicechild/server.go | 21 + .../streamonlyservicechild.go | 155 ++++ .../streamonlyservicechildchild/client.go | 92 +++ .../streamonlyservicechildchild/invoker.go | 24 + .../streamonlyservicechildchild/server.go | 21 + .../streamonlyservicechildchild.go | 155 ++++ thrift_streaming/kitex_gen/grpc_pb/api.pb.go | 2 +- .../kitex_gen/kitex_pb/api_no_stream.pb.go | 2 +- thrift_streaming/kitex_gen_cross/echo/api.go | 254 ++++-- .../kitex_gen_cross/echo/k-api.go | 44 +- .../echo/pingpongonlyservice/client.go | 6 +- .../pingpongonlyservice.go | 26 +- .../echo/pingpongonlyservicechild/client.go | 49 ++ .../echo/pingpongonlyservicechild/invoker.go | 24 + .../pingpongonlyservicechild.go | 75 ++ .../echo/pingpongonlyservicechild/server.go | 20 + .../pingpongonlyservicechildchild/client.go | 49 ++ .../pingpongonlyservicechildchild/invoker.go | 24 + .../pingpongonlyservicechildchild.go | 75 ++ .../pingpongonlyservicechildchild/server.go | 20 + .../echo/streamonlyservicechild/client.go | 40 + .../echo/streamonlyservicechild/invoker.go | 24 + .../echo/streamonlyservicechild/server.go | 20 + .../streamonlyservicechild.go | 44 + .../streamonlyservicechildchild/client.go | 40 + .../streamonlyservicechildchild/invoker.go | 24 + .../streamonlyservicechildchild/server.go | 20 + .../streamonlyservicechildchild.go | 44 + thrift_streaming/kitex_gen_old/echo/api.go | 769 +++++++++++++++--- thrift_streaming/kitex_gen_old/echo/k-api.go | 354 +++++++- .../echo/pingpongonlyservice/client.go | 6 +- .../pingpongonlyservice.go | 26 +- .../echo/pingpongonlyservicechild/client.go | 55 ++ .../echo/pingpongonlyservicechild/invoker.go | 24 + .../pingpongonlyservicechild.go | 104 +++ .../echo/pingpongonlyservicechild/server.go | 20 + .../pingpongonlyservicechildchild/client.go | 55 ++ .../pingpongonlyservicechildchild/invoker.go | 24 + .../pingpongonlyservicechildchild.go | 104 +++ .../pingpongonlyservicechildchild/server.go | 20 + .../echo/streamonlyservice/client.go | 6 +- .../streamonlyservice/streamonlyservice.go | 26 +- .../echo/streamonlyservicechild/client.go | 49 ++ .../echo/streamonlyservicechild/invoker.go | 24 + .../echo/streamonlyservicechild/server.go | 20 + .../streamonlyservicechild.go | 75 ++ .../streamonlyservicechildchild/client.go | 49 ++ .../streamonlyservicechildchild/invoker.go | 24 + .../streamonlyservicechildchild/server.go | 20 + .../streamonlyservicechildchild.go | 75 ++ .../kitex_gen_slim/combine_extend/a/a.go | 126 +++ .../kitex_gen_slim/combine_extend/a/client.go | 49 ++ .../combine_extend/a/invoker.go | 24 + .../kitex_gen_slim/combine_extend/a/server.go | 21 + .../kitex_gen_slim/combine_extend/b/b.go | 156 ++++ .../kitex_gen_slim/combine_extend/b/client.go | 92 +++ .../combine_extend/b/invoker.go | 24 + .../kitex_gen_slim/combine_extend/b/server.go | 21 + .../combine_extend/combine_extend.go | 15 + .../combine_extend/combineservice/client.go | 99 +++ .../combineservice/combineservice.go | 198 +++++ .../combine_extend/combineservice/invoker.go | 23 + .../combine_extend/combineservice/server.go | 20 + .../combine_extend/k-combine_extend.go | 24 + .../kitex_gen_slim/combine_extend/k-consts.go | 4 + thrift_streaming/kitex_gen_slim/echo/api.go | 32 +- thrift_streaming/kitex_gen_slim/echo/k-api.go | 180 ++-- .../echo/pingpongonlyservice/client.go | 6 +- .../pingpongonlyservice.go | 32 +- .../echo/pingpongonlyservicechild/client.go | 99 +++ .../echo/pingpongonlyservicechild/invoker.go | 24 + .../pingpongonlyservicechild.go | 190 +++++ .../echo/pingpongonlyservicechild/server.go | 21 + .../pingpongonlyservicechildchild/client.go | 99 +++ .../pingpongonlyservicechildchild/invoker.go | 24 + .../pingpongonlyservicechildchild.go | 190 +++++ .../pingpongonlyservicechildchild/server.go | 21 + .../echo/streamonlyservice/client.go | 8 +- .../streamonlyservice/streamonlyservice.go | 42 +- .../echo/streamonlyservicechild/client.go | 92 +++ .../echo/streamonlyservicechild/invoker.go | 24 + .../echo/streamonlyservicechild/server.go | 21 + .../streamonlyservicechild.go | 155 ++++ .../streamonlyservicechildchild/client.go | 92 +++ .../streamonlyservicechildchild/invoker.go | 24 + .../streamonlyservicechildchild/server.go | 21 + .../streamonlyservicechildchild.go | 155 ++++ 121 files changed, 8147 insertions(+), 587 deletions(-) create mode 100644 thrift_streaming/idl/combine_extend.thrift create mode 100644 thrift_streaming/kitex_gen/combine_extend/a/a.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/a/client.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/a/invoker.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/a/server.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/b/b.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/b/client.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/b/invoker.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/b/server.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/combine_extend.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/combineservice/client.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/combineservice/combineservice.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/combineservice/invoker.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/combineservice/server.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/k-combine_extend.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/k-consts.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/client.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/invoker.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/pingpongonlyservicechild.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/server.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/client.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/invoker.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/server.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechild/client.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechild/invoker.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechild/server.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechild/streamonlyservicechild.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/client.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/invoker.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/server.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/streamonlyservicechildchild.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechild/client.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechild/invoker.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechild/pingpongonlyservicechild.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechild/server.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechildchild/client.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechildchild/invoker.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechildchild/server.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/streamonlyservicechild/client.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/streamonlyservicechild/invoker.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/streamonlyservicechild/server.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/streamonlyservicechild/streamonlyservicechild.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/streamonlyservicechildchild/client.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/streamonlyservicechildchild/invoker.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/streamonlyservicechildchild/server.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/streamonlyservicechildchild/streamonlyservicechildchild.go create mode 100644 thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechild/client.go create mode 100644 thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechild/invoker.go create mode 100644 thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechild/pingpongonlyservicechild.go create mode 100644 thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechild/server.go create mode 100644 thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechildchild/client.go create mode 100644 thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechildchild/invoker.go create mode 100644 thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go create mode 100644 thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechildchild/server.go create mode 100644 thrift_streaming/kitex_gen_old/echo/streamonlyservicechild/client.go create mode 100644 thrift_streaming/kitex_gen_old/echo/streamonlyservicechild/invoker.go create mode 100644 thrift_streaming/kitex_gen_old/echo/streamonlyservicechild/server.go create mode 100644 thrift_streaming/kitex_gen_old/echo/streamonlyservicechild/streamonlyservicechild.go create mode 100644 thrift_streaming/kitex_gen_old/echo/streamonlyservicechildchild/client.go create mode 100644 thrift_streaming/kitex_gen_old/echo/streamonlyservicechildchild/invoker.go create mode 100644 thrift_streaming/kitex_gen_old/echo/streamonlyservicechildchild/server.go create mode 100644 thrift_streaming/kitex_gen_old/echo/streamonlyservicechildchild/streamonlyservicechildchild.go create mode 100644 thrift_streaming/kitex_gen_slim/combine_extend/a/a.go create mode 100644 thrift_streaming/kitex_gen_slim/combine_extend/a/client.go create mode 100644 thrift_streaming/kitex_gen_slim/combine_extend/a/invoker.go create mode 100644 thrift_streaming/kitex_gen_slim/combine_extend/a/server.go create mode 100644 thrift_streaming/kitex_gen_slim/combine_extend/b/b.go create mode 100644 thrift_streaming/kitex_gen_slim/combine_extend/b/client.go create mode 100644 thrift_streaming/kitex_gen_slim/combine_extend/b/invoker.go create mode 100644 thrift_streaming/kitex_gen_slim/combine_extend/b/server.go create mode 100644 thrift_streaming/kitex_gen_slim/combine_extend/combine_extend.go create mode 100644 thrift_streaming/kitex_gen_slim/combine_extend/combineservice/client.go create mode 100644 thrift_streaming/kitex_gen_slim/combine_extend/combineservice/combineservice.go create mode 100644 thrift_streaming/kitex_gen_slim/combine_extend/combineservice/invoker.go create mode 100644 thrift_streaming/kitex_gen_slim/combine_extend/combineservice/server.go create mode 100644 thrift_streaming/kitex_gen_slim/combine_extend/k-combine_extend.go create mode 100644 thrift_streaming/kitex_gen_slim/combine_extend/k-consts.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechild/client.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechild/invoker.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechild/pingpongonlyservicechild.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechild/server.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/client.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/invoker.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/server.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/client.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/invoker.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/server.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/streamonlyservicechild.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/client.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/invoker.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/server.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/streamonlyservicechildchild.go diff --git a/thrift_streaming/generate.sh b/thrift_streaming/generate.sh index ce63f42..427bcdc 100755 --- a/thrift_streaming/generate.sh +++ b/thrift_streaming/generate.sh @@ -44,8 +44,12 @@ function generate_old() { export PATH=$OLD:$SAVE_PATH mkdir -p $dir - GOBIN=$dir go install github.com/cloudwego/kitex/tool/cmd/kitex@v0.8.0 - GOBIN=$dir go install github.com/cloudwego/thriftgo@v0.3.4 + if [ ! -f "$dir/kitex" ]; then + GOBIN=$dir go install github.com/cloudwego/kitex/tool/cmd/kitex@v0.8.0 + fi + if [ ! -f "$dir/thriftgo" ]; then + GOBIN=$dir go install github.com/cloudwego/thriftgo@v0.3.4 + fi if [ ! -f "$dir/kitex" -o ! -f "$dir/thriftgo" ]; then echo "[old] Unable to install kitex or thriftgo to $dir, please check before continue." exit 1 @@ -81,10 +85,12 @@ function generate_new() { # Thrift kitex $module $idl kitex $module --combine-service idl/combine.thrift + kitex $module --combine-service idl/combine_extend.thrift # Thrift Slim kitex -thrift template=slim -gen-path kitex_gen_slim $module $idl kitex -thrift template=slim -gen-path kitex_gen_slim $module --combine-service idl/combine.thrift + kitex -thrift template=slim -gen-path kitex_gen_slim $module --combine-service idl/combine_extend.thrift # KitexPB kitex $module idl/api.proto @@ -99,8 +105,12 @@ function generate_new_thriftgo_old_kitex() { export PATH=$dir:$SAVE_PATH mkdir -p $dir - GOBIN=$dir go install github.com/cloudwego/kitex/tool/cmd/kitex@v0.8.0 - GOBIN=$dir go install github.com/cloudwego/thriftgo@latest + if [ ! -f "$dir/kitex" ]; then + GOBIN=$dir go install github.com/cloudwego/kitex/tool/cmd/kitex@v0.8.0 + fi + if [ ! -f "$dir/thriftgo" ]; then + GOBIN=$dir go install github.com/cloudwego/thriftgo@latest + fi if [ ! -f "$dir/kitex" -o ! -f "$dir/thriftgo" ]; then echo "[cross] Unable to install kitex or thriftgo to $dir, please check before continue." exit 1 diff --git a/thrift_streaming/idl/api.thrift b/thrift_streaming/idl/api.thrift index 9c91870..47959d7 100644 --- a/thrift_streaming/idl/api.thrift +++ b/thrift_streaming/idl/api.thrift @@ -42,10 +42,24 @@ service EchoService { // for checking whether the generated code is ok service PingPongOnlyService { - EchoResponse EchoPingPong (1: EchoRequest req1), + EchoResponse EchoPingPongNew (1: EchoRequest req1), } +// Also streaming +service PingPongOnlyServiceChild extends PingPongOnlyService { + EchoResponse EchoBidirectionalExtended (1: EchoRequest req1) (streaming.mode="bidirectional"), +} + +// Also streaming +service PingPongOnlyServiceChildChild extends PingPongOnlyServiceChild {} + // for checking whether the generated code is ok service StreamOnlyService { - EchoResponse EchoBidirectional (1: EchoRequest req1) (streaming.mode="bidirectional"), + EchoResponse EchoBidirectionalNew (1: EchoRequest req1) (streaming.mode="bidirectional"), } + +// for checking services extending a service extending a service +service StreamOnlyServiceChild extends StreamOnlyService {} + +// should also be a streaming service +service StreamOnlyServiceChildChild extends StreamOnlyServiceChild {} diff --git a/thrift_streaming/idl/combine_extend.thrift b/thrift_streaming/idl/combine_extend.thrift new file mode 100644 index 0000000..7efd68b --- /dev/null +++ b/thrift_streaming/idl/combine_extend.thrift @@ -0,0 +1,22 @@ +// Copyright 2023 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace go combine_extend + +include "api.thrift" + + +service A extends api.PingPongOnlyService {} + +service B extends api.StreamOnlyServiceChildChild {} \ No newline at end of file diff --git a/thrift_streaming/kitex_gen/combine_extend/a/a.go b/thrift_streaming/kitex_gen/combine_extend/a/a.go new file mode 100644 index 0000000..fc84980 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/a/a.go @@ -0,0 +1,126 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package a + +import ( + "context" + "errors" + combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine_extend" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoPingPongNew": kitex.NewMethodInfo( + echoPingPongNewHandler, + newPingPongOnlyServiceEchoPingPongNewArgs, + newPingPongOnlyServiceEchoPingPongNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), +} + +var ( + aServiceInfo = NewServiceInfo() + aServiceInfoForClient = NewServiceInfoForClient() + aServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return aServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return aServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return aServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "A" + handlerType := (*combine_extend.A)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "combine_extend", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() +} + +func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongNewArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceEchoPingPongNewResult + if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen/combine_extend/a/client.go b/thrift_streaming/kitex_gen/combine_extend/a/client.go new file mode 100644 index 0000000..5b397f3 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/a/client.go @@ -0,0 +1,49 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package a + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kAClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kAClient struct { + *kClient +} + +func (p *kAClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPongNew(ctx, req1) +} diff --git a/thrift_streaming/kitex_gen/combine_extend/a/invoker.go b/thrift_streaming/kitex_gen/combine_extend/a/invoker.go new file mode 100644 index 0000000..18adccc --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/a/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package a + +import ( + combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine_extend" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler combine_extend.A, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/combine_extend/a/server.go b/thrift_streaming/kitex_gen/combine_extend/a/server.go new file mode 100644 index 0000000..fcfeef1 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/a/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package a + +import ( + combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine_extend" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler combine_extend.A, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/combine_extend/b/b.go b/thrift_streaming/kitex_gen/combine_extend/b/b.go new file mode 100644 index 0000000..3d7980f --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/b/b.go @@ -0,0 +1,156 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package b + +import ( + "context" + "errors" + "fmt" + combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine_extend" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoBidirectionalNew": kitex.NewMethodInfo( + echoBidirectionalNewHandler, + newStreamOnlyServiceEchoBidirectionalNewArgs, + newStreamOnlyServiceEchoBidirectionalNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + bServiceInfo = NewServiceInfo() + bServiceInfoForClient = NewServiceInfoForClient() + bServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return bServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return bServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return bServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "B" + handlerType := (*combine_extend.B)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "combine_extend", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("StreamOnlyService.EchoBidirectionalNew is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &streamOnlyServiceEchoBidirectionalNewServer{st.Stream} + return handler.(echo.StreamOnlyService).EchoBidirectionalNew(stream) +} + +type streamOnlyServiceEchoBidirectionalNewClient struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *streamOnlyServiceEchoBidirectionalNewClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type streamOnlyServiceEchoBidirectionalNewServer struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() +} + +func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoBidirectionalNew(ctx context.Context) (StreamOnlyService_EchoBidirectionalNewClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectionalNew", nil, res) + if err != nil { + return nil, err + } + stream := &streamOnlyServiceEchoBidirectionalNewClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen/combine_extend/b/client.go b/thrift_streaming/kitex_gen/combine_extend/b/client.go new file mode 100644 index 0000000..645ae56 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/b/client.go @@ -0,0 +1,92 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package b + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) +} + +type StreamOnlyService_EchoBidirectionalNewClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kBClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kBClient struct { + *kClient +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kBStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kBStreamClient struct { + *kClient +} + +func (p *kBStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalNew(ctx) +} diff --git a/thrift_streaming/kitex_gen/combine_extend/b/invoker.go b/thrift_streaming/kitex_gen/combine_extend/b/invoker.go new file mode 100644 index 0000000..3fbd965 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/b/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package b + +import ( + combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine_extend" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler combine_extend.B, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/combine_extend/b/server.go b/thrift_streaming/kitex_gen/combine_extend/b/server.go new file mode 100644 index 0000000..54ea26b --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/b/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package b + +import ( + combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine_extend" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler combine_extend.B, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/combine_extend/combine_extend.go b/thrift_streaming/kitex_gen/combine_extend/combine_extend.go new file mode 100644 index 0000000..5b86a84 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/combine_extend.go @@ -0,0 +1,78 @@ +// Code generated by thriftgo (0.3.5). DO NOT EDIT. + +package combine_extend + +import ( + "github.com/apache/thrift/lib/go/thrift" + "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" +) + +type A interface { + echo.PingPongOnlyService +} + +type AClient struct { + *echo.PingPongOnlyServiceClient +} + +func NewAClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *AClient { + return &AClient{ + PingPongOnlyServiceClient: echo.NewPingPongOnlyServiceClientFactory(t, f), + } +} + +func NewAClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *AClient { + return &AClient{ + PingPongOnlyServiceClient: echo.NewPingPongOnlyServiceClientProtocol(t, iprot, oprot), + } +} + +func NewAClient(c thrift.TClient) *AClient { + return &AClient{ + PingPongOnlyServiceClient: echo.NewPingPongOnlyServiceClient(c), + } +} + +type B interface { + echo.StreamOnlyServiceChildChild +} + +type BClient struct { + *echo.StreamOnlyServiceChildChildClient +} + +func NewBClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *BClient { + return &BClient{ + StreamOnlyServiceChildChildClient: echo.NewStreamOnlyServiceChildChildClientFactory(t, f), + } +} + +func NewBClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *BClient { + return &BClient{ + StreamOnlyServiceChildChildClient: echo.NewStreamOnlyServiceChildChildClientProtocol(t, iprot, oprot), + } +} + +func NewBClient(c thrift.TClient) *BClient { + return &BClient{ + StreamOnlyServiceChildChildClient: echo.NewStreamOnlyServiceChildChildClient(c), + } +} + +type AProcessor struct { + *echo.PingPongOnlyServiceProcessor +} + +func NewAProcessor(handler A) *AProcessor { + self := &AProcessor{echo.NewPingPongOnlyServiceProcessor(handler)} + return self +} + +type BProcessor struct { + *echo.StreamOnlyServiceChildChildProcessor +} + +func NewBProcessor(handler B) *BProcessor { + self := &BProcessor{echo.NewStreamOnlyServiceChildChildProcessor(handler)} + return self +} diff --git a/thrift_streaming/kitex_gen/combine_extend/combineservice/client.go b/thrift_streaming/kitex_gen/combine_extend/combineservice/client.go new file mode 100644 index 0000000..6d71e8d --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/combineservice/client.go @@ -0,0 +1,99 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combineservice + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) +} + +type StreamOnlyService_EchoBidirectionalNewClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kCombineServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kCombineServiceClient struct { + *kClient +} + +func (p *kCombineServiceClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPongNew(ctx, req1) +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kCombineServiceStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kCombineServiceStreamClient struct { + *kClient +} + +func (p *kCombineServiceStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalNew(ctx) +} diff --git a/thrift_streaming/kitex_gen/combine_extend/combineservice/combineservice.go b/thrift_streaming/kitex_gen/combine_extend/combineservice/combineservice.go new file mode 100644 index 0000000..12b5f62 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/combineservice/combineservice.go @@ -0,0 +1,198 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combineservice + +import ( + "context" + "errors" + "fmt" + combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine_extend" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +type CombineService interface { + combine_extend.A + combine_extend.B +} + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoPingPongNew": kitex.NewMethodInfo( + echoPingPongNewHandler, + newPingPongOnlyServiceEchoPingPongNewArgs, + newPingPongOnlyServiceEchoPingPongNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "EchoBidirectionalNew": kitex.NewMethodInfo( + echoBidirectionalNewHandler, + newStreamOnlyServiceEchoBidirectionalNewArgs, + newStreamOnlyServiceEchoBidirectionalNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + combineServiceServiceInfo = NewServiceInfo() + combineServiceServiceInfoForClient = NewServiceInfoForClient() + combineServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return combineServiceServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return combineServiceServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return combineServiceServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "CombineService" + handlerType := (*CombineService)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "combine_extend", + } + extra["combine_service"] = true + extra["combined_service_list"] = []string{"A", "B"} + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() +} + +func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewResult() +} + +func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("StreamOnlyService.EchoBidirectionalNew is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &streamOnlyServiceEchoBidirectionalNewServer{st.Stream} + return handler.(echo.StreamOnlyService).EchoBidirectionalNew(stream) +} + +type streamOnlyServiceEchoBidirectionalNewClient struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *streamOnlyServiceEchoBidirectionalNewClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type streamOnlyServiceEchoBidirectionalNewServer struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() +} + +func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongNewArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceEchoPingPongNewResult + if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) EchoBidirectionalNew(ctx context.Context) (StreamOnlyService_EchoBidirectionalNewClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectionalNew", nil, res) + if err != nil { + return nil, err + } + stream := &streamOnlyServiceEchoBidirectionalNewClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen/combine_extend/combineservice/invoker.go b/thrift_streaming/kitex_gen/combine_extend/combineservice/invoker.go new file mode 100644 index 0000000..5605702 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/combineservice/invoker.go @@ -0,0 +1,23 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combineservice + +import ( + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler CombineService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/combine_extend/combineservice/server.go b/thrift_streaming/kitex_gen/combine_extend/combineservice/server.go new file mode 100644 index 0000000..39f663b --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/combineservice/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package combineservice + +import ( + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler CombineService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/combine_extend/k-combine_extend.go b/thrift_streaming/kitex_gen/combine_extend/k-combine_extend.go new file mode 100644 index 0000000..0eabf31 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/k-combine_extend.go @@ -0,0 +1,27 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combine_extend + +import ( + "bytes" + "fmt" + "reflect" + "strings" + + "github.com/apache/thrift/lib/go/thrift" + + "github.com/cloudwego/kitex/pkg/protocol/bthrift" + + "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" +) + +// unused protection +var ( + _ = fmt.Formatter(nil) + _ = (*bytes.Buffer)(nil) + _ = (*strings.Builder)(nil) + _ = reflect.Type(nil) + _ = thrift.TProtocol(nil) + _ = bthrift.BinaryWriter(nil) + _ = echo.KitexUnusedProtection +) diff --git a/thrift_streaming/kitex_gen/combine_extend/k-consts.go b/thrift_streaming/kitex_gen/combine_extend/k-consts.go new file mode 100644 index 0000000..8e5ff02 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/k-consts.go @@ -0,0 +1,4 @@ +package combine_extend + +// KitexUnusedProtection is used to prevent 'imported and not used' error. +var KitexUnusedProtection = struct{}{} diff --git a/thrift_streaming/kitex_gen/echo/api.go b/thrift_streaming/kitex_gen/echo/api.go index 804e889..7923db3 100644 --- a/thrift_streaming/kitex_gen/echo/api.go +++ b/thrift_streaming/kitex_gen/echo/api.go @@ -627,7 +627,7 @@ func (p *EchoServiceClient) Ping(ctx context.Context) (err error) { } type PingPongOnlyService interface { - EchoPingPong(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) + EchoPingPongNew(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) } type PingPongOnlyServiceClient struct { @@ -656,18 +656,84 @@ func (p *PingPongOnlyServiceClient) Client_() thrift.TClient { return p.c } -func (p *PingPongOnlyServiceClient) EchoPingPong(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) { - var _args PingPongOnlyServiceEchoPingPongArgs +func (p *PingPongOnlyServiceClient) EchoPingPongNew(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) { + var _args PingPongOnlyServiceEchoPingPongNewArgs _args.Req1 = req1 - var _result PingPongOnlyServiceEchoPingPongResult - if err = p.Client_().Call(ctx, "EchoPingPong", &_args, &_result); err != nil { + var _result PingPongOnlyServiceEchoPingPongNewResult + if err = p.Client_().Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { return } return _result.GetSuccess(), nil } +type PingPongOnlyServiceChild interface { + PingPongOnlyService + + EchoBidirectionalExtended(stream PingPongOnlyServiceChild_EchoBidirectionalExtendedServer) (err error) +} + +type PingPongOnlyServiceChildClient struct { + *PingPongOnlyServiceClient +} + +func NewPingPongOnlyServiceChildClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *PingPongOnlyServiceChildClient { + return &PingPongOnlyServiceChildClient{ + PingPongOnlyServiceClient: NewPingPongOnlyServiceClientFactory(t, f), + } +} + +func NewPingPongOnlyServiceChildClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *PingPongOnlyServiceChildClient { + return &PingPongOnlyServiceChildClient{ + PingPongOnlyServiceClient: NewPingPongOnlyServiceClientProtocol(t, iprot, oprot), + } +} + +func NewPingPongOnlyServiceChildClient(c thrift.TClient) *PingPongOnlyServiceChildClient { + return &PingPongOnlyServiceChildClient{ + PingPongOnlyServiceClient: NewPingPongOnlyServiceClient(c), + } +} + +func (p *PingPongOnlyServiceChildClient) EchoBidirectionalExtended(stream PingPongOnlyServiceChild_EchoBidirectionalExtendedServer) (err error) { + panic("streaming method PingPongOnlyServiceChild.EchoBidirectionalExtended(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") +} + +type PingPongOnlyServiceChild_EchoBidirectionalExtendedServer interface { + streaming.Stream + + Recv() (*EchoRequest, error) + + Send(*EchoResponse) error +} + +type PingPongOnlyServiceChildChild interface { + PingPongOnlyServiceChild +} + +type PingPongOnlyServiceChildChildClient struct { + *PingPongOnlyServiceChildClient +} + +func NewPingPongOnlyServiceChildChildClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *PingPongOnlyServiceChildChildClient { + return &PingPongOnlyServiceChildChildClient{ + PingPongOnlyServiceChildClient: NewPingPongOnlyServiceChildClientFactory(t, f), + } +} + +func NewPingPongOnlyServiceChildChildClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *PingPongOnlyServiceChildChildClient { + return &PingPongOnlyServiceChildChildClient{ + PingPongOnlyServiceChildClient: NewPingPongOnlyServiceChildClientProtocol(t, iprot, oprot), + } +} + +func NewPingPongOnlyServiceChildChildClient(c thrift.TClient) *PingPongOnlyServiceChildChildClient { + return &PingPongOnlyServiceChildChildClient{ + PingPongOnlyServiceChildClient: NewPingPongOnlyServiceChildClient(c), + } +} + type StreamOnlyService interface { - EchoBidirectional(stream StreamOnlyService_EchoBidirectionalServer) (err error) + EchoBidirectionalNew(stream StreamOnlyService_EchoBidirectionalNewServer) (err error) } type StreamOnlyServiceClient struct { @@ -696,11 +762,11 @@ func (p *StreamOnlyServiceClient) Client_() thrift.TClient { return p.c } -func (p *StreamOnlyServiceClient) EchoBidirectional(stream StreamOnlyService_EchoBidirectionalServer) (err error) { - panic("streaming method StreamOnlyService.EchoBidirectional(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") +func (p *StreamOnlyServiceClient) EchoBidirectionalNew(stream StreamOnlyService_EchoBidirectionalNewServer) (err error) { + panic("streaming method StreamOnlyService.EchoBidirectionalNew(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") } -type StreamOnlyService_EchoBidirectionalServer interface { +type StreamOnlyService_EchoBidirectionalNewServer interface { streaming.Stream Recv() (*EchoRequest, error) @@ -708,6 +774,58 @@ type StreamOnlyService_EchoBidirectionalServer interface { Send(*EchoResponse) error } +type StreamOnlyServiceChild interface { + StreamOnlyService +} + +type StreamOnlyServiceChildClient struct { + *StreamOnlyServiceClient +} + +func NewStreamOnlyServiceChildClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *StreamOnlyServiceChildClient { + return &StreamOnlyServiceChildClient{ + StreamOnlyServiceClient: NewStreamOnlyServiceClientFactory(t, f), + } +} + +func NewStreamOnlyServiceChildClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *StreamOnlyServiceChildClient { + return &StreamOnlyServiceChildClient{ + StreamOnlyServiceClient: NewStreamOnlyServiceClientProtocol(t, iprot, oprot), + } +} + +func NewStreamOnlyServiceChildClient(c thrift.TClient) *StreamOnlyServiceChildClient { + return &StreamOnlyServiceChildClient{ + StreamOnlyServiceClient: NewStreamOnlyServiceClient(c), + } +} + +type StreamOnlyServiceChildChild interface { + StreamOnlyServiceChild +} + +type StreamOnlyServiceChildChildClient struct { + *StreamOnlyServiceChildClient +} + +func NewStreamOnlyServiceChildChildClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *StreamOnlyServiceChildChildClient { + return &StreamOnlyServiceChildChildClient{ + StreamOnlyServiceChildClient: NewStreamOnlyServiceChildClientFactory(t, f), + } +} + +func NewStreamOnlyServiceChildChildClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *StreamOnlyServiceChildChildClient { + return &StreamOnlyServiceChildChildClient{ + StreamOnlyServiceChildClient: NewStreamOnlyServiceChildClientProtocol(t, iprot, oprot), + } +} + +func NewStreamOnlyServiceChildChildClient(c thrift.TClient) *StreamOnlyServiceChildChildClient { + return &StreamOnlyServiceChildChildClient{ + StreamOnlyServiceChildClient: NewStreamOnlyServiceChildClient(c), + } +} + type EchoServiceProcessor struct { processorMap map[string]thrift.TProcessorFunction handler EchoService @@ -3228,7 +3346,7 @@ func (p *PingPongOnlyServiceProcessor) ProcessorMap() map[string]thrift.TProcess func NewPingPongOnlyServiceProcessor(handler PingPongOnlyService) *PingPongOnlyServiceProcessor { self := &PingPongOnlyServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("EchoPingPong", &pingPongOnlyServiceProcessorEchoPingPong{handler: handler}) + self.AddToProcessorMap("EchoPingPongNew", &pingPongOnlyServiceProcessorEchoPingPongNew{handler: handler}) return self } func (p *PingPongOnlyServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { @@ -3249,16 +3367,16 @@ func (p *PingPongOnlyServiceProcessor) Process(ctx context.Context, iprot, oprot return false, x } -type pingPongOnlyServiceProcessorEchoPingPong struct { +type pingPongOnlyServiceProcessorEchoPingPongNew struct { handler PingPongOnlyService } -func (p *pingPongOnlyServiceProcessorEchoPingPong) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := PingPongOnlyServiceEchoPingPongArgs{} +func (p *pingPongOnlyServiceProcessorEchoPingPongNew) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := PingPongOnlyServiceEchoPingPongNewArgs{} if err = args.Read(iprot); err != nil { iprot.ReadMessageEnd() x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("EchoPingPong", thrift.EXCEPTION, seqId) + oprot.WriteMessageBegin("EchoPingPongNew", thrift.EXCEPTION, seqId) x.Write(oprot) oprot.WriteMessageEnd() oprot.Flush(ctx) @@ -3267,11 +3385,11 @@ func (p *pingPongOnlyServiceProcessorEchoPingPong) Process(ctx context.Context, iprot.ReadMessageEnd() var err2 error - result := PingPongOnlyServiceEchoPingPongResult{} + result := PingPongOnlyServiceEchoPingPongNewResult{} var retval *EchoResponse - if retval, err2 = p.handler.EchoPingPong(ctx, args.Req1); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoPingPong: "+err2.Error()) - oprot.WriteMessageBegin("EchoPingPong", thrift.EXCEPTION, seqId) + if retval, err2 = p.handler.EchoPingPongNew(ctx, args.Req1); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoPingPongNew: "+err2.Error()) + oprot.WriteMessageBegin("EchoPingPongNew", thrift.EXCEPTION, seqId) x.Write(oprot) oprot.WriteMessageEnd() oprot.Flush(ctx) @@ -3279,7 +3397,7 @@ func (p *pingPongOnlyServiceProcessorEchoPingPong) Process(ctx context.Context, } else { result.Success = retval } - if err2 = oprot.WriteMessageBegin("EchoPingPong", thrift.REPLY, seqId); err2 != nil { + if err2 = oprot.WriteMessageBegin("EchoPingPongNew", thrift.REPLY, seqId); err2 != nil { err = err2 } if err2 = result.Write(oprot); err == nil && err2 != nil { @@ -3297,39 +3415,39 @@ func (p *pingPongOnlyServiceProcessorEchoPingPong) Process(ctx context.Context, return true, err } -type PingPongOnlyServiceEchoPingPongArgs struct { +type PingPongOnlyServiceEchoPingPongNewArgs struct { Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` } -func NewPingPongOnlyServiceEchoPingPongArgs() *PingPongOnlyServiceEchoPingPongArgs { - return &PingPongOnlyServiceEchoPingPongArgs{} +func NewPingPongOnlyServiceEchoPingPongNewArgs() *PingPongOnlyServiceEchoPingPongNewArgs { + return &PingPongOnlyServiceEchoPingPongNewArgs{} } -func (p *PingPongOnlyServiceEchoPingPongArgs) InitDefault() { - *p = PingPongOnlyServiceEchoPingPongArgs{} +func (p *PingPongOnlyServiceEchoPingPongNewArgs) InitDefault() { + *p = PingPongOnlyServiceEchoPingPongNewArgs{} } -var PingPongOnlyServiceEchoPingPongArgs_Req1_DEFAULT *EchoRequest +var PingPongOnlyServiceEchoPingPongNewArgs_Req1_DEFAULT *EchoRequest -func (p *PingPongOnlyServiceEchoPingPongArgs) GetReq1() (v *EchoRequest) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) GetReq1() (v *EchoRequest) { if !p.IsSetReq1() { - return PingPongOnlyServiceEchoPingPongArgs_Req1_DEFAULT + return PingPongOnlyServiceEchoPingPongNewArgs_Req1_DEFAULT } return p.Req1 } -func (p *PingPongOnlyServiceEchoPingPongArgs) SetReq1(val *EchoRequest) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) SetReq1(val *EchoRequest) { p.Req1 = val } -var fieldIDToName_PingPongOnlyServiceEchoPingPongArgs = map[int16]string{ +var fieldIDToName_PingPongOnlyServiceEchoPingPongNewArgs = map[int16]string{ 1: "req1", } -func (p *PingPongOnlyServiceEchoPingPongArgs) IsSetReq1() bool { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) IsSetReq1() bool { return p.Req1 != nil } -func (p *PingPongOnlyServiceEchoPingPongArgs) Read(iprot thrift.TProtocol) (err error) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -3375,7 +3493,7 @@ ReadStructBeginError: ReadFieldBeginError: return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongArgs[fieldId]), err) + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongNewArgs[fieldId]), err) SkipFieldError: return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) @@ -3385,7 +3503,7 @@ ReadStructEndError: return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) ReadField1(iprot thrift.TProtocol) error { p.Req1 = NewEchoRequest() if err := p.Req1.Read(iprot); err != nil { return err @@ -3393,9 +3511,9 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) ReadField1(iprot thrift.TProtocol) return nil } -func (p *PingPongOnlyServiceEchoPingPongArgs) Write(oprot thrift.TProtocol) (err error) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 - if err = oprot.WriteStructBegin("EchoPingPong_args"); err != nil { + if err = oprot.WriteStructBegin("EchoPingPongNew_args"); err != nil { goto WriteStructBeginError } if p != nil { @@ -3421,7 +3539,7 @@ WriteStructEndError: return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongArgs) writeField1(oprot thrift.TProtocol) (err error) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) writeField1(oprot thrift.TProtocol) (err error) { if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { goto WriteFieldBeginError } @@ -3438,15 +3556,15 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongArgs) String() string { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) String() string { if p == nil { return "" } - return fmt.Sprintf("PingPongOnlyServiceEchoPingPongArgs(%+v)", *p) + return fmt.Sprintf("PingPongOnlyServiceEchoPingPongNewArgs(%+v)", *p) } -func (p *PingPongOnlyServiceEchoPingPongArgs) DeepEqual(ano *PingPongOnlyServiceEchoPingPongArgs) bool { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) DeepEqual(ano *PingPongOnlyServiceEchoPingPongNewArgs) bool { if p == ano { return true } else if p == nil || ano == nil { @@ -3458,7 +3576,7 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) DeepEqual(ano *PingPongOnlyService return true } -func (p *PingPongOnlyServiceEchoPingPongArgs) Field1DeepEqual(src *EchoRequest) bool { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) Field1DeepEqual(src *EchoRequest) bool { if !p.Req1.DeepEqual(src) { return false @@ -3466,39 +3584,39 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) Field1DeepEqual(src *EchoRequest) return true } -type PingPongOnlyServiceEchoPingPongResult struct { +type PingPongOnlyServiceEchoPingPongNewResult struct { Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` } -func NewPingPongOnlyServiceEchoPingPongResult() *PingPongOnlyServiceEchoPingPongResult { - return &PingPongOnlyServiceEchoPingPongResult{} +func NewPingPongOnlyServiceEchoPingPongNewResult() *PingPongOnlyServiceEchoPingPongNewResult { + return &PingPongOnlyServiceEchoPingPongNewResult{} } -func (p *PingPongOnlyServiceEchoPingPongResult) InitDefault() { - *p = PingPongOnlyServiceEchoPingPongResult{} +func (p *PingPongOnlyServiceEchoPingPongNewResult) InitDefault() { + *p = PingPongOnlyServiceEchoPingPongNewResult{} } -var PingPongOnlyServiceEchoPingPongResult_Success_DEFAULT *EchoResponse +var PingPongOnlyServiceEchoPingPongNewResult_Success_DEFAULT *EchoResponse -func (p *PingPongOnlyServiceEchoPingPongResult) GetSuccess() (v *EchoResponse) { +func (p *PingPongOnlyServiceEchoPingPongNewResult) GetSuccess() (v *EchoResponse) { if !p.IsSetSuccess() { - return PingPongOnlyServiceEchoPingPongResult_Success_DEFAULT + return PingPongOnlyServiceEchoPingPongNewResult_Success_DEFAULT } return p.Success } -func (p *PingPongOnlyServiceEchoPingPongResult) SetSuccess(x interface{}) { +func (p *PingPongOnlyServiceEchoPingPongNewResult) SetSuccess(x interface{}) { p.Success = x.(*EchoResponse) } -var fieldIDToName_PingPongOnlyServiceEchoPingPongResult = map[int16]string{ +var fieldIDToName_PingPongOnlyServiceEchoPingPongNewResult = map[int16]string{ 0: "success", } -func (p *PingPongOnlyServiceEchoPingPongResult) IsSetSuccess() bool { +func (p *PingPongOnlyServiceEchoPingPongNewResult) IsSetSuccess() bool { return p.Success != nil } -func (p *PingPongOnlyServiceEchoPingPongResult) Read(iprot thrift.TProtocol) (err error) { +func (p *PingPongOnlyServiceEchoPingPongNewResult) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -3544,7 +3662,7 @@ ReadStructBeginError: ReadFieldBeginError: return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongResult[fieldId]), err) + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongNewResult[fieldId]), err) SkipFieldError: return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) @@ -3554,7 +3672,7 @@ ReadStructEndError: return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongResult) ReadField0(iprot thrift.TProtocol) error { +func (p *PingPongOnlyServiceEchoPingPongNewResult) ReadField0(iprot thrift.TProtocol) error { p.Success = NewEchoResponse() if err := p.Success.Read(iprot); err != nil { return err @@ -3562,9 +3680,367 @@ func (p *PingPongOnlyServiceEchoPingPongResult) ReadField0(iprot thrift.TProtoco return nil } -func (p *PingPongOnlyServiceEchoPingPongResult) Write(oprot thrift.TProtocol) (err error) { +func (p *PingPongOnlyServiceEchoPingPongNewResult) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 - if err = oprot.WriteStructBegin("EchoPingPong_result"); err != nil { + if err = oprot.WriteStructBegin("EchoPingPongNew_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PingPongOnlyServiceEchoPingPongNewResult(%+v)", *p) + +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) DeepEqual(ano *PingPongOnlyServiceEchoPingPongNewResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) Field0DeepEqual(src *EchoResponse) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type PingPongOnlyServiceChildProcessor struct { + *PingPongOnlyServiceProcessor +} + +func NewPingPongOnlyServiceChildProcessor(handler PingPongOnlyServiceChild) *PingPongOnlyServiceChildProcessor { + self := &PingPongOnlyServiceChildProcessor{NewPingPongOnlyServiceProcessor(handler)} + self.AddToProcessorMap("EchoBidirectionalExtended", &pingPongOnlyServiceChildProcessorEchoBidirectionalExtended{handler: handler}) + return self +} + +type pingPongOnlyServiceChildProcessorEchoBidirectionalExtended struct { + handler PingPongOnlyServiceChild +} + +func (p *pingPongOnlyServiceChildProcessorEchoBidirectionalExtended) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + panic("streaming method PingPongOnlyServiceChild.EchoBidirectionalExtended(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") +} + +type PingPongOnlyServiceChildEchoBidirectionalExtendedArgs struct { + Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` +} + +func NewPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs { + return &PingPongOnlyServiceChildEchoBidirectionalExtendedArgs{} +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) InitDefault() { + *p = PingPongOnlyServiceChildEchoBidirectionalExtendedArgs{} +} + +var PingPongOnlyServiceChildEchoBidirectionalExtendedArgs_Req1_DEFAULT *EchoRequest + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) GetReq1() (v *EchoRequest) { + if !p.IsSetReq1() { + return PingPongOnlyServiceChildEchoBidirectionalExtendedArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) SetReq1(val *EchoRequest) { + p.Req1 = val +} + +var fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedArgs = map[int16]string{ + 1: "req1", +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = NewEchoRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoBidirectionalExtended_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PingPongOnlyServiceChildEchoBidirectionalExtendedArgs(%+v)", *p) + +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) DeepEqual(ano *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) Field1DeepEqual(src *EchoRequest) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type PingPongOnlyServiceChildEchoBidirectionalExtendedResult struct { + Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` +} + +func NewPingPongOnlyServiceChildEchoBidirectionalExtendedResult() *PingPongOnlyServiceChildEchoBidirectionalExtendedResult { + return &PingPongOnlyServiceChildEchoBidirectionalExtendedResult{} +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) InitDefault() { + *p = PingPongOnlyServiceChildEchoBidirectionalExtendedResult{} +} + +var PingPongOnlyServiceChildEchoBidirectionalExtendedResult_Success_DEFAULT *EchoResponse + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) GetSuccess() (v *EchoResponse) { + if !p.IsSetSuccess() { + return PingPongOnlyServiceChildEchoBidirectionalExtendedResult_Success_DEFAULT + } + return p.Success +} +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) SetSuccess(x interface{}) { + p.Success = x.(*EchoResponse) +} + +var fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedResult = map[int16]string{ + 0: "success", +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = NewEchoResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoBidirectionalExtended_result"); err != nil { goto WriteStructBeginError } if p != nil { @@ -3590,7 +4066,7 @@ WriteStructEndError: return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) writeField0(oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { goto WriteFieldBeginError @@ -3609,15 +4085,15 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongResult) String() string { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) String() string { if p == nil { return "" } - return fmt.Sprintf("PingPongOnlyServiceEchoPingPongResult(%+v)", *p) + return fmt.Sprintf("PingPongOnlyServiceChildEchoBidirectionalExtendedResult(%+v)", *p) } -func (p *PingPongOnlyServiceEchoPingPongResult) DeepEqual(ano *PingPongOnlyServiceEchoPingPongResult) bool { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) DeepEqual(ano *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) bool { if p == ano { return true } else if p == nil || ano == nil { @@ -3629,7 +4105,7 @@ func (p *PingPongOnlyServiceEchoPingPongResult) DeepEqual(ano *PingPongOnlyServi return true } -func (p *PingPongOnlyServiceEchoPingPongResult) Field0DeepEqual(src *EchoResponse) bool { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) Field0DeepEqual(src *EchoResponse) bool { if !p.Success.DeepEqual(src) { return false @@ -3637,6 +4113,15 @@ func (p *PingPongOnlyServiceEchoPingPongResult) Field0DeepEqual(src *EchoRespons return true } +type PingPongOnlyServiceChildChildProcessor struct { + *PingPongOnlyServiceChildProcessor +} + +func NewPingPongOnlyServiceChildChildProcessor(handler PingPongOnlyServiceChildChild) *PingPongOnlyServiceChildChildProcessor { + self := &PingPongOnlyServiceChildChildProcessor{NewPingPongOnlyServiceChildProcessor(handler)} + return self +} + type StreamOnlyServiceProcessor struct { processorMap map[string]thrift.TProcessorFunction handler StreamOnlyService @@ -3657,7 +4142,7 @@ func (p *StreamOnlyServiceProcessor) ProcessorMap() map[string]thrift.TProcessor func NewStreamOnlyServiceProcessor(handler StreamOnlyService) *StreamOnlyServiceProcessor { self := &StreamOnlyServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("EchoBidirectional", &streamOnlyServiceProcessorEchoBidirectional{handler: handler}) + self.AddToProcessorMap("EchoBidirectionalNew", &streamOnlyServiceProcessorEchoBidirectionalNew{handler: handler}) return self } func (p *StreamOnlyServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { @@ -3678,47 +4163,47 @@ func (p *StreamOnlyServiceProcessor) Process(ctx context.Context, iprot, oprot t return false, x } -type streamOnlyServiceProcessorEchoBidirectional struct { +type streamOnlyServiceProcessorEchoBidirectionalNew struct { handler StreamOnlyService } -func (p *streamOnlyServiceProcessorEchoBidirectional) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - panic("streaming method StreamOnlyService.EchoBidirectional(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") +func (p *streamOnlyServiceProcessorEchoBidirectionalNew) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + panic("streaming method StreamOnlyService.EchoBidirectionalNew(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") } -type StreamOnlyServiceEchoBidirectionalArgs struct { +type StreamOnlyServiceEchoBidirectionalNewArgs struct { Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` } -func NewStreamOnlyServiceEchoBidirectionalArgs() *StreamOnlyServiceEchoBidirectionalArgs { - return &StreamOnlyServiceEchoBidirectionalArgs{} +func NewStreamOnlyServiceEchoBidirectionalNewArgs() *StreamOnlyServiceEchoBidirectionalNewArgs { + return &StreamOnlyServiceEchoBidirectionalNewArgs{} } -func (p *StreamOnlyServiceEchoBidirectionalArgs) InitDefault() { - *p = StreamOnlyServiceEchoBidirectionalArgs{} +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) InitDefault() { + *p = StreamOnlyServiceEchoBidirectionalNewArgs{} } -var StreamOnlyServiceEchoBidirectionalArgs_Req1_DEFAULT *EchoRequest +var StreamOnlyServiceEchoBidirectionalNewArgs_Req1_DEFAULT *EchoRequest -func (p *StreamOnlyServiceEchoBidirectionalArgs) GetReq1() (v *EchoRequest) { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) GetReq1() (v *EchoRequest) { if !p.IsSetReq1() { - return StreamOnlyServiceEchoBidirectionalArgs_Req1_DEFAULT + return StreamOnlyServiceEchoBidirectionalNewArgs_Req1_DEFAULT } return p.Req1 } -func (p *StreamOnlyServiceEchoBidirectionalArgs) SetReq1(val *EchoRequest) { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) SetReq1(val *EchoRequest) { p.Req1 = val } -var fieldIDToName_StreamOnlyServiceEchoBidirectionalArgs = map[int16]string{ +var fieldIDToName_StreamOnlyServiceEchoBidirectionalNewArgs = map[int16]string{ 1: "req1", } -func (p *StreamOnlyServiceEchoBidirectionalArgs) IsSetReq1() bool { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) IsSetReq1() bool { return p.Req1 != nil } -func (p *StreamOnlyServiceEchoBidirectionalArgs) Read(iprot thrift.TProtocol) (err error) { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -3764,7 +4249,7 @@ ReadStructBeginError: ReadFieldBeginError: return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalArgs[fieldId]), err) + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalNewArgs[fieldId]), err) SkipFieldError: return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) @@ -3774,7 +4259,7 @@ ReadStructEndError: return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *StreamOnlyServiceEchoBidirectionalArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) ReadField1(iprot thrift.TProtocol) error { p.Req1 = NewEchoRequest() if err := p.Req1.Read(iprot); err != nil { return err @@ -3782,9 +4267,9 @@ func (p *StreamOnlyServiceEchoBidirectionalArgs) ReadField1(iprot thrift.TProtoc return nil } -func (p *StreamOnlyServiceEchoBidirectionalArgs) Write(oprot thrift.TProtocol) (err error) { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 - if err = oprot.WriteStructBegin("EchoBidirectional_args"); err != nil { + if err = oprot.WriteStructBegin("EchoBidirectionalNew_args"); err != nil { goto WriteStructBeginError } if p != nil { @@ -3810,7 +4295,7 @@ WriteStructEndError: return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) } -func (p *StreamOnlyServiceEchoBidirectionalArgs) writeField1(oprot thrift.TProtocol) (err error) { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) writeField1(oprot thrift.TProtocol) (err error) { if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { goto WriteFieldBeginError } @@ -3827,15 +4312,15 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } -func (p *StreamOnlyServiceEchoBidirectionalArgs) String() string { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) String() string { if p == nil { return "" } - return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalArgs(%+v)", *p) + return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalNewArgs(%+v)", *p) } -func (p *StreamOnlyServiceEchoBidirectionalArgs) DeepEqual(ano *StreamOnlyServiceEchoBidirectionalArgs) bool { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) DeepEqual(ano *StreamOnlyServiceEchoBidirectionalNewArgs) bool { if p == ano { return true } else if p == nil || ano == nil { @@ -3847,7 +4332,7 @@ func (p *StreamOnlyServiceEchoBidirectionalArgs) DeepEqual(ano *StreamOnlyServic return true } -func (p *StreamOnlyServiceEchoBidirectionalArgs) Field1DeepEqual(src *EchoRequest) bool { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) Field1DeepEqual(src *EchoRequest) bool { if !p.Req1.DeepEqual(src) { return false @@ -3855,39 +4340,39 @@ func (p *StreamOnlyServiceEchoBidirectionalArgs) Field1DeepEqual(src *EchoReques return true } -type StreamOnlyServiceEchoBidirectionalResult struct { +type StreamOnlyServiceEchoBidirectionalNewResult struct { Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` } -func NewStreamOnlyServiceEchoBidirectionalResult() *StreamOnlyServiceEchoBidirectionalResult { - return &StreamOnlyServiceEchoBidirectionalResult{} +func NewStreamOnlyServiceEchoBidirectionalNewResult() *StreamOnlyServiceEchoBidirectionalNewResult { + return &StreamOnlyServiceEchoBidirectionalNewResult{} } -func (p *StreamOnlyServiceEchoBidirectionalResult) InitDefault() { - *p = StreamOnlyServiceEchoBidirectionalResult{} +func (p *StreamOnlyServiceEchoBidirectionalNewResult) InitDefault() { + *p = StreamOnlyServiceEchoBidirectionalNewResult{} } -var StreamOnlyServiceEchoBidirectionalResult_Success_DEFAULT *EchoResponse +var StreamOnlyServiceEchoBidirectionalNewResult_Success_DEFAULT *EchoResponse -func (p *StreamOnlyServiceEchoBidirectionalResult) GetSuccess() (v *EchoResponse) { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) GetSuccess() (v *EchoResponse) { if !p.IsSetSuccess() { - return StreamOnlyServiceEchoBidirectionalResult_Success_DEFAULT + return StreamOnlyServiceEchoBidirectionalNewResult_Success_DEFAULT } return p.Success } -func (p *StreamOnlyServiceEchoBidirectionalResult) SetSuccess(x interface{}) { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) SetSuccess(x interface{}) { p.Success = x.(*EchoResponse) } -var fieldIDToName_StreamOnlyServiceEchoBidirectionalResult = map[int16]string{ +var fieldIDToName_StreamOnlyServiceEchoBidirectionalNewResult = map[int16]string{ 0: "success", } -func (p *StreamOnlyServiceEchoBidirectionalResult) IsSetSuccess() bool { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) IsSetSuccess() bool { return p.Success != nil } -func (p *StreamOnlyServiceEchoBidirectionalResult) Read(iprot thrift.TProtocol) (err error) { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -3933,7 +4418,7 @@ ReadStructBeginError: ReadFieldBeginError: return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalResult[fieldId]), err) + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalNewResult[fieldId]), err) SkipFieldError: return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) @@ -3943,7 +4428,7 @@ ReadStructEndError: return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *StreamOnlyServiceEchoBidirectionalResult) ReadField0(iprot thrift.TProtocol) error { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) ReadField0(iprot thrift.TProtocol) error { p.Success = NewEchoResponse() if err := p.Success.Read(iprot); err != nil { return err @@ -3951,9 +4436,9 @@ func (p *StreamOnlyServiceEchoBidirectionalResult) ReadField0(iprot thrift.TProt return nil } -func (p *StreamOnlyServiceEchoBidirectionalResult) Write(oprot thrift.TProtocol) (err error) { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 - if err = oprot.WriteStructBegin("EchoBidirectional_result"); err != nil { + if err = oprot.WriteStructBegin("EchoBidirectionalNew_result"); err != nil { goto WriteStructBeginError } if p != nil { @@ -3979,7 +4464,7 @@ WriteStructEndError: return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) } -func (p *StreamOnlyServiceEchoBidirectionalResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) writeField0(oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { goto WriteFieldBeginError @@ -3998,15 +4483,15 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) } -func (p *StreamOnlyServiceEchoBidirectionalResult) String() string { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) String() string { if p == nil { return "" } - return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalResult(%+v)", *p) + return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalNewResult(%+v)", *p) } -func (p *StreamOnlyServiceEchoBidirectionalResult) DeepEqual(ano *StreamOnlyServiceEchoBidirectionalResult) bool { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) DeepEqual(ano *StreamOnlyServiceEchoBidirectionalNewResult) bool { if p == ano { return true } else if p == nil || ano == nil { @@ -4018,10 +4503,28 @@ func (p *StreamOnlyServiceEchoBidirectionalResult) DeepEqual(ano *StreamOnlyServ return true } -func (p *StreamOnlyServiceEchoBidirectionalResult) Field0DeepEqual(src *EchoResponse) bool { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) Field0DeepEqual(src *EchoResponse) bool { if !p.Success.DeepEqual(src) { return false } return true } + +type StreamOnlyServiceChildProcessor struct { + *StreamOnlyServiceProcessor +} + +func NewStreamOnlyServiceChildProcessor(handler StreamOnlyServiceChild) *StreamOnlyServiceChildProcessor { + self := &StreamOnlyServiceChildProcessor{NewStreamOnlyServiceProcessor(handler)} + return self +} + +type StreamOnlyServiceChildChildProcessor struct { + *StreamOnlyServiceChildProcessor +} + +func NewStreamOnlyServiceChildChildProcessor(handler StreamOnlyServiceChildChild) *StreamOnlyServiceChildChildProcessor { + self := &StreamOnlyServiceChildChildProcessor{NewStreamOnlyServiceChildProcessor(handler)} + return self +} diff --git a/thrift_streaming/kitex_gen/echo/k-api.go b/thrift_streaming/kitex_gen/echo/k-api.go index d0db499..9eaa6c2 100644 --- a/thrift_streaming/kitex_gen/echo/k-api.go +++ b/thrift_streaming/kitex_gen/echo/k-api.go @@ -2171,7 +2171,7 @@ func (p *EchoServicePingResult) BLength() int { return l } -func (p *PingPongOnlyServiceEchoPingPongArgs) FastRead(buf []byte) (int, error) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) FastRead(buf []byte) (int, error) { var err error var offset int var l int @@ -2233,7 +2233,7 @@ ReadStructBeginError: ReadFieldBeginError: return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongArgs[fieldId]), err) + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongNewArgs[fieldId]), err) SkipFieldError: return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) ReadFieldEndError: @@ -2242,7 +2242,7 @@ ReadStructEndError: return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongArgs) FastReadField1(buf []byte) (int, error) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) FastReadField1(buf []byte) (int, error) { offset := 0 tmp := NewEchoRequest() @@ -2256,13 +2256,13 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) FastReadField1(buf []byte) (int, e } // for compatibility -func (p *PingPongOnlyServiceEchoPingPongArgs) FastWrite(buf []byte) int { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) FastWrite(buf []byte) int { return 0 } -func (p *PingPongOnlyServiceEchoPingPongArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPong_args") + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPongNew_args") if p != nil { offset += p.fastWriteField1(buf[offset:], binaryWriter) } @@ -2271,9 +2271,9 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) FastWriteNocopy(buf []byte, binary return offset } -func (p *PingPongOnlyServiceEchoPingPongArgs) BLength() int { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("EchoPingPong_args") + l += bthrift.Binary.StructBeginLength("EchoPingPongNew_args") if p != nil { l += p.field1Length() } @@ -2282,7 +2282,7 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) BLength() int { return l } -func (p *PingPongOnlyServiceEchoPingPongArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { offset := 0 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) @@ -2290,7 +2290,7 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) fastWriteField1(buf []byte, binary return offset } -func (p *PingPongOnlyServiceEchoPingPongArgs) field1Length() int { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) field1Length() int { l := 0 l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) l += p.Req1.BLength() @@ -2298,7 +2298,7 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) field1Length() int { return l } -func (p *PingPongOnlyServiceEchoPingPongResult) FastRead(buf []byte) (int, error) { +func (p *PingPongOnlyServiceEchoPingPongNewResult) FastRead(buf []byte) (int, error) { var err error var offset int var l int @@ -2360,7 +2360,7 @@ ReadStructBeginError: ReadFieldBeginError: return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongResult[fieldId]), err) + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongNewResult[fieldId]), err) SkipFieldError: return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) ReadFieldEndError: @@ -2369,7 +2369,7 @@ ReadStructEndError: return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongResult) FastReadField0(buf []byte) (int, error) { +func (p *PingPongOnlyServiceEchoPingPongNewResult) FastReadField0(buf []byte) (int, error) { offset := 0 tmp := NewEchoResponse() @@ -2383,13 +2383,13 @@ func (p *PingPongOnlyServiceEchoPingPongResult) FastReadField0(buf []byte) (int, } // for compatibility -func (p *PingPongOnlyServiceEchoPingPongResult) FastWrite(buf []byte) int { +func (p *PingPongOnlyServiceEchoPingPongNewResult) FastWrite(buf []byte) int { return 0 } -func (p *PingPongOnlyServiceEchoPingPongResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PingPongOnlyServiceEchoPingPongNewResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPong_result") + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPongNew_result") if p != nil { offset += p.fastWriteField0(buf[offset:], binaryWriter) } @@ -2398,9 +2398,9 @@ func (p *PingPongOnlyServiceEchoPingPongResult) FastWriteNocopy(buf []byte, bina return offset } -func (p *PingPongOnlyServiceEchoPingPongResult) BLength() int { +func (p *PingPongOnlyServiceEchoPingPongNewResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("EchoPingPong_result") + l += bthrift.Binary.StructBeginLength("EchoPingPongNew_result") if p != nil { l += p.field0Length() } @@ -2409,7 +2409,7 @@ func (p *PingPongOnlyServiceEchoPingPongResult) BLength() int { return l } -func (p *PingPongOnlyServiceEchoPingPongResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PingPongOnlyServiceEchoPingPongNewResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { offset := 0 if p.IsSetSuccess() { offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) @@ -2419,7 +2419,7 @@ func (p *PingPongOnlyServiceEchoPingPongResult) fastWriteField0(buf []byte, bina return offset } -func (p *PingPongOnlyServiceEchoPingPongResult) field0Length() int { +func (p *PingPongOnlyServiceEchoPingPongNewResult) field0Length() int { l := 0 if p.IsSetSuccess() { l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) @@ -2429,7 +2429,7 @@ func (p *PingPongOnlyServiceEchoPingPongResult) field0Length() int { return l } -func (p *StreamOnlyServiceEchoBidirectionalArgs) FastRead(buf []byte) (int, error) { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) FastRead(buf []byte) (int, error) { var err error var offset int var l int @@ -2491,7 +2491,7 @@ ReadStructBeginError: ReadFieldBeginError: return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalArgs[fieldId]), err) + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedArgs[fieldId]), err) SkipFieldError: return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) ReadFieldEndError: @@ -2500,7 +2500,7 @@ ReadStructEndError: return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *StreamOnlyServiceEchoBidirectionalArgs) FastReadField1(buf []byte) (int, error) { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) FastReadField1(buf []byte) (int, error) { offset := 0 tmp := NewEchoRequest() @@ -2514,13 +2514,13 @@ func (p *StreamOnlyServiceEchoBidirectionalArgs) FastReadField1(buf []byte) (int } // for compatibility -func (p *StreamOnlyServiceEchoBidirectionalArgs) FastWrite(buf []byte) int { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) FastWrite(buf []byte) int { return 0 } -func (p *StreamOnlyServiceEchoBidirectionalArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectional_args") + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectionalExtended_args") if p != nil { offset += p.fastWriteField1(buf[offset:], binaryWriter) } @@ -2529,9 +2529,9 @@ func (p *StreamOnlyServiceEchoBidirectionalArgs) FastWriteNocopy(buf []byte, bin return offset } -func (p *StreamOnlyServiceEchoBidirectionalArgs) BLength() int { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("EchoBidirectional_args") + l += bthrift.Binary.StructBeginLength("EchoBidirectionalExtended_args") if p != nil { l += p.field1Length() } @@ -2540,7 +2540,7 @@ func (p *StreamOnlyServiceEchoBidirectionalArgs) BLength() int { return l } -func (p *StreamOnlyServiceEchoBidirectionalArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { offset := 0 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) @@ -2548,7 +2548,7 @@ func (p *StreamOnlyServiceEchoBidirectionalArgs) fastWriteField1(buf []byte, bin return offset } -func (p *StreamOnlyServiceEchoBidirectionalArgs) field1Length() int { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) field1Length() int { l := 0 l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) l += p.Req1.BLength() @@ -2556,7 +2556,7 @@ func (p *StreamOnlyServiceEchoBidirectionalArgs) field1Length() int { return l } -func (p *StreamOnlyServiceEchoBidirectionalResult) FastRead(buf []byte) (int, error) { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) FastRead(buf []byte) (int, error) { var err error var offset int var l int @@ -2618,7 +2618,7 @@ ReadStructBeginError: ReadFieldBeginError: return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalResult[fieldId]), err) + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedResult[fieldId]), err) SkipFieldError: return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) ReadFieldEndError: @@ -2627,7 +2627,7 @@ ReadStructEndError: return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *StreamOnlyServiceEchoBidirectionalResult) FastReadField0(buf []byte) (int, error) { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) FastReadField0(buf []byte) (int, error) { offset := 0 tmp := NewEchoResponse() @@ -2641,13 +2641,13 @@ func (p *StreamOnlyServiceEchoBidirectionalResult) FastReadField0(buf []byte) (i } // for compatibility -func (p *StreamOnlyServiceEchoBidirectionalResult) FastWrite(buf []byte) int { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) FastWrite(buf []byte) int { return 0 } -func (p *StreamOnlyServiceEchoBidirectionalResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectional_result") + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectionalExtended_result") if p != nil { offset += p.fastWriteField0(buf[offset:], binaryWriter) } @@ -2656,9 +2656,267 @@ func (p *StreamOnlyServiceEchoBidirectionalResult) FastWriteNocopy(buf []byte, b return offset } -func (p *StreamOnlyServiceEchoBidirectionalResult) BLength() int { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("EchoBidirectional_result") + l += bthrift.Binary.StructBeginLength("EchoBidirectionalExtended_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalNewArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectionalNew_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoBidirectionalNew_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalNewResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *StreamOnlyServiceEchoBidirectionalNewResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectionalNew_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoBidirectionalNew_result") if p != nil { l += p.field0Length() } @@ -2667,7 +2925,7 @@ func (p *StreamOnlyServiceEchoBidirectionalResult) BLength() int { return l } -func (p *StreamOnlyServiceEchoBidirectionalResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { offset := 0 if p.IsSetSuccess() { offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) @@ -2677,7 +2935,7 @@ func (p *StreamOnlyServiceEchoBidirectionalResult) fastWriteField0(buf []byte, b return offset } -func (p *StreamOnlyServiceEchoBidirectionalResult) field0Length() int { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) field0Length() int { l := 0 if p.IsSetSuccess() { l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) @@ -2743,18 +3001,26 @@ func (p *EchoServicePingResult) GetResult() interface{} { return nil } -func (p *PingPongOnlyServiceEchoPingPongArgs) GetFirstArgument() interface{} { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) GetResult() interface{} { + return p.Success +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) GetFirstArgument() interface{} { return p.Req1 } -func (p *PingPongOnlyServiceEchoPingPongResult) GetResult() interface{} { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) GetResult() interface{} { return p.Success } -func (p *StreamOnlyServiceEchoBidirectionalArgs) GetFirstArgument() interface{} { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) GetFirstArgument() interface{} { return p.Req1 } -func (p *StreamOnlyServiceEchoBidirectionalResult) GetResult() interface{} { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) GetResult() interface{} { return p.Success } diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservice/client.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/client.go index 8d34c24..0b298a3 100644 --- a/thrift_streaming/kitex_gen/echo/pingpongonlyservice/client.go +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/client.go @@ -11,7 +11,7 @@ import ( // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. type Client interface { - EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) + EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) } // NewClient creates a client for the service defined in IDL. @@ -43,7 +43,7 @@ type kPingPongOnlyServiceClient struct { *kClient } -func (p *kPingPongOnlyServiceClient) EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { +func (p *kPingPongOnlyServiceClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.EchoPingPong(ctx, req1) + return p.kClient.EchoPingPongNew(ctx, req1) } diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservice/pingpongonlyservice.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/pingpongonlyservice.go index 37bf1bd..0bf7178 100644 --- a/thrift_streaming/kitex_gen/echo/pingpongonlyservice/pingpongonlyservice.go +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/pingpongonlyservice.go @@ -13,10 +13,10 @@ import ( var errInvalidMessageType = errors.New("invalid message type for service method handler") var serviceMethods = map[string]kitex.MethodInfo{ - "EchoPingPong": kitex.NewMethodInfo( - echoPingPongHandler, - newPingPongOnlyServiceEchoPingPongArgs, - newPingPongOnlyServiceEchoPingPongResult, + "EchoPingPongNew": kitex.NewMethodInfo( + echoPingPongNewHandler, + newPingPongOnlyServiceEchoPingPongNewArgs, + newPingPongOnlyServiceEchoPingPongNewResult, false, kitex.WithStreamingMode(kitex.StreamingNone), ), @@ -86,22 +86,22 @@ func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreami return svcInfo } -func echoPingPongHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongArgs) - realResult := result.(*echo.PingPongOnlyServiceEchoPingPongResult) - success, err := handler.(echo.PingPongOnlyService).EchoPingPong(ctx, realArg.Req1) +func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) if err != nil { return err } realResult.Success = success return nil } -func newPingPongOnlyServiceEchoPingPongArgs() interface{} { - return echo.NewPingPongOnlyServiceEchoPingPongArgs() +func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() } -func newPingPongOnlyServiceEchoPingPongResult() interface{} { - return echo.NewPingPongOnlyServiceEchoPingPongResult() +func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewResult() } type kClient struct { @@ -114,11 +114,11 @@ func newServiceClient(c client.Client) *kClient { } } -func (p *kClient) EchoPingPong(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { - var _args echo.PingPongOnlyServiceEchoPingPongArgs +func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongNewArgs _args.Req1 = req1 - var _result echo.PingPongOnlyServiceEchoPingPongResult - if err = p.c.Call(ctx, "EchoPingPong", &_args, &_result); err != nil { + var _result echo.PingPongOnlyServiceEchoPingPongNewResult + if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { return } return _result.GetSuccess(), nil diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/client.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/client.go new file mode 100644 index 0000000..9603c81 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/client.go @@ -0,0 +1,99 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalExtended(ctx context.Context, callOptions ...streamcall.Option) (stream PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, err error) +} + +type PingPongOnlyServiceChild_EchoBidirectionalExtendedClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceChildClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceChildClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceChildClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPongNew(ctx, req1) +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceChildStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceChildStreamClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceChildStreamClient) EchoBidirectionalExtended(ctx context.Context, callOptions ...streamcall.Option) (stream PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalExtended(ctx) +} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/invoker.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/invoker.go new file mode 100644 index 0000000..1d57220 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.PingPongOnlyServiceChild, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/pingpongonlyservicechild.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/pingpongonlyservicechild.go new file mode 100644 index 0000000..d9fde95 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/pingpongonlyservicechild.go @@ -0,0 +1,190 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechild + +import ( + "context" + "errors" + "fmt" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoPingPongNew": kitex.NewMethodInfo( + echoPingPongNewHandler, + newPingPongOnlyServiceEchoPingPongNewArgs, + newPingPongOnlyServiceEchoPingPongNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "EchoBidirectionalExtended": kitex.NewMethodInfo( + echoBidirectionalExtendedHandler, + newPingPongOnlyServiceChildEchoBidirectionalExtendedArgs, + newPingPongOnlyServiceChildEchoBidirectionalExtendedResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + pingPongOnlyServiceChildServiceInfo = NewServiceInfo() + pingPongOnlyServiceChildServiceInfoForClient = NewServiceInfoForClient() + pingPongOnlyServiceChildServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return pingPongOnlyServiceChildServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return pingPongOnlyServiceChildServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return pingPongOnlyServiceChildServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "PingPongOnlyServiceChild" + handlerType := (*echo.PingPongOnlyServiceChild)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "echo", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() +} + +func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewResult() +} + +func echoBidirectionalExtendedHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("PingPongOnlyServiceChild.EchoBidirectionalExtended is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &pingPongOnlyServiceChildEchoBidirectionalExtendedServer{st.Stream} + return handler.(echo.PingPongOnlyServiceChild).EchoBidirectionalExtended(stream) +} + +type pingPongOnlyServiceChildEchoBidirectionalExtendedClient struct { + streaming.Stream +} + +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type pingPongOnlyServiceChildEchoBidirectionalExtendedServer struct { + streaming.Stream +} + +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() interface{} { + return echo.NewPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() +} + +func newPingPongOnlyServiceChildEchoBidirectionalExtendedResult() interface{} { + return echo.NewPingPongOnlyServiceChildEchoBidirectionalExtendedResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongNewArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceEchoPingPongNewResult + if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) EchoBidirectionalExtended(ctx context.Context) (PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectionalExtended", nil, res) + if err != nil { + return nil, err + } + stream := &pingPongOnlyServiceChildEchoBidirectionalExtendedClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/server.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/server.go new file mode 100644 index 0000000..3c88548 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package pingpongonlyservicechild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.PingPongOnlyServiceChild, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/client.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/client.go new file mode 100644 index 0000000..dcc00bc --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/client.go @@ -0,0 +1,99 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechildchild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalExtended(ctx context.Context, callOptions ...streamcall.Option) (stream PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, err error) +} + +type PingPongOnlyServiceChild_EchoBidirectionalExtendedClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceChildChildClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceChildChildClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceChildChildClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPongNew(ctx, req1) +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceChildChildStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceChildChildStreamClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceChildChildStreamClient) EchoBidirectionalExtended(ctx context.Context, callOptions ...streamcall.Option) (stream PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalExtended(ctx) +} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/invoker.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/invoker.go new file mode 100644 index 0000000..50d661b --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechildchild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.PingPongOnlyServiceChildChild, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go new file mode 100644 index 0000000..7fe56bb --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go @@ -0,0 +1,190 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechildchild + +import ( + "context" + "errors" + "fmt" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoPingPongNew": kitex.NewMethodInfo( + echoPingPongNewHandler, + newPingPongOnlyServiceEchoPingPongNewArgs, + newPingPongOnlyServiceEchoPingPongNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "EchoBidirectionalExtended": kitex.NewMethodInfo( + echoBidirectionalExtendedHandler, + newPingPongOnlyServiceChildEchoBidirectionalExtendedArgs, + newPingPongOnlyServiceChildEchoBidirectionalExtendedResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + pingPongOnlyServiceChildChildServiceInfo = NewServiceInfo() + pingPongOnlyServiceChildChildServiceInfoForClient = NewServiceInfoForClient() + pingPongOnlyServiceChildChildServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return pingPongOnlyServiceChildChildServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return pingPongOnlyServiceChildChildServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return pingPongOnlyServiceChildChildServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "PingPongOnlyServiceChildChild" + handlerType := (*echo.PingPongOnlyServiceChildChild)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "echo", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() +} + +func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewResult() +} + +func echoBidirectionalExtendedHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("PingPongOnlyServiceChild.EchoBidirectionalExtended is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &pingPongOnlyServiceChildEchoBidirectionalExtendedServer{st.Stream} + return handler.(echo.PingPongOnlyServiceChild).EchoBidirectionalExtended(stream) +} + +type pingPongOnlyServiceChildEchoBidirectionalExtendedClient struct { + streaming.Stream +} + +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type pingPongOnlyServiceChildEchoBidirectionalExtendedServer struct { + streaming.Stream +} + +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() interface{} { + return echo.NewPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() +} + +func newPingPongOnlyServiceChildEchoBidirectionalExtendedResult() interface{} { + return echo.NewPingPongOnlyServiceChildEchoBidirectionalExtendedResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongNewArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceEchoPingPongNewResult + if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) EchoBidirectionalExtended(ctx context.Context) (PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectionalExtended", nil, res) + if err != nil { + return nil, err + } + stream := &pingPongOnlyServiceChildEchoBidirectionalExtendedClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/server.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/server.go new file mode 100644 index 0000000..39e1083 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package pingpongonlyservicechildchild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.PingPongOnlyServiceChildChild, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservice/client.go b/thrift_streaming/kitex_gen/echo/streamonlyservice/client.go index a489e44..e86aac5 100644 --- a/thrift_streaming/kitex_gen/echo/streamonlyservice/client.go +++ b/thrift_streaming/kitex_gen/echo/streamonlyservice/client.go @@ -18,10 +18,10 @@ type Client interface { // StreamClient is designed to provide Interface for Streaming APIs. type StreamClient interface { - EchoBidirectional(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalClient, err error) + EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) } -type StreamOnlyService_EchoBidirectionalClient interface { +type StreamOnlyService_EchoBidirectionalNewClient interface { streaming.Stream Send(*echo.EchoRequest) error Recv() (*echo.EchoResponse, error) @@ -86,7 +86,7 @@ type kStreamOnlyServiceStreamClient struct { *kClient } -func (p *kStreamOnlyServiceStreamClient) EchoBidirectional(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalClient, err error) { +func (p *kStreamOnlyServiceStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.EchoBidirectional(ctx) + return p.kClient.EchoBidirectionalNew(ctx) } diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservice/streamonlyservice.go b/thrift_streaming/kitex_gen/echo/streamonlyservice/streamonlyservice.go index feb738c..269fe07 100644 --- a/thrift_streaming/kitex_gen/echo/streamonlyservice/streamonlyservice.go +++ b/thrift_streaming/kitex_gen/echo/streamonlyservice/streamonlyservice.go @@ -15,10 +15,10 @@ import ( var errInvalidMessageType = errors.New("invalid message type for service method handler") var serviceMethods = map[string]kitex.MethodInfo{ - "EchoBidirectional": kitex.NewMethodInfo( - echoBidirectionalHandler, - newStreamOnlyServiceEchoBidirectionalArgs, - newStreamOnlyServiceEchoBidirectionalResult, + "EchoBidirectionalNew": kitex.NewMethodInfo( + echoBidirectionalNewHandler, + newStreamOnlyServiceEchoBidirectionalNewArgs, + newStreamOnlyServiceEchoBidirectionalNewResult, false, kitex.WithStreamingMode(kitex.StreamingBidirectional), ), @@ -88,46 +88,46 @@ func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreami return svcInfo } -func echoBidirectionalHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { +func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { st, ok := arg.(*streaming.Args) if !ok { - return errors.New("StreamOnlyService.EchoBidirectional is a thrift streaming method, please call with Kitex StreamClient") + return errors.New("StreamOnlyService.EchoBidirectionalNew is a thrift streaming method, please call with Kitex StreamClient") } - stream := &streamOnlyServiceEchoBidirectionalServer{st.Stream} - return handler.(echo.StreamOnlyService).EchoBidirectional(stream) + stream := &streamOnlyServiceEchoBidirectionalNewServer{st.Stream} + return handler.(echo.StreamOnlyService).EchoBidirectionalNew(stream) } -type streamOnlyServiceEchoBidirectionalClient struct { +type streamOnlyServiceEchoBidirectionalNewClient struct { streaming.Stream } -func (x *streamOnlyServiceEchoBidirectionalClient) Send(m *echo.EchoRequest) error { +func (x *streamOnlyServiceEchoBidirectionalNewClient) Send(m *echo.EchoRequest) error { return x.Stream.SendMsg(m) } -func (x *streamOnlyServiceEchoBidirectionalClient) Recv() (*echo.EchoResponse, error) { +func (x *streamOnlyServiceEchoBidirectionalNewClient) Recv() (*echo.EchoResponse, error) { m := new(echo.EchoResponse) return m, x.Stream.RecvMsg(m) } -type streamOnlyServiceEchoBidirectionalServer struct { +type streamOnlyServiceEchoBidirectionalNewServer struct { streaming.Stream } -func (x *streamOnlyServiceEchoBidirectionalServer) Send(m *echo.EchoResponse) error { +func (x *streamOnlyServiceEchoBidirectionalNewServer) Send(m *echo.EchoResponse) error { return x.Stream.SendMsg(m) } -func (x *streamOnlyServiceEchoBidirectionalServer) Recv() (*echo.EchoRequest, error) { +func (x *streamOnlyServiceEchoBidirectionalNewServer) Recv() (*echo.EchoRequest, error) { m := new(echo.EchoRequest) return m, x.Stream.RecvMsg(m) } -func newStreamOnlyServiceEchoBidirectionalArgs() interface{} { - return echo.NewStreamOnlyServiceEchoBidirectionalArgs() +func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() } -func newStreamOnlyServiceEchoBidirectionalResult() interface{} { - return echo.NewStreamOnlyServiceEchoBidirectionalResult() +func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() } type kClient struct { @@ -140,16 +140,16 @@ func newServiceClient(c client.Client) *kClient { } } -func (p *kClient) EchoBidirectional(ctx context.Context) (StreamOnlyService_EchoBidirectionalClient, error) { +func (p *kClient) EchoBidirectionalNew(ctx context.Context) (StreamOnlyService_EchoBidirectionalNewClient, error) { streamClient, ok := p.c.(client.Streaming) if !ok { return nil, fmt.Errorf("client not support streaming") } res := new(streaming.Result) - err := streamClient.Stream(ctx, "EchoBidirectional", nil, res) + err := streamClient.Stream(ctx, "EchoBidirectionalNew", nil, res) if err != nil { return nil, err } - stream := &streamOnlyServiceEchoBidirectionalClient{res.Stream} + stream := &streamOnlyServiceEchoBidirectionalNewClient{res.Stream} return stream, nil } diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechild/client.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechild/client.go new file mode 100644 index 0000000..257e546 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservicechild/client.go @@ -0,0 +1,92 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) +} + +type StreamOnlyService_EchoBidirectionalNewClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceChildClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceChildClient struct { + *kClient +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceChildStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceChildStreamClient struct { + *kClient +} + +func (p *kStreamOnlyServiceChildStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalNew(ctx) +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechild/invoker.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechild/invoker.go new file mode 100644 index 0000000..34a30f2 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservicechild/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.StreamOnlyServiceChild, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechild/server.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechild/server.go new file mode 100644 index 0000000..c2d5088 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservicechild/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package streamonlyservicechild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.StreamOnlyServiceChild, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechild/streamonlyservicechild.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechild/streamonlyservicechild.go new file mode 100644 index 0000000..110d6a4 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservicechild/streamonlyservicechild.go @@ -0,0 +1,155 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechild + +import ( + "context" + "errors" + "fmt" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoBidirectionalNew": kitex.NewMethodInfo( + echoBidirectionalNewHandler, + newStreamOnlyServiceEchoBidirectionalNewArgs, + newStreamOnlyServiceEchoBidirectionalNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + streamOnlyServiceChildServiceInfo = NewServiceInfo() + streamOnlyServiceChildServiceInfoForClient = NewServiceInfoForClient() + streamOnlyServiceChildServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return streamOnlyServiceChildServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return streamOnlyServiceChildServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return streamOnlyServiceChildServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "StreamOnlyServiceChild" + handlerType := (*echo.StreamOnlyServiceChild)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "echo", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("StreamOnlyService.EchoBidirectionalNew is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &streamOnlyServiceEchoBidirectionalNewServer{st.Stream} + return handler.(echo.StreamOnlyService).EchoBidirectionalNew(stream) +} + +type streamOnlyServiceEchoBidirectionalNewClient struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *streamOnlyServiceEchoBidirectionalNewClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type streamOnlyServiceEchoBidirectionalNewServer struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() +} + +func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoBidirectionalNew(ctx context.Context) (StreamOnlyService_EchoBidirectionalNewClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectionalNew", nil, res) + if err != nil { + return nil, err + } + stream := &streamOnlyServiceEchoBidirectionalNewClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/client.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/client.go new file mode 100644 index 0000000..34e5462 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/client.go @@ -0,0 +1,92 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechildchild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) +} + +type StreamOnlyService_EchoBidirectionalNewClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceChildChildClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceChildChildClient struct { + *kClient +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceChildChildStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceChildChildStreamClient struct { + *kClient +} + +func (p *kStreamOnlyServiceChildChildStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalNew(ctx) +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/invoker.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/invoker.go new file mode 100644 index 0000000..d314e03 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechildchild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.StreamOnlyServiceChildChild, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/server.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/server.go new file mode 100644 index 0000000..68b2d4c --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package streamonlyservicechildchild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.StreamOnlyServiceChildChild, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/streamonlyservicechildchild.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/streamonlyservicechildchild.go new file mode 100644 index 0000000..e254e50 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/streamonlyservicechildchild.go @@ -0,0 +1,155 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechildchild + +import ( + "context" + "errors" + "fmt" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoBidirectionalNew": kitex.NewMethodInfo( + echoBidirectionalNewHandler, + newStreamOnlyServiceEchoBidirectionalNewArgs, + newStreamOnlyServiceEchoBidirectionalNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + streamOnlyServiceChildChildServiceInfo = NewServiceInfo() + streamOnlyServiceChildChildServiceInfoForClient = NewServiceInfoForClient() + streamOnlyServiceChildChildServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return streamOnlyServiceChildChildServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return streamOnlyServiceChildChildServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return streamOnlyServiceChildChildServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "StreamOnlyServiceChildChild" + handlerType := (*echo.StreamOnlyServiceChildChild)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "echo", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("StreamOnlyService.EchoBidirectionalNew is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &streamOnlyServiceEchoBidirectionalNewServer{st.Stream} + return handler.(echo.StreamOnlyService).EchoBidirectionalNew(stream) +} + +type streamOnlyServiceEchoBidirectionalNewClient struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *streamOnlyServiceEchoBidirectionalNewClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type streamOnlyServiceEchoBidirectionalNewServer struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() +} + +func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoBidirectionalNew(ctx context.Context) (StreamOnlyService_EchoBidirectionalNewClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectionalNew", nil, res) + if err != nil { + return nil, err + } + stream := &streamOnlyServiceEchoBidirectionalNewClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen/grpc_pb/api.pb.go b/thrift_streaming/kitex_gen/grpc_pb/api.pb.go index 73fd9b1..a46c9e4 100644 --- a/thrift_streaming/kitex_gen/grpc_pb/api.pb.go +++ b/thrift_streaming/kitex_gen/grpc_pb/api.pb.go @@ -15,7 +15,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.13.0 +// protoc v3.21.12 // source: idl/api.proto package grpc_pb diff --git a/thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.go b/thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.go index 9fcf6f5..12e1add 100644 --- a/thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.go +++ b/thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.go @@ -15,7 +15,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.13.0 +// protoc v3.21.12 // source: idl/api_no_stream.proto package kitex_pb diff --git a/thrift_streaming/kitex_gen_cross/echo/api.go b/thrift_streaming/kitex_gen_cross/echo/api.go index 0a1fd28..7bcbee0 100644 --- a/thrift_streaming/kitex_gen_cross/echo/api.go +++ b/thrift_streaming/kitex_gen_cross/echo/api.go @@ -581,7 +581,7 @@ func (p *EchoServiceClient) Ping(ctx context.Context) (err error) { } type PingPongOnlyService interface { - EchoPingPong(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) + EchoPingPongNew(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) } type PingPongOnlyServiceClient struct { @@ -610,16 +610,68 @@ func (p *PingPongOnlyServiceClient) Client_() thrift.TClient { return p.c } -func (p *PingPongOnlyServiceClient) EchoPingPong(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) { - var _args PingPongOnlyServiceEchoPingPongArgs +func (p *PingPongOnlyServiceClient) EchoPingPongNew(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) { + var _args PingPongOnlyServiceEchoPingPongNewArgs _args.Req1 = req1 - var _result PingPongOnlyServiceEchoPingPongResult - if err = p.Client_().Call(ctx, "EchoPingPong", &_args, &_result); err != nil { + var _result PingPongOnlyServiceEchoPingPongNewResult + if err = p.Client_().Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { return } return _result.GetSuccess(), nil } +type PingPongOnlyServiceChild interface { + PingPongOnlyService +} + +type PingPongOnlyServiceChildClient struct { + *PingPongOnlyServiceClient +} + +func NewPingPongOnlyServiceChildClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *PingPongOnlyServiceChildClient { + return &PingPongOnlyServiceChildClient{ + PingPongOnlyServiceClient: NewPingPongOnlyServiceClientFactory(t, f), + } +} + +func NewPingPongOnlyServiceChildClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *PingPongOnlyServiceChildClient { + return &PingPongOnlyServiceChildClient{ + PingPongOnlyServiceClient: NewPingPongOnlyServiceClientProtocol(t, iprot, oprot), + } +} + +func NewPingPongOnlyServiceChildClient(c thrift.TClient) *PingPongOnlyServiceChildClient { + return &PingPongOnlyServiceChildClient{ + PingPongOnlyServiceClient: NewPingPongOnlyServiceClient(c), + } +} + +type PingPongOnlyServiceChildChild interface { + PingPongOnlyServiceChild +} + +type PingPongOnlyServiceChildChildClient struct { + *PingPongOnlyServiceChildClient +} + +func NewPingPongOnlyServiceChildChildClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *PingPongOnlyServiceChildChildClient { + return &PingPongOnlyServiceChildChildClient{ + PingPongOnlyServiceChildClient: NewPingPongOnlyServiceChildClientFactory(t, f), + } +} + +func NewPingPongOnlyServiceChildChildClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *PingPongOnlyServiceChildChildClient { + return &PingPongOnlyServiceChildChildClient{ + PingPongOnlyServiceChildClient: NewPingPongOnlyServiceChildClientProtocol(t, iprot, oprot), + } +} + +func NewPingPongOnlyServiceChildChildClient(c thrift.TClient) *PingPongOnlyServiceChildChildClient { + return &PingPongOnlyServiceChildChildClient{ + PingPongOnlyServiceChildClient: NewPingPongOnlyServiceChildClient(c), + } +} + type StreamOnlyService interface { } @@ -649,6 +701,58 @@ func (p *StreamOnlyServiceClient) Client_() thrift.TClient { return p.c } +type StreamOnlyServiceChild interface { + StreamOnlyService +} + +type StreamOnlyServiceChildClient struct { + *StreamOnlyServiceClient +} + +func NewStreamOnlyServiceChildClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *StreamOnlyServiceChildClient { + return &StreamOnlyServiceChildClient{ + StreamOnlyServiceClient: NewStreamOnlyServiceClientFactory(t, f), + } +} + +func NewStreamOnlyServiceChildClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *StreamOnlyServiceChildClient { + return &StreamOnlyServiceChildClient{ + StreamOnlyServiceClient: NewStreamOnlyServiceClientProtocol(t, iprot, oprot), + } +} + +func NewStreamOnlyServiceChildClient(c thrift.TClient) *StreamOnlyServiceChildClient { + return &StreamOnlyServiceChildClient{ + StreamOnlyServiceClient: NewStreamOnlyServiceClient(c), + } +} + +type StreamOnlyServiceChildChild interface { + StreamOnlyServiceChild +} + +type StreamOnlyServiceChildChildClient struct { + *StreamOnlyServiceChildClient +} + +func NewStreamOnlyServiceChildChildClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *StreamOnlyServiceChildChildClient { + return &StreamOnlyServiceChildChildClient{ + StreamOnlyServiceChildClient: NewStreamOnlyServiceChildClientFactory(t, f), + } +} + +func NewStreamOnlyServiceChildChildClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *StreamOnlyServiceChildChildClient { + return &StreamOnlyServiceChildChildClient{ + StreamOnlyServiceChildClient: NewStreamOnlyServiceChildClientProtocol(t, iprot, oprot), + } +} + +func NewStreamOnlyServiceChildChildClient(c thrift.TClient) *StreamOnlyServiceChildChildClient { + return &StreamOnlyServiceChildChildClient{ + StreamOnlyServiceChildClient: NewStreamOnlyServiceChildClient(c), + } +} + type EchoServiceProcessor struct { processorMap map[string]thrift.TProcessorFunction handler EchoService @@ -1773,7 +1877,7 @@ func (p *PingPongOnlyServiceProcessor) ProcessorMap() map[string]thrift.TProcess func NewPingPongOnlyServiceProcessor(handler PingPongOnlyService) *PingPongOnlyServiceProcessor { self := &PingPongOnlyServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("EchoPingPong", &pingPongOnlyServiceProcessorEchoPingPong{handler: handler}) + self.AddToProcessorMap("EchoPingPongNew", &pingPongOnlyServiceProcessorEchoPingPongNew{handler: handler}) return self } func (p *PingPongOnlyServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { @@ -1794,16 +1898,16 @@ func (p *PingPongOnlyServiceProcessor) Process(ctx context.Context, iprot, oprot return false, x } -type pingPongOnlyServiceProcessorEchoPingPong struct { +type pingPongOnlyServiceProcessorEchoPingPongNew struct { handler PingPongOnlyService } -func (p *pingPongOnlyServiceProcessorEchoPingPong) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := PingPongOnlyServiceEchoPingPongArgs{} +func (p *pingPongOnlyServiceProcessorEchoPingPongNew) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := PingPongOnlyServiceEchoPingPongNewArgs{} if err = args.Read(iprot); err != nil { iprot.ReadMessageEnd() x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("EchoPingPong", thrift.EXCEPTION, seqId) + oprot.WriteMessageBegin("EchoPingPongNew", thrift.EXCEPTION, seqId) x.Write(oprot) oprot.WriteMessageEnd() oprot.Flush(ctx) @@ -1812,11 +1916,11 @@ func (p *pingPongOnlyServiceProcessorEchoPingPong) Process(ctx context.Context, iprot.ReadMessageEnd() var err2 error - result := PingPongOnlyServiceEchoPingPongResult{} + result := PingPongOnlyServiceEchoPingPongNewResult{} var retval *EchoResponse - if retval, err2 = p.handler.EchoPingPong(ctx, args.Req1); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoPingPong: "+err2.Error()) - oprot.WriteMessageBegin("EchoPingPong", thrift.EXCEPTION, seqId) + if retval, err2 = p.handler.EchoPingPongNew(ctx, args.Req1); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoPingPongNew: "+err2.Error()) + oprot.WriteMessageBegin("EchoPingPongNew", thrift.EXCEPTION, seqId) x.Write(oprot) oprot.WriteMessageEnd() oprot.Flush(ctx) @@ -1824,7 +1928,7 @@ func (p *pingPongOnlyServiceProcessorEchoPingPong) Process(ctx context.Context, } else { result.Success = retval } - if err2 = oprot.WriteMessageBegin("EchoPingPong", thrift.REPLY, seqId); err2 != nil { + if err2 = oprot.WriteMessageBegin("EchoPingPongNew", thrift.REPLY, seqId); err2 != nil { err = err2 } if err2 = result.Write(oprot); err == nil && err2 != nil { @@ -1842,39 +1946,39 @@ func (p *pingPongOnlyServiceProcessorEchoPingPong) Process(ctx context.Context, return true, err } -type PingPongOnlyServiceEchoPingPongArgs struct { +type PingPongOnlyServiceEchoPingPongNewArgs struct { Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` } -func NewPingPongOnlyServiceEchoPingPongArgs() *PingPongOnlyServiceEchoPingPongArgs { - return &PingPongOnlyServiceEchoPingPongArgs{} +func NewPingPongOnlyServiceEchoPingPongNewArgs() *PingPongOnlyServiceEchoPingPongNewArgs { + return &PingPongOnlyServiceEchoPingPongNewArgs{} } -func (p *PingPongOnlyServiceEchoPingPongArgs) InitDefault() { - *p = PingPongOnlyServiceEchoPingPongArgs{} +func (p *PingPongOnlyServiceEchoPingPongNewArgs) InitDefault() { + *p = PingPongOnlyServiceEchoPingPongNewArgs{} } -var PingPongOnlyServiceEchoPingPongArgs_Req1_DEFAULT *EchoRequest +var PingPongOnlyServiceEchoPingPongNewArgs_Req1_DEFAULT *EchoRequest -func (p *PingPongOnlyServiceEchoPingPongArgs) GetReq1() (v *EchoRequest) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) GetReq1() (v *EchoRequest) { if !p.IsSetReq1() { - return PingPongOnlyServiceEchoPingPongArgs_Req1_DEFAULT + return PingPongOnlyServiceEchoPingPongNewArgs_Req1_DEFAULT } return p.Req1 } -func (p *PingPongOnlyServiceEchoPingPongArgs) SetReq1(val *EchoRequest) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) SetReq1(val *EchoRequest) { p.Req1 = val } -var fieldIDToName_PingPongOnlyServiceEchoPingPongArgs = map[int16]string{ +var fieldIDToName_PingPongOnlyServiceEchoPingPongNewArgs = map[int16]string{ 1: "req1", } -func (p *PingPongOnlyServiceEchoPingPongArgs) IsSetReq1() bool { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) IsSetReq1() bool { return p.Req1 != nil } -func (p *PingPongOnlyServiceEchoPingPongArgs) Read(iprot thrift.TProtocol) (err error) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -1920,7 +2024,7 @@ ReadStructBeginError: ReadFieldBeginError: return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongArgs[fieldId]), err) + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongNewArgs[fieldId]), err) SkipFieldError: return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) @@ -1930,7 +2034,7 @@ ReadStructEndError: return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) ReadField1(iprot thrift.TProtocol) error { p.Req1 = NewEchoRequest() if err := p.Req1.Read(iprot); err != nil { return err @@ -1938,9 +2042,9 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) ReadField1(iprot thrift.TProtocol) return nil } -func (p *PingPongOnlyServiceEchoPingPongArgs) Write(oprot thrift.TProtocol) (err error) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 - if err = oprot.WriteStructBegin("EchoPingPong_args"); err != nil { + if err = oprot.WriteStructBegin("EchoPingPongNew_args"); err != nil { goto WriteStructBeginError } if p != nil { @@ -1966,7 +2070,7 @@ WriteStructEndError: return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongArgs) writeField1(oprot thrift.TProtocol) (err error) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) writeField1(oprot thrift.TProtocol) (err error) { if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { goto WriteFieldBeginError } @@ -1983,15 +2087,15 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongArgs) String() string { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) String() string { if p == nil { return "" } - return fmt.Sprintf("PingPongOnlyServiceEchoPingPongArgs(%+v)", *p) + return fmt.Sprintf("PingPongOnlyServiceEchoPingPongNewArgs(%+v)", *p) } -func (p *PingPongOnlyServiceEchoPingPongArgs) DeepEqual(ano *PingPongOnlyServiceEchoPingPongArgs) bool { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) DeepEqual(ano *PingPongOnlyServiceEchoPingPongNewArgs) bool { if p == ano { return true } else if p == nil || ano == nil { @@ -2003,7 +2107,7 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) DeepEqual(ano *PingPongOnlyService return true } -func (p *PingPongOnlyServiceEchoPingPongArgs) Field1DeepEqual(src *EchoRequest) bool { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) Field1DeepEqual(src *EchoRequest) bool { if !p.Req1.DeepEqual(src) { return false @@ -2011,39 +2115,39 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) Field1DeepEqual(src *EchoRequest) return true } -type PingPongOnlyServiceEchoPingPongResult struct { +type PingPongOnlyServiceEchoPingPongNewResult struct { Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` } -func NewPingPongOnlyServiceEchoPingPongResult() *PingPongOnlyServiceEchoPingPongResult { - return &PingPongOnlyServiceEchoPingPongResult{} +func NewPingPongOnlyServiceEchoPingPongNewResult() *PingPongOnlyServiceEchoPingPongNewResult { + return &PingPongOnlyServiceEchoPingPongNewResult{} } -func (p *PingPongOnlyServiceEchoPingPongResult) InitDefault() { - *p = PingPongOnlyServiceEchoPingPongResult{} +func (p *PingPongOnlyServiceEchoPingPongNewResult) InitDefault() { + *p = PingPongOnlyServiceEchoPingPongNewResult{} } -var PingPongOnlyServiceEchoPingPongResult_Success_DEFAULT *EchoResponse +var PingPongOnlyServiceEchoPingPongNewResult_Success_DEFAULT *EchoResponse -func (p *PingPongOnlyServiceEchoPingPongResult) GetSuccess() (v *EchoResponse) { +func (p *PingPongOnlyServiceEchoPingPongNewResult) GetSuccess() (v *EchoResponse) { if !p.IsSetSuccess() { - return PingPongOnlyServiceEchoPingPongResult_Success_DEFAULT + return PingPongOnlyServiceEchoPingPongNewResult_Success_DEFAULT } return p.Success } -func (p *PingPongOnlyServiceEchoPingPongResult) SetSuccess(x interface{}) { +func (p *PingPongOnlyServiceEchoPingPongNewResult) SetSuccess(x interface{}) { p.Success = x.(*EchoResponse) } -var fieldIDToName_PingPongOnlyServiceEchoPingPongResult = map[int16]string{ +var fieldIDToName_PingPongOnlyServiceEchoPingPongNewResult = map[int16]string{ 0: "success", } -func (p *PingPongOnlyServiceEchoPingPongResult) IsSetSuccess() bool { +func (p *PingPongOnlyServiceEchoPingPongNewResult) IsSetSuccess() bool { return p.Success != nil } -func (p *PingPongOnlyServiceEchoPingPongResult) Read(iprot thrift.TProtocol) (err error) { +func (p *PingPongOnlyServiceEchoPingPongNewResult) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -2089,7 +2193,7 @@ ReadStructBeginError: ReadFieldBeginError: return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongResult[fieldId]), err) + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongNewResult[fieldId]), err) SkipFieldError: return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) @@ -2099,7 +2203,7 @@ ReadStructEndError: return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongResult) ReadField0(iprot thrift.TProtocol) error { +func (p *PingPongOnlyServiceEchoPingPongNewResult) ReadField0(iprot thrift.TProtocol) error { p.Success = NewEchoResponse() if err := p.Success.Read(iprot); err != nil { return err @@ -2107,9 +2211,9 @@ func (p *PingPongOnlyServiceEchoPingPongResult) ReadField0(iprot thrift.TProtoco return nil } -func (p *PingPongOnlyServiceEchoPingPongResult) Write(oprot thrift.TProtocol) (err error) { +func (p *PingPongOnlyServiceEchoPingPongNewResult) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 - if err = oprot.WriteStructBegin("EchoPingPong_result"); err != nil { + if err = oprot.WriteStructBegin("EchoPingPongNew_result"); err != nil { goto WriteStructBeginError } if p != nil { @@ -2135,7 +2239,7 @@ WriteStructEndError: return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *PingPongOnlyServiceEchoPingPongNewResult) writeField0(oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { goto WriteFieldBeginError @@ -2154,15 +2258,15 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongResult) String() string { +func (p *PingPongOnlyServiceEchoPingPongNewResult) String() string { if p == nil { return "" } - return fmt.Sprintf("PingPongOnlyServiceEchoPingPongResult(%+v)", *p) + return fmt.Sprintf("PingPongOnlyServiceEchoPingPongNewResult(%+v)", *p) } -func (p *PingPongOnlyServiceEchoPingPongResult) DeepEqual(ano *PingPongOnlyServiceEchoPingPongResult) bool { +func (p *PingPongOnlyServiceEchoPingPongNewResult) DeepEqual(ano *PingPongOnlyServiceEchoPingPongNewResult) bool { if p == ano { return true } else if p == nil || ano == nil { @@ -2174,7 +2278,7 @@ func (p *PingPongOnlyServiceEchoPingPongResult) DeepEqual(ano *PingPongOnlyServi return true } -func (p *PingPongOnlyServiceEchoPingPongResult) Field0DeepEqual(src *EchoResponse) bool { +func (p *PingPongOnlyServiceEchoPingPongNewResult) Field0DeepEqual(src *EchoResponse) bool { if !p.Success.DeepEqual(src) { return false @@ -2182,6 +2286,24 @@ func (p *PingPongOnlyServiceEchoPingPongResult) Field0DeepEqual(src *EchoRespons return true } +type PingPongOnlyServiceChildProcessor struct { + *PingPongOnlyServiceProcessor +} + +func NewPingPongOnlyServiceChildProcessor(handler PingPongOnlyServiceChild) *PingPongOnlyServiceChildProcessor { + self := &PingPongOnlyServiceChildProcessor{NewPingPongOnlyServiceProcessor(handler)} + return self +} + +type PingPongOnlyServiceChildChildProcessor struct { + *PingPongOnlyServiceChildProcessor +} + +func NewPingPongOnlyServiceChildChildProcessor(handler PingPongOnlyServiceChildChild) *PingPongOnlyServiceChildChildProcessor { + self := &PingPongOnlyServiceChildChildProcessor{NewPingPongOnlyServiceChildProcessor(handler)} + return self +} + type StreamOnlyServiceProcessor struct { processorMap map[string]thrift.TProcessorFunction handler StreamOnlyService @@ -2221,3 +2343,21 @@ func (p *StreamOnlyServiceProcessor) Process(ctx context.Context, iprot, oprot t oprot.Flush(ctx) return false, x } + +type StreamOnlyServiceChildProcessor struct { + *StreamOnlyServiceProcessor +} + +func NewStreamOnlyServiceChildProcessor(handler StreamOnlyServiceChild) *StreamOnlyServiceChildProcessor { + self := &StreamOnlyServiceChildProcessor{NewStreamOnlyServiceProcessor(handler)} + return self +} + +type StreamOnlyServiceChildChildProcessor struct { + *StreamOnlyServiceChildProcessor +} + +func NewStreamOnlyServiceChildChildProcessor(handler StreamOnlyServiceChildChild) *StreamOnlyServiceChildChildProcessor { + self := &StreamOnlyServiceChildChildProcessor{NewStreamOnlyServiceChildProcessor(handler)} + return self +} diff --git a/thrift_streaming/kitex_gen_cross/echo/k-api.go b/thrift_streaming/kitex_gen_cross/echo/k-api.go index 91facb6..fe4400c 100644 --- a/thrift_streaming/kitex_gen_cross/echo/k-api.go +++ b/thrift_streaming/kitex_gen_cross/echo/k-api.go @@ -1139,7 +1139,7 @@ func (p *EchoServicePingResult) BLength() int { return l } -func (p *PingPongOnlyServiceEchoPingPongArgs) FastRead(buf []byte) (int, error) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) FastRead(buf []byte) (int, error) { var err error var offset int var l int @@ -1201,7 +1201,7 @@ ReadStructBeginError: ReadFieldBeginError: return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongArgs[fieldId]), err) + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongNewArgs[fieldId]), err) SkipFieldError: return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) ReadFieldEndError: @@ -1210,7 +1210,7 @@ ReadStructEndError: return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongArgs) FastReadField1(buf []byte) (int, error) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) FastReadField1(buf []byte) (int, error) { offset := 0 tmp := NewEchoRequest() @@ -1224,13 +1224,13 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) FastReadField1(buf []byte) (int, e } // for compatibility -func (p *PingPongOnlyServiceEchoPingPongArgs) FastWrite(buf []byte) int { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) FastWrite(buf []byte) int { return 0 } -func (p *PingPongOnlyServiceEchoPingPongArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPong_args") + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPongNew_args") if p != nil { offset += p.fastWriteField1(buf[offset:], binaryWriter) } @@ -1239,9 +1239,9 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) FastWriteNocopy(buf []byte, binary return offset } -func (p *PingPongOnlyServiceEchoPingPongArgs) BLength() int { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("EchoPingPong_args") + l += bthrift.Binary.StructBeginLength("EchoPingPongNew_args") if p != nil { l += p.field1Length() } @@ -1250,7 +1250,7 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) BLength() int { return l } -func (p *PingPongOnlyServiceEchoPingPongArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { offset := 0 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) @@ -1258,7 +1258,7 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) fastWriteField1(buf []byte, binary return offset } -func (p *PingPongOnlyServiceEchoPingPongArgs) field1Length() int { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) field1Length() int { l := 0 l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) l += p.Req1.BLength() @@ -1266,7 +1266,7 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) field1Length() int { return l } -func (p *PingPongOnlyServiceEchoPingPongResult) FastRead(buf []byte) (int, error) { +func (p *PingPongOnlyServiceEchoPingPongNewResult) FastRead(buf []byte) (int, error) { var err error var offset int var l int @@ -1328,7 +1328,7 @@ ReadStructBeginError: ReadFieldBeginError: return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongResult[fieldId]), err) + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongNewResult[fieldId]), err) SkipFieldError: return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) ReadFieldEndError: @@ -1337,7 +1337,7 @@ ReadStructEndError: return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongResult) FastReadField0(buf []byte) (int, error) { +func (p *PingPongOnlyServiceEchoPingPongNewResult) FastReadField0(buf []byte) (int, error) { offset := 0 tmp := NewEchoResponse() @@ -1351,13 +1351,13 @@ func (p *PingPongOnlyServiceEchoPingPongResult) FastReadField0(buf []byte) (int, } // for compatibility -func (p *PingPongOnlyServiceEchoPingPongResult) FastWrite(buf []byte) int { +func (p *PingPongOnlyServiceEchoPingPongNewResult) FastWrite(buf []byte) int { return 0 } -func (p *PingPongOnlyServiceEchoPingPongResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PingPongOnlyServiceEchoPingPongNewResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPong_result") + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPongNew_result") if p != nil { offset += p.fastWriteField0(buf[offset:], binaryWriter) } @@ -1366,9 +1366,9 @@ func (p *PingPongOnlyServiceEchoPingPongResult) FastWriteNocopy(buf []byte, bina return offset } -func (p *PingPongOnlyServiceEchoPingPongResult) BLength() int { +func (p *PingPongOnlyServiceEchoPingPongNewResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("EchoPingPong_result") + l += bthrift.Binary.StructBeginLength("EchoPingPongNew_result") if p != nil { l += p.field0Length() } @@ -1377,7 +1377,7 @@ func (p *PingPongOnlyServiceEchoPingPongResult) BLength() int { return l } -func (p *PingPongOnlyServiceEchoPingPongResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PingPongOnlyServiceEchoPingPongNewResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { offset := 0 if p.IsSetSuccess() { offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) @@ -1387,7 +1387,7 @@ func (p *PingPongOnlyServiceEchoPingPongResult) fastWriteField0(buf []byte, bina return offset } -func (p *PingPongOnlyServiceEchoPingPongResult) field0Length() int { +func (p *PingPongOnlyServiceEchoPingPongNewResult) field0Length() int { l := 0 if p.IsSetSuccess() { l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) @@ -1421,10 +1421,10 @@ func (p *EchoServicePingResult) GetResult() interface{} { return nil } -func (p *PingPongOnlyServiceEchoPingPongArgs) GetFirstArgument() interface{} { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) GetFirstArgument() interface{} { return p.Req1 } -func (p *PingPongOnlyServiceEchoPingPongResult) GetResult() interface{} { +func (p *PingPongOnlyServiceEchoPingPongNewResult) GetResult() interface{} { return p.Success } diff --git a/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/client.go b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/client.go index 5dcb3ca..f187bd7 100644 --- a/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/client.go +++ b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/client.go @@ -11,7 +11,7 @@ import ( // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. type Client interface { - EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) + EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) } // NewClient creates a client for the service defined in IDL. @@ -43,7 +43,7 @@ type kPingPongOnlyServiceClient struct { *kClient } -func (p *kPingPongOnlyServiceClient) EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { +func (p *kPingPongOnlyServiceClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.EchoPingPong(ctx, req1) + return p.kClient.EchoPingPongNew(ctx, req1) } diff --git a/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/pingpongonlyservice.go b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/pingpongonlyservice.go index 6f2f57b..4769b01 100644 --- a/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/pingpongonlyservice.go +++ b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservice/pingpongonlyservice.go @@ -19,7 +19,7 @@ func NewServiceInfo() *kitex.ServiceInfo { serviceName := "PingPongOnlyService" handlerType := (*echo.PingPongOnlyService)(nil) methods := map[string]kitex.MethodInfo{ - "EchoPingPong": kitex.NewMethodInfo(echoPingPongHandler, newPingPongOnlyServiceEchoPingPongArgs, newPingPongOnlyServiceEchoPingPongResult, false), + "EchoPingPongNew": kitex.NewMethodInfo(echoPingPongNewHandler, newPingPongOnlyServiceEchoPingPongNewArgs, newPingPongOnlyServiceEchoPingPongNewResult, false), } extra := map[string]interface{}{ "PackageName": "echo", @@ -36,22 +36,22 @@ func NewServiceInfo() *kitex.ServiceInfo { return svcInfo } -func echoPingPongHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongArgs) - realResult := result.(*echo.PingPongOnlyServiceEchoPingPongResult) - success, err := handler.(echo.PingPongOnlyService).EchoPingPong(ctx, realArg.Req1) +func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) if err != nil { return err } realResult.Success = success return nil } -func newPingPongOnlyServiceEchoPingPongArgs() interface{} { - return echo.NewPingPongOnlyServiceEchoPingPongArgs() +func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() } -func newPingPongOnlyServiceEchoPingPongResult() interface{} { - return echo.NewPingPongOnlyServiceEchoPingPongResult() +func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewResult() } type kClient struct { @@ -64,11 +64,11 @@ func newServiceClient(c client.Client) *kClient { } } -func (p *kClient) EchoPingPong(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { - var _args echo.PingPongOnlyServiceEchoPingPongArgs +func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongNewArgs _args.Req1 = req1 - var _result echo.PingPongOnlyServiceEchoPingPongResult - if err = p.c.Call(ctx, "EchoPingPong", &_args, &_result); err != nil { + var _result echo.PingPongOnlyServiceEchoPingPongNewResult + if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { return } return _result.GetSuccess(), nil diff --git a/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechild/client.go b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechild/client.go new file mode 100644 index 0000000..721d47a --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechild/client.go @@ -0,0 +1,49 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfo(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceChildClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceChildClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceChildClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPongNew(ctx, req1) +} diff --git a/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechild/invoker.go b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechild/invoker.go new file mode 100644 index 0000000..bbe277b --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechild/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.PingPongOnlyServiceChild, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechild/pingpongonlyservicechild.go b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechild/pingpongonlyservicechild.go new file mode 100644 index 0000000..cfb170a --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechild/pingpongonlyservicechild.go @@ -0,0 +1,75 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +func serviceInfo() *kitex.ServiceInfo { + return pingPongOnlyServiceChildServiceInfo +} + +var pingPongOnlyServiceChildServiceInfo = NewServiceInfo() + +func NewServiceInfo() *kitex.ServiceInfo { + serviceName := "PingPongOnlyServiceChild" + handlerType := (*echo.PingPongOnlyServiceChild)(nil) + methods := map[string]kitex.MethodInfo{ + "EchoPingPongNew": kitex.NewMethodInfo(echoPingPongNewHandler, newPingPongOnlyServiceEchoPingPongNewArgs, newPingPongOnlyServiceEchoPingPongNewResult, false), + } + extra := map[string]interface{}{ + "PackageName": "echo", + "ServiceFilePath": `idl/api.thrift`, + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() +} + +func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongNewArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceEchoPingPongNewResult + if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechild/server.go b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechild/server.go new file mode 100644 index 0000000..9b505e1 --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechild/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package pingpongonlyservicechild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.PingPongOnlyServiceChild, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechildchild/client.go b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechildchild/client.go new file mode 100644 index 0000000..631ee63 --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechildchild/client.go @@ -0,0 +1,49 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechildchild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfo(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceChildChildClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceChildChildClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceChildChildClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPongNew(ctx, req1) +} diff --git a/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechildchild/invoker.go b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechildchild/invoker.go new file mode 100644 index 0000000..382568b --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechildchild/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechildchild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.PingPongOnlyServiceChildChild, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go new file mode 100644 index 0000000..49f22c9 --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go @@ -0,0 +1,75 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechildchild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +func serviceInfo() *kitex.ServiceInfo { + return pingPongOnlyServiceChildChildServiceInfo +} + +var pingPongOnlyServiceChildChildServiceInfo = NewServiceInfo() + +func NewServiceInfo() *kitex.ServiceInfo { + serviceName := "PingPongOnlyServiceChildChild" + handlerType := (*echo.PingPongOnlyServiceChildChild)(nil) + methods := map[string]kitex.MethodInfo{ + "EchoPingPongNew": kitex.NewMethodInfo(echoPingPongNewHandler, newPingPongOnlyServiceEchoPingPongNewArgs, newPingPongOnlyServiceEchoPingPongNewResult, false), + } + extra := map[string]interface{}{ + "PackageName": "echo", + "ServiceFilePath": `idl/api.thrift`, + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() +} + +func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongNewArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceEchoPingPongNewResult + if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechildchild/server.go b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechildchild/server.go new file mode 100644 index 0000000..a4e4743 --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/pingpongonlyservicechildchild/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package pingpongonlyservicechildchild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.PingPongOnlyServiceChildChild, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechild/client.go b/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechild/client.go new file mode 100644 index 0000000..e1a8e61 --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechild/client.go @@ -0,0 +1,40 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechild + +import ( + client "github.com/cloudwego/kitex/client" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfo(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceChildClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceChildClient struct { + *kClient +} diff --git a/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechild/invoker.go b/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechild/invoker.go new file mode 100644 index 0000000..e41e3fb --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechild/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.StreamOnlyServiceChild, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechild/server.go b/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechild/server.go new file mode 100644 index 0000000..1e4debe --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechild/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package streamonlyservicechild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.StreamOnlyServiceChild, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechild/streamonlyservicechild.go b/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechild/streamonlyservicechild.go new file mode 100644 index 0000000..99e7394 --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechild/streamonlyservicechild.go @@ -0,0 +1,44 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +func serviceInfo() *kitex.ServiceInfo { + return streamOnlyServiceChildServiceInfo +} + +var streamOnlyServiceChildServiceInfo = NewServiceInfo() + +func NewServiceInfo() *kitex.ServiceInfo { + serviceName := "StreamOnlyServiceChild" + handlerType := (*echo.StreamOnlyServiceChild)(nil) + methods := map[string]kitex.MethodInfo{} + extra := map[string]interface{}{ + "PackageName": "echo", + "ServiceFilePath": `idl/api.thrift`, + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} diff --git a/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechildchild/client.go b/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechildchild/client.go new file mode 100644 index 0000000..3ecb584 --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechildchild/client.go @@ -0,0 +1,40 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechildchild + +import ( + client "github.com/cloudwego/kitex/client" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfo(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceChildChildClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceChildChildClient struct { + *kClient +} diff --git a/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechildchild/invoker.go b/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechildchild/invoker.go new file mode 100644 index 0000000..f9f96d2 --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechildchild/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechildchild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.StreamOnlyServiceChildChild, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechildchild/server.go b/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechildchild/server.go new file mode 100644 index 0000000..7b33493 --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechildchild/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package streamonlyservicechildchild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.StreamOnlyServiceChildChild, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechildchild/streamonlyservicechildchild.go b/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechildchild/streamonlyservicechildchild.go new file mode 100644 index 0000000..b2db695 --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/streamonlyservicechildchild/streamonlyservicechildchild.go @@ -0,0 +1,44 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechildchild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +func serviceInfo() *kitex.ServiceInfo { + return streamOnlyServiceChildChildServiceInfo +} + +var streamOnlyServiceChildChildServiceInfo = NewServiceInfo() + +func NewServiceInfo() *kitex.ServiceInfo { + serviceName := "StreamOnlyServiceChildChild" + handlerType := (*echo.StreamOnlyServiceChildChild)(nil) + methods := map[string]kitex.MethodInfo{} + extra := map[string]interface{}{ + "PackageName": "echo", + "ServiceFilePath": `idl/api.thrift`, + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} diff --git a/thrift_streaming/kitex_gen_old/echo/api.go b/thrift_streaming/kitex_gen_old/echo/api.go index 62dba46..a767632 100644 --- a/thrift_streaming/kitex_gen_old/echo/api.go +++ b/thrift_streaming/kitex_gen_old/echo/api.go @@ -625,7 +625,7 @@ func (p *EchoServiceClient) Ping(ctx context.Context) (err error) { } type PingPongOnlyService interface { - EchoPingPong(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) + EchoPingPongNew(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) } type PingPongOnlyServiceClient struct { @@ -654,18 +654,82 @@ func (p *PingPongOnlyServiceClient) Client_() thrift.TClient { return p.c } -func (p *PingPongOnlyServiceClient) EchoPingPong(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) { - var _args PingPongOnlyServiceEchoPingPongArgs +func (p *PingPongOnlyServiceClient) EchoPingPongNew(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) { + var _args PingPongOnlyServiceEchoPingPongNewArgs _args.Req1 = req1 - var _result PingPongOnlyServiceEchoPingPongResult - if err = p.Client_().Call(ctx, "EchoPingPong", &_args, &_result); err != nil { + var _result PingPongOnlyServiceEchoPingPongNewResult + if err = p.Client_().Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { return } return _result.GetSuccess(), nil } +type PingPongOnlyServiceChild interface { + PingPongOnlyService + + EchoBidirectionalExtended(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) +} + +type PingPongOnlyServiceChildClient struct { + *PingPongOnlyServiceClient +} + +func NewPingPongOnlyServiceChildClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *PingPongOnlyServiceChildClient { + return &PingPongOnlyServiceChildClient{ + PingPongOnlyServiceClient: NewPingPongOnlyServiceClientFactory(t, f), + } +} + +func NewPingPongOnlyServiceChildClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *PingPongOnlyServiceChildClient { + return &PingPongOnlyServiceChildClient{ + PingPongOnlyServiceClient: NewPingPongOnlyServiceClientProtocol(t, iprot, oprot), + } +} + +func NewPingPongOnlyServiceChildClient(c thrift.TClient) *PingPongOnlyServiceChildClient { + return &PingPongOnlyServiceChildClient{ + PingPongOnlyServiceClient: NewPingPongOnlyServiceClient(c), + } +} + +func (p *PingPongOnlyServiceChildClient) EchoBidirectionalExtended(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) { + var _args PingPongOnlyServiceChildEchoBidirectionalExtendedArgs + _args.Req1 = req1 + var _result PingPongOnlyServiceChildEchoBidirectionalExtendedResult + if err = p.Client_().Call(ctx, "EchoBidirectionalExtended", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +type PingPongOnlyServiceChildChild interface { + PingPongOnlyServiceChild +} + +type PingPongOnlyServiceChildChildClient struct { + *PingPongOnlyServiceChildClient +} + +func NewPingPongOnlyServiceChildChildClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *PingPongOnlyServiceChildChildClient { + return &PingPongOnlyServiceChildChildClient{ + PingPongOnlyServiceChildClient: NewPingPongOnlyServiceChildClientFactory(t, f), + } +} + +func NewPingPongOnlyServiceChildChildClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *PingPongOnlyServiceChildChildClient { + return &PingPongOnlyServiceChildChildClient{ + PingPongOnlyServiceChildClient: NewPingPongOnlyServiceChildClientProtocol(t, iprot, oprot), + } +} + +func NewPingPongOnlyServiceChildChildClient(c thrift.TClient) *PingPongOnlyServiceChildChildClient { + return &PingPongOnlyServiceChildChildClient{ + PingPongOnlyServiceChildClient: NewPingPongOnlyServiceChildClient(c), + } +} + type StreamOnlyService interface { - EchoBidirectional(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) + EchoBidirectionalNew(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) } type StreamOnlyServiceClient struct { @@ -694,16 +758,68 @@ func (p *StreamOnlyServiceClient) Client_() thrift.TClient { return p.c } -func (p *StreamOnlyServiceClient) EchoBidirectional(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) { - var _args StreamOnlyServiceEchoBidirectionalArgs +func (p *StreamOnlyServiceClient) EchoBidirectionalNew(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) { + var _args StreamOnlyServiceEchoBidirectionalNewArgs _args.Req1 = req1 - var _result StreamOnlyServiceEchoBidirectionalResult - if err = p.Client_().Call(ctx, "EchoBidirectional", &_args, &_result); err != nil { + var _result StreamOnlyServiceEchoBidirectionalNewResult + if err = p.Client_().Call(ctx, "EchoBidirectionalNew", &_args, &_result); err != nil { return } return _result.GetSuccess(), nil } +type StreamOnlyServiceChild interface { + StreamOnlyService +} + +type StreamOnlyServiceChildClient struct { + *StreamOnlyServiceClient +} + +func NewStreamOnlyServiceChildClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *StreamOnlyServiceChildClient { + return &StreamOnlyServiceChildClient{ + StreamOnlyServiceClient: NewStreamOnlyServiceClientFactory(t, f), + } +} + +func NewStreamOnlyServiceChildClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *StreamOnlyServiceChildClient { + return &StreamOnlyServiceChildClient{ + StreamOnlyServiceClient: NewStreamOnlyServiceClientProtocol(t, iprot, oprot), + } +} + +func NewStreamOnlyServiceChildClient(c thrift.TClient) *StreamOnlyServiceChildClient { + return &StreamOnlyServiceChildClient{ + StreamOnlyServiceClient: NewStreamOnlyServiceClient(c), + } +} + +type StreamOnlyServiceChildChild interface { + StreamOnlyServiceChild +} + +type StreamOnlyServiceChildChildClient struct { + *StreamOnlyServiceChildClient +} + +func NewStreamOnlyServiceChildChildClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *StreamOnlyServiceChildChildClient { + return &StreamOnlyServiceChildChildClient{ + StreamOnlyServiceChildClient: NewStreamOnlyServiceChildClientFactory(t, f), + } +} + +func NewStreamOnlyServiceChildChildClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *StreamOnlyServiceChildChildClient { + return &StreamOnlyServiceChildChildClient{ + StreamOnlyServiceChildClient: NewStreamOnlyServiceChildClientProtocol(t, iprot, oprot), + } +} + +func NewStreamOnlyServiceChildChildClient(c thrift.TClient) *StreamOnlyServiceChildChildClient { + return &StreamOnlyServiceChildChildClient{ + StreamOnlyServiceChildClient: NewStreamOnlyServiceChildClient(c), + } +} + type EchoServiceProcessor struct { processorMap map[string]thrift.TProcessorFunction handler EchoService @@ -3384,7 +3500,7 @@ func (p *PingPongOnlyServiceProcessor) ProcessorMap() map[string]thrift.TProcess func NewPingPongOnlyServiceProcessor(handler PingPongOnlyService) *PingPongOnlyServiceProcessor { self := &PingPongOnlyServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("EchoPingPong", &pingPongOnlyServiceProcessorEchoPingPong{handler: handler}) + self.AddToProcessorMap("EchoPingPongNew", &pingPongOnlyServiceProcessorEchoPingPongNew{handler: handler}) return self } func (p *PingPongOnlyServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { @@ -3405,16 +3521,16 @@ func (p *PingPongOnlyServiceProcessor) Process(ctx context.Context, iprot, oprot return false, x } -type pingPongOnlyServiceProcessorEchoPingPong struct { +type pingPongOnlyServiceProcessorEchoPingPongNew struct { handler PingPongOnlyService } -func (p *pingPongOnlyServiceProcessorEchoPingPong) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := PingPongOnlyServiceEchoPingPongArgs{} +func (p *pingPongOnlyServiceProcessorEchoPingPongNew) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := PingPongOnlyServiceEchoPingPongNewArgs{} if err = args.Read(iprot); err != nil { iprot.ReadMessageEnd() x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("EchoPingPong", thrift.EXCEPTION, seqId) + oprot.WriteMessageBegin("EchoPingPongNew", thrift.EXCEPTION, seqId) x.Write(oprot) oprot.WriteMessageEnd() oprot.Flush(ctx) @@ -3423,11 +3539,11 @@ func (p *pingPongOnlyServiceProcessorEchoPingPong) Process(ctx context.Context, iprot.ReadMessageEnd() var err2 error - result := PingPongOnlyServiceEchoPingPongResult{} + result := PingPongOnlyServiceEchoPingPongNewResult{} var retval *EchoResponse - if retval, err2 = p.handler.EchoPingPong(ctx, args.Req1); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoPingPong: "+err2.Error()) - oprot.WriteMessageBegin("EchoPingPong", thrift.EXCEPTION, seqId) + if retval, err2 = p.handler.EchoPingPongNew(ctx, args.Req1); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoPingPongNew: "+err2.Error()) + oprot.WriteMessageBegin("EchoPingPongNew", thrift.EXCEPTION, seqId) x.Write(oprot) oprot.WriteMessageEnd() oprot.Flush(ctx) @@ -3435,7 +3551,7 @@ func (p *pingPongOnlyServiceProcessorEchoPingPong) Process(ctx context.Context, } else { result.Success = retval } - if err2 = oprot.WriteMessageBegin("EchoPingPong", thrift.REPLY, seqId); err2 != nil { + if err2 = oprot.WriteMessageBegin("EchoPingPongNew", thrift.REPLY, seqId); err2 != nil { err = err2 } if err2 = result.Write(oprot); err == nil && err2 != nil { @@ -3453,39 +3569,39 @@ func (p *pingPongOnlyServiceProcessorEchoPingPong) Process(ctx context.Context, return true, err } -type PingPongOnlyServiceEchoPingPongArgs struct { +type PingPongOnlyServiceEchoPingPongNewArgs struct { Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` } -func NewPingPongOnlyServiceEchoPingPongArgs() *PingPongOnlyServiceEchoPingPongArgs { - return &PingPongOnlyServiceEchoPingPongArgs{} +func NewPingPongOnlyServiceEchoPingPongNewArgs() *PingPongOnlyServiceEchoPingPongNewArgs { + return &PingPongOnlyServiceEchoPingPongNewArgs{} } -func (p *PingPongOnlyServiceEchoPingPongArgs) InitDefault() { - *p = PingPongOnlyServiceEchoPingPongArgs{} +func (p *PingPongOnlyServiceEchoPingPongNewArgs) InitDefault() { + *p = PingPongOnlyServiceEchoPingPongNewArgs{} } -var PingPongOnlyServiceEchoPingPongArgs_Req1_DEFAULT *EchoRequest +var PingPongOnlyServiceEchoPingPongNewArgs_Req1_DEFAULT *EchoRequest -func (p *PingPongOnlyServiceEchoPingPongArgs) GetReq1() (v *EchoRequest) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) GetReq1() (v *EchoRequest) { if !p.IsSetReq1() { - return PingPongOnlyServiceEchoPingPongArgs_Req1_DEFAULT + return PingPongOnlyServiceEchoPingPongNewArgs_Req1_DEFAULT } return p.Req1 } -func (p *PingPongOnlyServiceEchoPingPongArgs) SetReq1(val *EchoRequest) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) SetReq1(val *EchoRequest) { p.Req1 = val } -var fieldIDToName_PingPongOnlyServiceEchoPingPongArgs = map[int16]string{ +var fieldIDToName_PingPongOnlyServiceEchoPingPongNewArgs = map[int16]string{ 1: "req1", } -func (p *PingPongOnlyServiceEchoPingPongArgs) IsSetReq1() bool { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) IsSetReq1() bool { return p.Req1 != nil } -func (p *PingPongOnlyServiceEchoPingPongArgs) Read(iprot thrift.TProtocol) (err error) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -3531,7 +3647,7 @@ ReadStructBeginError: ReadFieldBeginError: return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongArgs[fieldId]), err) + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongNewArgs[fieldId]), err) SkipFieldError: return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) @@ -3541,7 +3657,7 @@ ReadStructEndError: return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) ReadField1(iprot thrift.TProtocol) error { p.Req1 = NewEchoRequest() if err := p.Req1.Read(iprot); err != nil { return err @@ -3549,9 +3665,9 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) ReadField1(iprot thrift.TProtocol) return nil } -func (p *PingPongOnlyServiceEchoPingPongArgs) Write(oprot thrift.TProtocol) (err error) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 - if err = oprot.WriteStructBegin("EchoPingPong_args"); err != nil { + if err = oprot.WriteStructBegin("EchoPingPongNew_args"); err != nil { goto WriteStructBeginError } if p != nil { @@ -3577,7 +3693,7 @@ WriteStructEndError: return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongArgs) writeField1(oprot thrift.TProtocol) (err error) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) writeField1(oprot thrift.TProtocol) (err error) { if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { goto WriteFieldBeginError } @@ -3594,15 +3710,15 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongArgs) String() string { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) String() string { if p == nil { return "" } - return fmt.Sprintf("PingPongOnlyServiceEchoPingPongArgs(%+v)", *p) + return fmt.Sprintf("PingPongOnlyServiceEchoPingPongNewArgs(%+v)", *p) } -func (p *PingPongOnlyServiceEchoPingPongArgs) DeepEqual(ano *PingPongOnlyServiceEchoPingPongArgs) bool { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) DeepEqual(ano *PingPongOnlyServiceEchoPingPongNewArgs) bool { if p == ano { return true } else if p == nil || ano == nil { @@ -3614,7 +3730,7 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) DeepEqual(ano *PingPongOnlyService return true } -func (p *PingPongOnlyServiceEchoPingPongArgs) Field1DeepEqual(src *EchoRequest) bool { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) Field1DeepEqual(src *EchoRequest) bool { if !p.Req1.DeepEqual(src) { return false @@ -3622,39 +3738,39 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) Field1DeepEqual(src *EchoRequest) return true } -type PingPongOnlyServiceEchoPingPongResult struct { +type PingPongOnlyServiceEchoPingPongNewResult struct { Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` } -func NewPingPongOnlyServiceEchoPingPongResult() *PingPongOnlyServiceEchoPingPongResult { - return &PingPongOnlyServiceEchoPingPongResult{} +func NewPingPongOnlyServiceEchoPingPongNewResult() *PingPongOnlyServiceEchoPingPongNewResult { + return &PingPongOnlyServiceEchoPingPongNewResult{} } -func (p *PingPongOnlyServiceEchoPingPongResult) InitDefault() { - *p = PingPongOnlyServiceEchoPingPongResult{} +func (p *PingPongOnlyServiceEchoPingPongNewResult) InitDefault() { + *p = PingPongOnlyServiceEchoPingPongNewResult{} } -var PingPongOnlyServiceEchoPingPongResult_Success_DEFAULT *EchoResponse +var PingPongOnlyServiceEchoPingPongNewResult_Success_DEFAULT *EchoResponse -func (p *PingPongOnlyServiceEchoPingPongResult) GetSuccess() (v *EchoResponse) { +func (p *PingPongOnlyServiceEchoPingPongNewResult) GetSuccess() (v *EchoResponse) { if !p.IsSetSuccess() { - return PingPongOnlyServiceEchoPingPongResult_Success_DEFAULT + return PingPongOnlyServiceEchoPingPongNewResult_Success_DEFAULT } return p.Success } -func (p *PingPongOnlyServiceEchoPingPongResult) SetSuccess(x interface{}) { +func (p *PingPongOnlyServiceEchoPingPongNewResult) SetSuccess(x interface{}) { p.Success = x.(*EchoResponse) } -var fieldIDToName_PingPongOnlyServiceEchoPingPongResult = map[int16]string{ +var fieldIDToName_PingPongOnlyServiceEchoPingPongNewResult = map[int16]string{ 0: "success", } -func (p *PingPongOnlyServiceEchoPingPongResult) IsSetSuccess() bool { +func (p *PingPongOnlyServiceEchoPingPongNewResult) IsSetSuccess() bool { return p.Success != nil } -func (p *PingPongOnlyServiceEchoPingPongResult) Read(iprot thrift.TProtocol) (err error) { +func (p *PingPongOnlyServiceEchoPingPongNewResult) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -3700,7 +3816,7 @@ ReadStructBeginError: ReadFieldBeginError: return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongResult[fieldId]), err) + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongNewResult[fieldId]), err) SkipFieldError: return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) @@ -3710,7 +3826,7 @@ ReadStructEndError: return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongResult) ReadField0(iprot thrift.TProtocol) error { +func (p *PingPongOnlyServiceEchoPingPongNewResult) ReadField0(iprot thrift.TProtocol) error { p.Success = NewEchoResponse() if err := p.Success.Read(iprot); err != nil { return err @@ -3718,9 +3834,407 @@ func (p *PingPongOnlyServiceEchoPingPongResult) ReadField0(iprot thrift.TProtoco return nil } -func (p *PingPongOnlyServiceEchoPingPongResult) Write(oprot thrift.TProtocol) (err error) { +func (p *PingPongOnlyServiceEchoPingPongNewResult) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 - if err = oprot.WriteStructBegin("EchoPingPong_result"); err != nil { + if err = oprot.WriteStructBegin("EchoPingPongNew_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PingPongOnlyServiceEchoPingPongNewResult(%+v)", *p) + +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) DeepEqual(ano *PingPongOnlyServiceEchoPingPongNewResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) Field0DeepEqual(src *EchoResponse) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type PingPongOnlyServiceChildProcessor struct { + *PingPongOnlyServiceProcessor +} + +func NewPingPongOnlyServiceChildProcessor(handler PingPongOnlyServiceChild) *PingPongOnlyServiceChildProcessor { + self := &PingPongOnlyServiceChildProcessor{NewPingPongOnlyServiceProcessor(handler)} + self.AddToProcessorMap("EchoBidirectionalExtended", &pingPongOnlyServiceChildProcessorEchoBidirectionalExtended{handler: handler}) + return self +} + +type pingPongOnlyServiceChildProcessorEchoBidirectionalExtended struct { + handler PingPongOnlyServiceChild +} + +func (p *pingPongOnlyServiceChildProcessorEchoBidirectionalExtended) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := PingPongOnlyServiceChildEchoBidirectionalExtendedArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("EchoBidirectionalExtended", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := PingPongOnlyServiceChildEchoBidirectionalExtendedResult{} + var retval *EchoResponse + if retval, err2 = p.handler.EchoBidirectionalExtended(ctx, args.Req1); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoBidirectionalExtended: "+err2.Error()) + oprot.WriteMessageBegin("EchoBidirectionalExtended", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("EchoBidirectionalExtended", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type PingPongOnlyServiceChildEchoBidirectionalExtendedArgs struct { + Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` +} + +func NewPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs { + return &PingPongOnlyServiceChildEchoBidirectionalExtendedArgs{} +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) InitDefault() { + *p = PingPongOnlyServiceChildEchoBidirectionalExtendedArgs{} +} + +var PingPongOnlyServiceChildEchoBidirectionalExtendedArgs_Req1_DEFAULT *EchoRequest + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) GetReq1() (v *EchoRequest) { + if !p.IsSetReq1() { + return PingPongOnlyServiceChildEchoBidirectionalExtendedArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) SetReq1(val *EchoRequest) { + p.Req1 = val +} + +var fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedArgs = map[int16]string{ + 1: "req1", +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = NewEchoRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoBidirectionalExtended_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PingPongOnlyServiceChildEchoBidirectionalExtendedArgs(%+v)", *p) + +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) DeepEqual(ano *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) Field1DeepEqual(src *EchoRequest) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type PingPongOnlyServiceChildEchoBidirectionalExtendedResult struct { + Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` +} + +func NewPingPongOnlyServiceChildEchoBidirectionalExtendedResult() *PingPongOnlyServiceChildEchoBidirectionalExtendedResult { + return &PingPongOnlyServiceChildEchoBidirectionalExtendedResult{} +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) InitDefault() { + *p = PingPongOnlyServiceChildEchoBidirectionalExtendedResult{} +} + +var PingPongOnlyServiceChildEchoBidirectionalExtendedResult_Success_DEFAULT *EchoResponse + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) GetSuccess() (v *EchoResponse) { + if !p.IsSetSuccess() { + return PingPongOnlyServiceChildEchoBidirectionalExtendedResult_Success_DEFAULT + } + return p.Success +} +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) SetSuccess(x interface{}) { + p.Success = x.(*EchoResponse) +} + +var fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedResult = map[int16]string{ + 0: "success", +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = NewEchoResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoBidirectionalExtended_result"); err != nil { goto WriteStructBeginError } if p != nil { @@ -3746,7 +4260,7 @@ WriteStructEndError: return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) writeField0(oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { goto WriteFieldBeginError @@ -3765,15 +4279,15 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongResult) String() string { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) String() string { if p == nil { return "" } - return fmt.Sprintf("PingPongOnlyServiceEchoPingPongResult(%+v)", *p) + return fmt.Sprintf("PingPongOnlyServiceChildEchoBidirectionalExtendedResult(%+v)", *p) } -func (p *PingPongOnlyServiceEchoPingPongResult) DeepEqual(ano *PingPongOnlyServiceEchoPingPongResult) bool { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) DeepEqual(ano *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) bool { if p == ano { return true } else if p == nil || ano == nil { @@ -3785,7 +4299,7 @@ func (p *PingPongOnlyServiceEchoPingPongResult) DeepEqual(ano *PingPongOnlyServi return true } -func (p *PingPongOnlyServiceEchoPingPongResult) Field0DeepEqual(src *EchoResponse) bool { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) Field0DeepEqual(src *EchoResponse) bool { if !p.Success.DeepEqual(src) { return false @@ -3793,6 +4307,15 @@ func (p *PingPongOnlyServiceEchoPingPongResult) Field0DeepEqual(src *EchoRespons return true } +type PingPongOnlyServiceChildChildProcessor struct { + *PingPongOnlyServiceChildProcessor +} + +func NewPingPongOnlyServiceChildChildProcessor(handler PingPongOnlyServiceChildChild) *PingPongOnlyServiceChildChildProcessor { + self := &PingPongOnlyServiceChildChildProcessor{NewPingPongOnlyServiceChildProcessor(handler)} + return self +} + type StreamOnlyServiceProcessor struct { processorMap map[string]thrift.TProcessorFunction handler StreamOnlyService @@ -3813,7 +4336,7 @@ func (p *StreamOnlyServiceProcessor) ProcessorMap() map[string]thrift.TProcessor func NewStreamOnlyServiceProcessor(handler StreamOnlyService) *StreamOnlyServiceProcessor { self := &StreamOnlyServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("EchoBidirectional", &streamOnlyServiceProcessorEchoBidirectional{handler: handler}) + self.AddToProcessorMap("EchoBidirectionalNew", &streamOnlyServiceProcessorEchoBidirectionalNew{handler: handler}) return self } func (p *StreamOnlyServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { @@ -3834,16 +4357,16 @@ func (p *StreamOnlyServiceProcessor) Process(ctx context.Context, iprot, oprot t return false, x } -type streamOnlyServiceProcessorEchoBidirectional struct { +type streamOnlyServiceProcessorEchoBidirectionalNew struct { handler StreamOnlyService } -func (p *streamOnlyServiceProcessorEchoBidirectional) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := StreamOnlyServiceEchoBidirectionalArgs{} +func (p *streamOnlyServiceProcessorEchoBidirectionalNew) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := StreamOnlyServiceEchoBidirectionalNewArgs{} if err = args.Read(iprot); err != nil { iprot.ReadMessageEnd() x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("EchoBidirectional", thrift.EXCEPTION, seqId) + oprot.WriteMessageBegin("EchoBidirectionalNew", thrift.EXCEPTION, seqId) x.Write(oprot) oprot.WriteMessageEnd() oprot.Flush(ctx) @@ -3852,11 +4375,11 @@ func (p *streamOnlyServiceProcessorEchoBidirectional) Process(ctx context.Contex iprot.ReadMessageEnd() var err2 error - result := StreamOnlyServiceEchoBidirectionalResult{} + result := StreamOnlyServiceEchoBidirectionalNewResult{} var retval *EchoResponse - if retval, err2 = p.handler.EchoBidirectional(ctx, args.Req1); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoBidirectional: "+err2.Error()) - oprot.WriteMessageBegin("EchoBidirectional", thrift.EXCEPTION, seqId) + if retval, err2 = p.handler.EchoBidirectionalNew(ctx, args.Req1); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoBidirectionalNew: "+err2.Error()) + oprot.WriteMessageBegin("EchoBidirectionalNew", thrift.EXCEPTION, seqId) x.Write(oprot) oprot.WriteMessageEnd() oprot.Flush(ctx) @@ -3864,7 +4387,7 @@ func (p *streamOnlyServiceProcessorEchoBidirectional) Process(ctx context.Contex } else { result.Success = retval } - if err2 = oprot.WriteMessageBegin("EchoBidirectional", thrift.REPLY, seqId); err2 != nil { + if err2 = oprot.WriteMessageBegin("EchoBidirectionalNew", thrift.REPLY, seqId); err2 != nil { err = err2 } if err2 = result.Write(oprot); err == nil && err2 != nil { @@ -3882,39 +4405,39 @@ func (p *streamOnlyServiceProcessorEchoBidirectional) Process(ctx context.Contex return true, err } -type StreamOnlyServiceEchoBidirectionalArgs struct { +type StreamOnlyServiceEchoBidirectionalNewArgs struct { Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` } -func NewStreamOnlyServiceEchoBidirectionalArgs() *StreamOnlyServiceEchoBidirectionalArgs { - return &StreamOnlyServiceEchoBidirectionalArgs{} +func NewStreamOnlyServiceEchoBidirectionalNewArgs() *StreamOnlyServiceEchoBidirectionalNewArgs { + return &StreamOnlyServiceEchoBidirectionalNewArgs{} } -func (p *StreamOnlyServiceEchoBidirectionalArgs) InitDefault() { - *p = StreamOnlyServiceEchoBidirectionalArgs{} +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) InitDefault() { + *p = StreamOnlyServiceEchoBidirectionalNewArgs{} } -var StreamOnlyServiceEchoBidirectionalArgs_Req1_DEFAULT *EchoRequest +var StreamOnlyServiceEchoBidirectionalNewArgs_Req1_DEFAULT *EchoRequest -func (p *StreamOnlyServiceEchoBidirectionalArgs) GetReq1() (v *EchoRequest) { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) GetReq1() (v *EchoRequest) { if !p.IsSetReq1() { - return StreamOnlyServiceEchoBidirectionalArgs_Req1_DEFAULT + return StreamOnlyServiceEchoBidirectionalNewArgs_Req1_DEFAULT } return p.Req1 } -func (p *StreamOnlyServiceEchoBidirectionalArgs) SetReq1(val *EchoRequest) { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) SetReq1(val *EchoRequest) { p.Req1 = val } -var fieldIDToName_StreamOnlyServiceEchoBidirectionalArgs = map[int16]string{ +var fieldIDToName_StreamOnlyServiceEchoBidirectionalNewArgs = map[int16]string{ 1: "req1", } -func (p *StreamOnlyServiceEchoBidirectionalArgs) IsSetReq1() bool { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) IsSetReq1() bool { return p.Req1 != nil } -func (p *StreamOnlyServiceEchoBidirectionalArgs) Read(iprot thrift.TProtocol) (err error) { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -3960,7 +4483,7 @@ ReadStructBeginError: ReadFieldBeginError: return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalArgs[fieldId]), err) + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalNewArgs[fieldId]), err) SkipFieldError: return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) @@ -3970,7 +4493,7 @@ ReadStructEndError: return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *StreamOnlyServiceEchoBidirectionalArgs) ReadField1(iprot thrift.TProtocol) error { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) ReadField1(iprot thrift.TProtocol) error { p.Req1 = NewEchoRequest() if err := p.Req1.Read(iprot); err != nil { return err @@ -3978,9 +4501,9 @@ func (p *StreamOnlyServiceEchoBidirectionalArgs) ReadField1(iprot thrift.TProtoc return nil } -func (p *StreamOnlyServiceEchoBidirectionalArgs) Write(oprot thrift.TProtocol) (err error) { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 - if err = oprot.WriteStructBegin("EchoBidirectional_args"); err != nil { + if err = oprot.WriteStructBegin("EchoBidirectionalNew_args"); err != nil { goto WriteStructBeginError } if p != nil { @@ -4006,7 +4529,7 @@ WriteStructEndError: return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) } -func (p *StreamOnlyServiceEchoBidirectionalArgs) writeField1(oprot thrift.TProtocol) (err error) { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) writeField1(oprot thrift.TProtocol) (err error) { if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { goto WriteFieldBeginError } @@ -4023,15 +4546,15 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } -func (p *StreamOnlyServiceEchoBidirectionalArgs) String() string { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) String() string { if p == nil { return "" } - return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalArgs(%+v)", *p) + return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalNewArgs(%+v)", *p) } -func (p *StreamOnlyServiceEchoBidirectionalArgs) DeepEqual(ano *StreamOnlyServiceEchoBidirectionalArgs) bool { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) DeepEqual(ano *StreamOnlyServiceEchoBidirectionalNewArgs) bool { if p == ano { return true } else if p == nil || ano == nil { @@ -4043,7 +4566,7 @@ func (p *StreamOnlyServiceEchoBidirectionalArgs) DeepEqual(ano *StreamOnlyServic return true } -func (p *StreamOnlyServiceEchoBidirectionalArgs) Field1DeepEqual(src *EchoRequest) bool { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) Field1DeepEqual(src *EchoRequest) bool { if !p.Req1.DeepEqual(src) { return false @@ -4051,39 +4574,39 @@ func (p *StreamOnlyServiceEchoBidirectionalArgs) Field1DeepEqual(src *EchoReques return true } -type StreamOnlyServiceEchoBidirectionalResult struct { +type StreamOnlyServiceEchoBidirectionalNewResult struct { Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` } -func NewStreamOnlyServiceEchoBidirectionalResult() *StreamOnlyServiceEchoBidirectionalResult { - return &StreamOnlyServiceEchoBidirectionalResult{} +func NewStreamOnlyServiceEchoBidirectionalNewResult() *StreamOnlyServiceEchoBidirectionalNewResult { + return &StreamOnlyServiceEchoBidirectionalNewResult{} } -func (p *StreamOnlyServiceEchoBidirectionalResult) InitDefault() { - *p = StreamOnlyServiceEchoBidirectionalResult{} +func (p *StreamOnlyServiceEchoBidirectionalNewResult) InitDefault() { + *p = StreamOnlyServiceEchoBidirectionalNewResult{} } -var StreamOnlyServiceEchoBidirectionalResult_Success_DEFAULT *EchoResponse +var StreamOnlyServiceEchoBidirectionalNewResult_Success_DEFAULT *EchoResponse -func (p *StreamOnlyServiceEchoBidirectionalResult) GetSuccess() (v *EchoResponse) { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) GetSuccess() (v *EchoResponse) { if !p.IsSetSuccess() { - return StreamOnlyServiceEchoBidirectionalResult_Success_DEFAULT + return StreamOnlyServiceEchoBidirectionalNewResult_Success_DEFAULT } return p.Success } -func (p *StreamOnlyServiceEchoBidirectionalResult) SetSuccess(x interface{}) { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) SetSuccess(x interface{}) { p.Success = x.(*EchoResponse) } -var fieldIDToName_StreamOnlyServiceEchoBidirectionalResult = map[int16]string{ +var fieldIDToName_StreamOnlyServiceEchoBidirectionalNewResult = map[int16]string{ 0: "success", } -func (p *StreamOnlyServiceEchoBidirectionalResult) IsSetSuccess() bool { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) IsSetSuccess() bool { return p.Success != nil } -func (p *StreamOnlyServiceEchoBidirectionalResult) Read(iprot thrift.TProtocol) (err error) { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) Read(iprot thrift.TProtocol) (err error) { var fieldTypeId thrift.TType var fieldId int16 @@ -4129,7 +4652,7 @@ ReadStructBeginError: ReadFieldBeginError: return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalResult[fieldId]), err) + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalNewResult[fieldId]), err) SkipFieldError: return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) @@ -4139,7 +4662,7 @@ ReadStructEndError: return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *StreamOnlyServiceEchoBidirectionalResult) ReadField0(iprot thrift.TProtocol) error { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) ReadField0(iprot thrift.TProtocol) error { p.Success = NewEchoResponse() if err := p.Success.Read(iprot); err != nil { return err @@ -4147,9 +4670,9 @@ func (p *StreamOnlyServiceEchoBidirectionalResult) ReadField0(iprot thrift.TProt return nil } -func (p *StreamOnlyServiceEchoBidirectionalResult) Write(oprot thrift.TProtocol) (err error) { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) Write(oprot thrift.TProtocol) (err error) { var fieldId int16 - if err = oprot.WriteStructBegin("EchoBidirectional_result"); err != nil { + if err = oprot.WriteStructBegin("EchoBidirectionalNew_result"); err != nil { goto WriteStructBeginError } if p != nil { @@ -4175,7 +4698,7 @@ WriteStructEndError: return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) } -func (p *StreamOnlyServiceEchoBidirectionalResult) writeField0(oprot thrift.TProtocol) (err error) { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) writeField0(oprot thrift.TProtocol) (err error) { if p.IsSetSuccess() { if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { goto WriteFieldBeginError @@ -4194,15 +4717,15 @@ WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) } -func (p *StreamOnlyServiceEchoBidirectionalResult) String() string { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) String() string { if p == nil { return "" } - return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalResult(%+v)", *p) + return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalNewResult(%+v)", *p) } -func (p *StreamOnlyServiceEchoBidirectionalResult) DeepEqual(ano *StreamOnlyServiceEchoBidirectionalResult) bool { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) DeepEqual(ano *StreamOnlyServiceEchoBidirectionalNewResult) bool { if p == ano { return true } else if p == nil || ano == nil { @@ -4214,10 +4737,28 @@ func (p *StreamOnlyServiceEchoBidirectionalResult) DeepEqual(ano *StreamOnlyServ return true } -func (p *StreamOnlyServiceEchoBidirectionalResult) Field0DeepEqual(src *EchoResponse) bool { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) Field0DeepEqual(src *EchoResponse) bool { if !p.Success.DeepEqual(src) { return false } return true } + +type StreamOnlyServiceChildProcessor struct { + *StreamOnlyServiceProcessor +} + +func NewStreamOnlyServiceChildProcessor(handler StreamOnlyServiceChild) *StreamOnlyServiceChildProcessor { + self := &StreamOnlyServiceChildProcessor{NewStreamOnlyServiceProcessor(handler)} + return self +} + +type StreamOnlyServiceChildChildProcessor struct { + *StreamOnlyServiceChildProcessor +} + +func NewStreamOnlyServiceChildChildProcessor(handler StreamOnlyServiceChildChild) *StreamOnlyServiceChildChildProcessor { + self := &StreamOnlyServiceChildChildProcessor{NewStreamOnlyServiceChildProcessor(handler)} + return self +} diff --git a/thrift_streaming/kitex_gen_old/echo/k-api.go b/thrift_streaming/kitex_gen_old/echo/k-api.go index d0db499..9eaa6c2 100644 --- a/thrift_streaming/kitex_gen_old/echo/k-api.go +++ b/thrift_streaming/kitex_gen_old/echo/k-api.go @@ -2171,7 +2171,7 @@ func (p *EchoServicePingResult) BLength() int { return l } -func (p *PingPongOnlyServiceEchoPingPongArgs) FastRead(buf []byte) (int, error) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) FastRead(buf []byte) (int, error) { var err error var offset int var l int @@ -2233,7 +2233,7 @@ ReadStructBeginError: ReadFieldBeginError: return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongArgs[fieldId]), err) + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongNewArgs[fieldId]), err) SkipFieldError: return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) ReadFieldEndError: @@ -2242,7 +2242,7 @@ ReadStructEndError: return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongArgs) FastReadField1(buf []byte) (int, error) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) FastReadField1(buf []byte) (int, error) { offset := 0 tmp := NewEchoRequest() @@ -2256,13 +2256,13 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) FastReadField1(buf []byte) (int, e } // for compatibility -func (p *PingPongOnlyServiceEchoPingPongArgs) FastWrite(buf []byte) int { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) FastWrite(buf []byte) int { return 0 } -func (p *PingPongOnlyServiceEchoPingPongArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPong_args") + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPongNew_args") if p != nil { offset += p.fastWriteField1(buf[offset:], binaryWriter) } @@ -2271,9 +2271,9 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) FastWriteNocopy(buf []byte, binary return offset } -func (p *PingPongOnlyServiceEchoPingPongArgs) BLength() int { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("EchoPingPong_args") + l += bthrift.Binary.StructBeginLength("EchoPingPongNew_args") if p != nil { l += p.field1Length() } @@ -2282,7 +2282,7 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) BLength() int { return l } -func (p *PingPongOnlyServiceEchoPingPongArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { offset := 0 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) @@ -2290,7 +2290,7 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) fastWriteField1(buf []byte, binary return offset } -func (p *PingPongOnlyServiceEchoPingPongArgs) field1Length() int { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) field1Length() int { l := 0 l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) l += p.Req1.BLength() @@ -2298,7 +2298,7 @@ func (p *PingPongOnlyServiceEchoPingPongArgs) field1Length() int { return l } -func (p *PingPongOnlyServiceEchoPingPongResult) FastRead(buf []byte) (int, error) { +func (p *PingPongOnlyServiceEchoPingPongNewResult) FastRead(buf []byte) (int, error) { var err error var offset int var l int @@ -2360,7 +2360,7 @@ ReadStructBeginError: ReadFieldBeginError: return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongResult[fieldId]), err) + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongNewResult[fieldId]), err) SkipFieldError: return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) ReadFieldEndError: @@ -2369,7 +2369,7 @@ ReadStructEndError: return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *PingPongOnlyServiceEchoPingPongResult) FastReadField0(buf []byte) (int, error) { +func (p *PingPongOnlyServiceEchoPingPongNewResult) FastReadField0(buf []byte) (int, error) { offset := 0 tmp := NewEchoResponse() @@ -2383,13 +2383,13 @@ func (p *PingPongOnlyServiceEchoPingPongResult) FastReadField0(buf []byte) (int, } // for compatibility -func (p *PingPongOnlyServiceEchoPingPongResult) FastWrite(buf []byte) int { +func (p *PingPongOnlyServiceEchoPingPongNewResult) FastWrite(buf []byte) int { return 0 } -func (p *PingPongOnlyServiceEchoPingPongResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PingPongOnlyServiceEchoPingPongNewResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPong_result") + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPongNew_result") if p != nil { offset += p.fastWriteField0(buf[offset:], binaryWriter) } @@ -2398,9 +2398,9 @@ func (p *PingPongOnlyServiceEchoPingPongResult) FastWriteNocopy(buf []byte, bina return offset } -func (p *PingPongOnlyServiceEchoPingPongResult) BLength() int { +func (p *PingPongOnlyServiceEchoPingPongNewResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("EchoPingPong_result") + l += bthrift.Binary.StructBeginLength("EchoPingPongNew_result") if p != nil { l += p.field0Length() } @@ -2409,7 +2409,7 @@ func (p *PingPongOnlyServiceEchoPingPongResult) BLength() int { return l } -func (p *PingPongOnlyServiceEchoPingPongResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PingPongOnlyServiceEchoPingPongNewResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { offset := 0 if p.IsSetSuccess() { offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) @@ -2419,7 +2419,7 @@ func (p *PingPongOnlyServiceEchoPingPongResult) fastWriteField0(buf []byte, bina return offset } -func (p *PingPongOnlyServiceEchoPingPongResult) field0Length() int { +func (p *PingPongOnlyServiceEchoPingPongNewResult) field0Length() int { l := 0 if p.IsSetSuccess() { l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) @@ -2429,7 +2429,7 @@ func (p *PingPongOnlyServiceEchoPingPongResult) field0Length() int { return l } -func (p *StreamOnlyServiceEchoBidirectionalArgs) FastRead(buf []byte) (int, error) { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) FastRead(buf []byte) (int, error) { var err error var offset int var l int @@ -2491,7 +2491,7 @@ ReadStructBeginError: ReadFieldBeginError: return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalArgs[fieldId]), err) + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedArgs[fieldId]), err) SkipFieldError: return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) ReadFieldEndError: @@ -2500,7 +2500,7 @@ ReadStructEndError: return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *StreamOnlyServiceEchoBidirectionalArgs) FastReadField1(buf []byte) (int, error) { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) FastReadField1(buf []byte) (int, error) { offset := 0 tmp := NewEchoRequest() @@ -2514,13 +2514,13 @@ func (p *StreamOnlyServiceEchoBidirectionalArgs) FastReadField1(buf []byte) (int } // for compatibility -func (p *StreamOnlyServiceEchoBidirectionalArgs) FastWrite(buf []byte) int { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) FastWrite(buf []byte) int { return 0 } -func (p *StreamOnlyServiceEchoBidirectionalArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectional_args") + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectionalExtended_args") if p != nil { offset += p.fastWriteField1(buf[offset:], binaryWriter) } @@ -2529,9 +2529,9 @@ func (p *StreamOnlyServiceEchoBidirectionalArgs) FastWriteNocopy(buf []byte, bin return offset } -func (p *StreamOnlyServiceEchoBidirectionalArgs) BLength() int { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("EchoBidirectional_args") + l += bthrift.Binary.StructBeginLength("EchoBidirectionalExtended_args") if p != nil { l += p.field1Length() } @@ -2540,7 +2540,7 @@ func (p *StreamOnlyServiceEchoBidirectionalArgs) BLength() int { return l } -func (p *StreamOnlyServiceEchoBidirectionalArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { offset := 0 offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) @@ -2548,7 +2548,7 @@ func (p *StreamOnlyServiceEchoBidirectionalArgs) fastWriteField1(buf []byte, bin return offset } -func (p *StreamOnlyServiceEchoBidirectionalArgs) field1Length() int { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) field1Length() int { l := 0 l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) l += p.Req1.BLength() @@ -2556,7 +2556,7 @@ func (p *StreamOnlyServiceEchoBidirectionalArgs) field1Length() int { return l } -func (p *StreamOnlyServiceEchoBidirectionalResult) FastRead(buf []byte) (int, error) { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) FastRead(buf []byte) (int, error) { var err error var offset int var l int @@ -2618,7 +2618,7 @@ ReadStructBeginError: ReadFieldBeginError: return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalResult[fieldId]), err) + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedResult[fieldId]), err) SkipFieldError: return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) ReadFieldEndError: @@ -2627,7 +2627,7 @@ ReadStructEndError: return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *StreamOnlyServiceEchoBidirectionalResult) FastReadField0(buf []byte) (int, error) { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) FastReadField0(buf []byte) (int, error) { offset := 0 tmp := NewEchoResponse() @@ -2641,13 +2641,13 @@ func (p *StreamOnlyServiceEchoBidirectionalResult) FastReadField0(buf []byte) (i } // for compatibility -func (p *StreamOnlyServiceEchoBidirectionalResult) FastWrite(buf []byte) int { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) FastWrite(buf []byte) int { return 0 } -func (p *StreamOnlyServiceEchoBidirectionalResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectional_result") + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectionalExtended_result") if p != nil { offset += p.fastWriteField0(buf[offset:], binaryWriter) } @@ -2656,9 +2656,267 @@ func (p *StreamOnlyServiceEchoBidirectionalResult) FastWriteNocopy(buf []byte, b return offset } -func (p *StreamOnlyServiceEchoBidirectionalResult) BLength() int { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) BLength() int { l := 0 - l += bthrift.Binary.StructBeginLength("EchoBidirectional_result") + l += bthrift.Binary.StructBeginLength("EchoBidirectionalExtended_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalNewArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectionalNew_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoBidirectionalNew_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalNewResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *StreamOnlyServiceEchoBidirectionalNewResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectionalNew_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoBidirectionalNew_result") if p != nil { l += p.field0Length() } @@ -2667,7 +2925,7 @@ func (p *StreamOnlyServiceEchoBidirectionalResult) BLength() int { return l } -func (p *StreamOnlyServiceEchoBidirectionalResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { offset := 0 if p.IsSetSuccess() { offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) @@ -2677,7 +2935,7 @@ func (p *StreamOnlyServiceEchoBidirectionalResult) fastWriteField0(buf []byte, b return offset } -func (p *StreamOnlyServiceEchoBidirectionalResult) field0Length() int { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) field0Length() int { l := 0 if p.IsSetSuccess() { l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) @@ -2743,18 +3001,26 @@ func (p *EchoServicePingResult) GetResult() interface{} { return nil } -func (p *PingPongOnlyServiceEchoPingPongArgs) GetFirstArgument() interface{} { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) GetResult() interface{} { + return p.Success +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) GetFirstArgument() interface{} { return p.Req1 } -func (p *PingPongOnlyServiceEchoPingPongResult) GetResult() interface{} { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) GetResult() interface{} { return p.Success } -func (p *StreamOnlyServiceEchoBidirectionalArgs) GetFirstArgument() interface{} { +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) GetFirstArgument() interface{} { return p.Req1 } -func (p *StreamOnlyServiceEchoBidirectionalResult) GetResult() interface{} { +func (p *StreamOnlyServiceEchoBidirectionalNewResult) GetResult() interface{} { return p.Success } diff --git a/thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/client.go b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/client.go index 0a49be0..8cf515b 100644 --- a/thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/client.go +++ b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/client.go @@ -11,7 +11,7 @@ import ( // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. type Client interface { - EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) + EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) } // NewClient creates a client for the service defined in IDL. @@ -43,7 +43,7 @@ type kPingPongOnlyServiceClient struct { *kClient } -func (p *kPingPongOnlyServiceClient) EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { +func (p *kPingPongOnlyServiceClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.EchoPingPong(ctx, req1) + return p.kClient.EchoPingPongNew(ctx, req1) } diff --git a/thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/pingpongonlyservice.go b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/pingpongonlyservice.go index 498d0a3..4ce1064 100644 --- a/thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/pingpongonlyservice.go +++ b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservice/pingpongonlyservice.go @@ -19,7 +19,7 @@ func NewServiceInfo() *kitex.ServiceInfo { serviceName := "PingPongOnlyService" handlerType := (*echo.PingPongOnlyService)(nil) methods := map[string]kitex.MethodInfo{ - "EchoPingPong": kitex.NewMethodInfo(echoPingPongHandler, newPingPongOnlyServiceEchoPingPongArgs, newPingPongOnlyServiceEchoPingPongResult, false), + "EchoPingPongNew": kitex.NewMethodInfo(echoPingPongNewHandler, newPingPongOnlyServiceEchoPingPongNewArgs, newPingPongOnlyServiceEchoPingPongNewResult, false), } extra := map[string]interface{}{ "PackageName": "echo", @@ -36,22 +36,22 @@ func NewServiceInfo() *kitex.ServiceInfo { return svcInfo } -func echoPingPongHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongArgs) - realResult := result.(*echo.PingPongOnlyServiceEchoPingPongResult) - success, err := handler.(echo.PingPongOnlyService).EchoPingPong(ctx, realArg.Req1) +func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) if err != nil { return err } realResult.Success = success return nil } -func newPingPongOnlyServiceEchoPingPongArgs() interface{} { - return echo.NewPingPongOnlyServiceEchoPingPongArgs() +func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() } -func newPingPongOnlyServiceEchoPingPongResult() interface{} { - return echo.NewPingPongOnlyServiceEchoPingPongResult() +func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewResult() } type kClient struct { @@ -64,11 +64,11 @@ func newServiceClient(c client.Client) *kClient { } } -func (p *kClient) EchoPingPong(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { - var _args echo.PingPongOnlyServiceEchoPingPongArgs +func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongNewArgs _args.Req1 = req1 - var _result echo.PingPongOnlyServiceEchoPingPongResult - if err = p.c.Call(ctx, "EchoPingPong", &_args, &_result); err != nil { + var _result echo.PingPongOnlyServiceEchoPingPongNewResult + if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { return } return _result.GetSuccess(), nil diff --git a/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechild/client.go b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechild/client.go new file mode 100644 index 0000000..67dc119 --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechild/client.go @@ -0,0 +1,55 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) + EchoBidirectionalExtended(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfo(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceChildClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceChildClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceChildClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPongNew(ctx, req1) +} + +func (p *kPingPongOnlyServiceChildClient) EchoBidirectionalExtended(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoBidirectionalExtended(ctx, req1) +} diff --git a/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechild/invoker.go b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechild/invoker.go new file mode 100644 index 0000000..30f132d --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechild/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.PingPongOnlyServiceChild, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechild/pingpongonlyservicechild.go b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechild/pingpongonlyservicechild.go new file mode 100644 index 0000000..f97798f --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechild/pingpongonlyservicechild.go @@ -0,0 +1,104 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +func serviceInfo() *kitex.ServiceInfo { + return pingPongOnlyServiceChildServiceInfo +} + +var pingPongOnlyServiceChildServiceInfo = NewServiceInfo() + +func NewServiceInfo() *kitex.ServiceInfo { + serviceName := "PingPongOnlyServiceChild" + handlerType := (*echo.PingPongOnlyServiceChild)(nil) + methods := map[string]kitex.MethodInfo{ + "EchoPingPongNew": kitex.NewMethodInfo(echoPingPongNewHandler, newPingPongOnlyServiceEchoPingPongNewArgs, newPingPongOnlyServiceEchoPingPongNewResult, false), + "EchoBidirectionalExtended": kitex.NewMethodInfo(echoBidirectionalExtendedHandler, newPingPongOnlyServiceChildEchoBidirectionalExtendedArgs, newPingPongOnlyServiceChildEchoBidirectionalExtendedResult, false), + } + extra := map[string]interface{}{ + "PackageName": "echo", + "ServiceFilePath": `idl/api.thrift`, + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() +} + +func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewResult() +} + +func echoBidirectionalExtendedHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) + realResult := result.(*echo.PingPongOnlyServiceChildEchoBidirectionalExtendedResult) + success, err := handler.(echo.PingPongOnlyServiceChild).EchoBidirectionalExtended(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() interface{} { + return echo.NewPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() +} + +func newPingPongOnlyServiceChildEchoBidirectionalExtendedResult() interface{} { + return echo.NewPingPongOnlyServiceChildEchoBidirectionalExtendedResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongNewArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceEchoPingPongNewResult + if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) EchoBidirectionalExtended(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceChildEchoBidirectionalExtendedArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceChildEchoBidirectionalExtendedResult + if err = p.c.Call(ctx, "EchoBidirectionalExtended", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechild/server.go b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechild/server.go new file mode 100644 index 0000000..316b88b --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechild/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package pingpongonlyservicechild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.PingPongOnlyServiceChild, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechildchild/client.go b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechildchild/client.go new file mode 100644 index 0000000..a0c2901 --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechildchild/client.go @@ -0,0 +1,55 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechildchild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) + EchoBidirectionalExtended(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfo(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceChildChildClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceChildChildClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceChildChildClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPongNew(ctx, req1) +} + +func (p *kPingPongOnlyServiceChildChildClient) EchoBidirectionalExtended(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoBidirectionalExtended(ctx, req1) +} diff --git a/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechildchild/invoker.go b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechildchild/invoker.go new file mode 100644 index 0000000..6b1711c --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechildchild/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechildchild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.PingPongOnlyServiceChildChild, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go new file mode 100644 index 0000000..bd32917 --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go @@ -0,0 +1,104 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechildchild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +func serviceInfo() *kitex.ServiceInfo { + return pingPongOnlyServiceChildChildServiceInfo +} + +var pingPongOnlyServiceChildChildServiceInfo = NewServiceInfo() + +func NewServiceInfo() *kitex.ServiceInfo { + serviceName := "PingPongOnlyServiceChildChild" + handlerType := (*echo.PingPongOnlyServiceChildChild)(nil) + methods := map[string]kitex.MethodInfo{ + "EchoPingPongNew": kitex.NewMethodInfo(echoPingPongNewHandler, newPingPongOnlyServiceEchoPingPongNewArgs, newPingPongOnlyServiceEchoPingPongNewResult, false), + "EchoBidirectionalExtended": kitex.NewMethodInfo(echoBidirectionalExtendedHandler, newPingPongOnlyServiceChildEchoBidirectionalExtendedArgs, newPingPongOnlyServiceChildEchoBidirectionalExtendedResult, false), + } + extra := map[string]interface{}{ + "PackageName": "echo", + "ServiceFilePath": `idl/api.thrift`, + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() +} + +func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewResult() +} + +func echoBidirectionalExtendedHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) + realResult := result.(*echo.PingPongOnlyServiceChildEchoBidirectionalExtendedResult) + success, err := handler.(echo.PingPongOnlyServiceChild).EchoBidirectionalExtended(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() interface{} { + return echo.NewPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() +} + +func newPingPongOnlyServiceChildEchoBidirectionalExtendedResult() interface{} { + return echo.NewPingPongOnlyServiceChildEchoBidirectionalExtendedResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongNewArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceEchoPingPongNewResult + if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) EchoBidirectionalExtended(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceChildEchoBidirectionalExtendedArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceChildEchoBidirectionalExtendedResult + if err = p.c.Call(ctx, "EchoBidirectionalExtended", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechildchild/server.go b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechildchild/server.go new file mode 100644 index 0000000..0be886f --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/pingpongonlyservicechildchild/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package pingpongonlyservicechildchild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.PingPongOnlyServiceChildChild, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_old/echo/streamonlyservice/client.go b/thrift_streaming/kitex_gen_old/echo/streamonlyservice/client.go index bb5c0b6..3af7b7f 100644 --- a/thrift_streaming/kitex_gen_old/echo/streamonlyservice/client.go +++ b/thrift_streaming/kitex_gen_old/echo/streamonlyservice/client.go @@ -11,7 +11,7 @@ import ( // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. type Client interface { - EchoBidirectional(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) + EchoBidirectionalNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) } // NewClient creates a client for the service defined in IDL. @@ -43,7 +43,7 @@ type kStreamOnlyServiceClient struct { *kClient } -func (p *kStreamOnlyServiceClient) EchoBidirectional(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { +func (p *kStreamOnlyServiceClient) EchoBidirectionalNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.EchoBidirectional(ctx, req1) + return p.kClient.EchoBidirectionalNew(ctx, req1) } diff --git a/thrift_streaming/kitex_gen_old/echo/streamonlyservice/streamonlyservice.go b/thrift_streaming/kitex_gen_old/echo/streamonlyservice/streamonlyservice.go index 147b8f8..b084989 100644 --- a/thrift_streaming/kitex_gen_old/echo/streamonlyservice/streamonlyservice.go +++ b/thrift_streaming/kitex_gen_old/echo/streamonlyservice/streamonlyservice.go @@ -19,7 +19,7 @@ func NewServiceInfo() *kitex.ServiceInfo { serviceName := "StreamOnlyService" handlerType := (*echo.StreamOnlyService)(nil) methods := map[string]kitex.MethodInfo{ - "EchoBidirectional": kitex.NewMethodInfo(echoBidirectionalHandler, newStreamOnlyServiceEchoBidirectionalArgs, newStreamOnlyServiceEchoBidirectionalResult, false), + "EchoBidirectionalNew": kitex.NewMethodInfo(echoBidirectionalNewHandler, newStreamOnlyServiceEchoBidirectionalNewArgs, newStreamOnlyServiceEchoBidirectionalNewResult, false), } extra := map[string]interface{}{ "PackageName": "echo", @@ -36,22 +36,22 @@ func NewServiceInfo() *kitex.ServiceInfo { return svcInfo } -func echoBidirectionalHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - realArg := arg.(*echo.StreamOnlyServiceEchoBidirectionalArgs) - realResult := result.(*echo.StreamOnlyServiceEchoBidirectionalResult) - success, err := handler.(echo.StreamOnlyService).EchoBidirectional(ctx, realArg.Req1) +func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.StreamOnlyServiceEchoBidirectionalNewArgs) + realResult := result.(*echo.StreamOnlyServiceEchoBidirectionalNewResult) + success, err := handler.(echo.StreamOnlyService).EchoBidirectionalNew(ctx, realArg.Req1) if err != nil { return err } realResult.Success = success return nil } -func newStreamOnlyServiceEchoBidirectionalArgs() interface{} { - return echo.NewStreamOnlyServiceEchoBidirectionalArgs() +func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() } -func newStreamOnlyServiceEchoBidirectionalResult() interface{} { - return echo.NewStreamOnlyServiceEchoBidirectionalResult() +func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() } type kClient struct { @@ -64,11 +64,11 @@ func newServiceClient(c client.Client) *kClient { } } -func (p *kClient) EchoBidirectional(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { - var _args echo.StreamOnlyServiceEchoBidirectionalArgs +func (p *kClient) EchoBidirectionalNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.StreamOnlyServiceEchoBidirectionalNewArgs _args.Req1 = req1 - var _result echo.StreamOnlyServiceEchoBidirectionalResult - if err = p.c.Call(ctx, "EchoBidirectional", &_args, &_result); err != nil { + var _result echo.StreamOnlyServiceEchoBidirectionalNewResult + if err = p.c.Call(ctx, "EchoBidirectionalNew", &_args, &_result); err != nil { return } return _result.GetSuccess(), nil diff --git a/thrift_streaming/kitex_gen_old/echo/streamonlyservicechild/client.go b/thrift_streaming/kitex_gen_old/echo/streamonlyservicechild/client.go new file mode 100644 index 0000000..9ed9473 --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/streamonlyservicechild/client.go @@ -0,0 +1,49 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoBidirectionalNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfo(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceChildClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceChildClient struct { + *kClient +} + +func (p *kStreamOnlyServiceChildClient) EchoBidirectionalNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoBidirectionalNew(ctx, req1) +} diff --git a/thrift_streaming/kitex_gen_old/echo/streamonlyservicechild/invoker.go b/thrift_streaming/kitex_gen_old/echo/streamonlyservicechild/invoker.go new file mode 100644 index 0000000..e071248 --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/streamonlyservicechild/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.StreamOnlyServiceChild, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_old/echo/streamonlyservicechild/server.go b/thrift_streaming/kitex_gen_old/echo/streamonlyservicechild/server.go new file mode 100644 index 0000000..dc04f64 --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/streamonlyservicechild/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package streamonlyservicechild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.StreamOnlyServiceChild, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_old/echo/streamonlyservicechild/streamonlyservicechild.go b/thrift_streaming/kitex_gen_old/echo/streamonlyservicechild/streamonlyservicechild.go new file mode 100644 index 0000000..2b4753c --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/streamonlyservicechild/streamonlyservicechild.go @@ -0,0 +1,75 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +func serviceInfo() *kitex.ServiceInfo { + return streamOnlyServiceChildServiceInfo +} + +var streamOnlyServiceChildServiceInfo = NewServiceInfo() + +func NewServiceInfo() *kitex.ServiceInfo { + serviceName := "StreamOnlyServiceChild" + handlerType := (*echo.StreamOnlyServiceChild)(nil) + methods := map[string]kitex.MethodInfo{ + "EchoBidirectionalNew": kitex.NewMethodInfo(echoBidirectionalNewHandler, newStreamOnlyServiceEchoBidirectionalNewArgs, newStreamOnlyServiceEchoBidirectionalNewResult, false), + } + extra := map[string]interface{}{ + "PackageName": "echo", + "ServiceFilePath": `idl/api.thrift`, + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.StreamOnlyServiceEchoBidirectionalNewArgs) + realResult := result.(*echo.StreamOnlyServiceEchoBidirectionalNewResult) + success, err := handler.(echo.StreamOnlyService).EchoBidirectionalNew(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() +} + +func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoBidirectionalNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.StreamOnlyServiceEchoBidirectionalNewArgs + _args.Req1 = req1 + var _result echo.StreamOnlyServiceEchoBidirectionalNewResult + if err = p.c.Call(ctx, "EchoBidirectionalNew", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen_old/echo/streamonlyservicechildchild/client.go b/thrift_streaming/kitex_gen_old/echo/streamonlyservicechildchild/client.go new file mode 100644 index 0000000..33591df --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/streamonlyservicechildchild/client.go @@ -0,0 +1,49 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechildchild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoBidirectionalNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfo(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceChildChildClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceChildChildClient struct { + *kClient +} + +func (p *kStreamOnlyServiceChildChildClient) EchoBidirectionalNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoBidirectionalNew(ctx, req1) +} diff --git a/thrift_streaming/kitex_gen_old/echo/streamonlyservicechildchild/invoker.go b/thrift_streaming/kitex_gen_old/echo/streamonlyservicechildchild/invoker.go new file mode 100644 index 0000000..ab23e95 --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/streamonlyservicechildchild/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechildchild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.StreamOnlyServiceChildChild, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_old/echo/streamonlyservicechildchild/server.go b/thrift_streaming/kitex_gen_old/echo/streamonlyservicechildchild/server.go new file mode 100644 index 0000000..f7a9da6 --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/streamonlyservicechildchild/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package streamonlyservicechildchild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.StreamOnlyServiceChildChild, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_old/echo/streamonlyservicechildchild/streamonlyservicechildchild.go b/thrift_streaming/kitex_gen_old/echo/streamonlyservicechildchild/streamonlyservicechildchild.go new file mode 100644 index 0000000..7b8bc87 --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/streamonlyservicechildchild/streamonlyservicechildchild.go @@ -0,0 +1,75 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechildchild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +func serviceInfo() *kitex.ServiceInfo { + return streamOnlyServiceChildChildServiceInfo +} + +var streamOnlyServiceChildChildServiceInfo = NewServiceInfo() + +func NewServiceInfo() *kitex.ServiceInfo { + serviceName := "StreamOnlyServiceChildChild" + handlerType := (*echo.StreamOnlyServiceChildChild)(nil) + methods := map[string]kitex.MethodInfo{ + "EchoBidirectionalNew": kitex.NewMethodInfo(echoBidirectionalNewHandler, newStreamOnlyServiceEchoBidirectionalNewArgs, newStreamOnlyServiceEchoBidirectionalNewResult, false), + } + extra := map[string]interface{}{ + "PackageName": "echo", + "ServiceFilePath": `idl/api.thrift`, + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.StreamOnlyServiceEchoBidirectionalNewArgs) + realResult := result.(*echo.StreamOnlyServiceEchoBidirectionalNewResult) + success, err := handler.(echo.StreamOnlyService).EchoBidirectionalNew(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() +} + +func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoBidirectionalNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.StreamOnlyServiceEchoBidirectionalNewArgs + _args.Req1 = req1 + var _result echo.StreamOnlyServiceEchoBidirectionalNewResult + if err = p.c.Call(ctx, "EchoBidirectionalNew", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/a/a.go b/thrift_streaming/kitex_gen_slim/combine_extend/a/a.go new file mode 100644 index 0000000..e97fd72 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine_extend/a/a.go @@ -0,0 +1,126 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package a + +import ( + "context" + "errors" + combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/combine_extend" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoPingPongNew": kitex.NewMethodInfo( + echoPingPongNewHandler, + newPingPongOnlyServiceEchoPingPongNewArgs, + newPingPongOnlyServiceEchoPingPongNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), +} + +var ( + aServiceInfo = NewServiceInfo() + aServiceInfoForClient = NewServiceInfoForClient() + aServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return aServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return aServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return aServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "A" + handlerType := (*combine_extend.A)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "combine_extend", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() +} + +func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongNewArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceEchoPingPongNewResult + if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/a/client.go b/thrift_streaming/kitex_gen_slim/combine_extend/a/client.go new file mode 100644 index 0000000..afa1d63 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine_extend/a/client.go @@ -0,0 +1,49 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package a + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kAClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kAClient struct { + *kClient +} + +func (p *kAClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPongNew(ctx, req1) +} diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/a/invoker.go b/thrift_streaming/kitex_gen_slim/combine_extend/a/invoker.go new file mode 100644 index 0000000..6a401eb --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine_extend/a/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package a + +import ( + combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/combine_extend" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler combine_extend.A, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/a/server.go b/thrift_streaming/kitex_gen_slim/combine_extend/a/server.go new file mode 100644 index 0000000..e0142ae --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine_extend/a/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package a + +import ( + combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/combine_extend" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler combine_extend.A, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/b/b.go b/thrift_streaming/kitex_gen_slim/combine_extend/b/b.go new file mode 100644 index 0000000..a06b21d --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine_extend/b/b.go @@ -0,0 +1,156 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package b + +import ( + "context" + "errors" + "fmt" + combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/combine_extend" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoBidirectionalNew": kitex.NewMethodInfo( + echoBidirectionalNewHandler, + newStreamOnlyServiceEchoBidirectionalNewArgs, + newStreamOnlyServiceEchoBidirectionalNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + bServiceInfo = NewServiceInfo() + bServiceInfoForClient = NewServiceInfoForClient() + bServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return bServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return bServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return bServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "B" + handlerType := (*combine_extend.B)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "combine_extend", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("StreamOnlyService.EchoBidirectionalNew is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &streamOnlyServiceEchoBidirectionalNewServer{st.Stream} + return handler.(echo.StreamOnlyService).EchoBidirectionalNew(stream) +} + +type streamOnlyServiceEchoBidirectionalNewClient struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *streamOnlyServiceEchoBidirectionalNewClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type streamOnlyServiceEchoBidirectionalNewServer struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() +} + +func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoBidirectionalNew(ctx context.Context) (StreamOnlyService_EchoBidirectionalNewClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectionalNew", nil, res) + if err != nil { + return nil, err + } + stream := &streamOnlyServiceEchoBidirectionalNewClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/b/client.go b/thrift_streaming/kitex_gen_slim/combine_extend/b/client.go new file mode 100644 index 0000000..4ebfd2f --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine_extend/b/client.go @@ -0,0 +1,92 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package b + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + client "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) +} + +type StreamOnlyService_EchoBidirectionalNewClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kBClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kBClient struct { + *kClient +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kBStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kBStreamClient struct { + *kClient +} + +func (p *kBStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalNew(ctx) +} diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/b/invoker.go b/thrift_streaming/kitex_gen_slim/combine_extend/b/invoker.go new file mode 100644 index 0000000..500faa1 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine_extend/b/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package b + +import ( + combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/combine_extend" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler combine_extend.B, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/b/server.go b/thrift_streaming/kitex_gen_slim/combine_extend/b/server.go new file mode 100644 index 0000000..fd7b467 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine_extend/b/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package b + +import ( + combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/combine_extend" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler combine_extend.B, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/combine_extend.go b/thrift_streaming/kitex_gen_slim/combine_extend/combine_extend.go new file mode 100644 index 0000000..5ad4ba6 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine_extend/combine_extend.go @@ -0,0 +1,15 @@ +// Code generated by thriftgo (0.3.5). DO NOT EDIT. + +package combine_extend + +import ( + "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" +) + +type A interface { + echo.PingPongOnlyService +} + +type B interface { + echo.StreamOnlyServiceChildChild +} diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/client.go b/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/client.go new file mode 100644 index 0000000..c297e43 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/client.go @@ -0,0 +1,99 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combineservice + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) +} + +type StreamOnlyService_EchoBidirectionalNewClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kCombineServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kCombineServiceClient struct { + *kClient +} + +func (p *kCombineServiceClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPongNew(ctx, req1) +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kCombineServiceStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kCombineServiceStreamClient struct { + *kClient +} + +func (p *kCombineServiceStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalNew(ctx) +} diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/combineservice.go b/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/combineservice.go new file mode 100644 index 0000000..9a1ef94 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/combineservice.go @@ -0,0 +1,198 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combineservice + +import ( + "context" + "errors" + "fmt" + combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/combine_extend" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +type CombineService interface { + combine_extend.A + combine_extend.B +} + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoPingPongNew": kitex.NewMethodInfo( + echoPingPongNewHandler, + newPingPongOnlyServiceEchoPingPongNewArgs, + newPingPongOnlyServiceEchoPingPongNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "EchoBidirectionalNew": kitex.NewMethodInfo( + echoBidirectionalNewHandler, + newStreamOnlyServiceEchoBidirectionalNewArgs, + newStreamOnlyServiceEchoBidirectionalNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + combineServiceServiceInfo = NewServiceInfo() + combineServiceServiceInfoForClient = NewServiceInfoForClient() + combineServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return combineServiceServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return combineServiceServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return combineServiceServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "CombineService" + handlerType := (*CombineService)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "combine_extend", + } + extra["combine_service"] = true + extra["combined_service_list"] = []string{"A", "B"} + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() +} + +func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewResult() +} + +func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("StreamOnlyService.EchoBidirectionalNew is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &streamOnlyServiceEchoBidirectionalNewServer{st.Stream} + return handler.(echo.StreamOnlyService).EchoBidirectionalNew(stream) +} + +type streamOnlyServiceEchoBidirectionalNewClient struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *streamOnlyServiceEchoBidirectionalNewClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type streamOnlyServiceEchoBidirectionalNewServer struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() +} + +func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongNewArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceEchoPingPongNewResult + if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) EchoBidirectionalNew(ctx context.Context) (StreamOnlyService_EchoBidirectionalNewClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectionalNew", nil, res) + if err != nil { + return nil, err + } + stream := &streamOnlyServiceEchoBidirectionalNewClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/invoker.go b/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/invoker.go new file mode 100644 index 0000000..5605702 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/invoker.go @@ -0,0 +1,23 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combineservice + +import ( + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler CombineService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/server.go b/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/server.go new file mode 100644 index 0000000..39f663b --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package combineservice + +import ( + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler CombineService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/k-combine_extend.go b/thrift_streaming/kitex_gen_slim/combine_extend/k-combine_extend.go new file mode 100644 index 0000000..9066e5b --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine_extend/k-combine_extend.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combine_extend + +import ( + "bytes" + "fmt" + "reflect" + "strings" + + "github.com/apache/thrift/lib/go/thrift" + + "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" +) + +// unused protection +var ( + _ = fmt.Formatter(nil) + _ = (*bytes.Buffer)(nil) + _ = (*strings.Builder)(nil) + _ = reflect.Type(nil) + _ = thrift.TProtocol(nil) + _ = echo.KitexUnusedProtection +) diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/k-consts.go b/thrift_streaming/kitex_gen_slim/combine_extend/k-consts.go new file mode 100644 index 0000000..8e5ff02 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/combine_extend/k-consts.go @@ -0,0 +1,4 @@ +package combine_extend + +// KitexUnusedProtection is used to prevent 'imported and not used' error. +var KitexUnusedProtection = struct{}{} diff --git a/thrift_streaming/kitex_gen_slim/echo/api.go b/thrift_streaming/kitex_gen_slim/echo/api.go index 6dd1ccf..55ab800 100644 --- a/thrift_streaming/kitex_gen_slim/echo/api.go +++ b/thrift_streaming/kitex_gen_slim/echo/api.go @@ -126,14 +126,32 @@ type EchoService_EchoServerServer interface { } type PingPongOnlyService interface { - EchoPingPong(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) + EchoPingPongNew(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) +} + +type PingPongOnlyServiceChild interface { + PingPongOnlyService + + EchoBidirectionalExtended(stream PingPongOnlyServiceChild_EchoBidirectionalExtendedServer) (err error) +} + +type PingPongOnlyServiceChild_EchoBidirectionalExtendedServer interface { + streaming.Stream + + Recv() (*EchoRequest, error) + + Send(*EchoResponse) error +} + +type PingPongOnlyServiceChildChild interface { + PingPongOnlyServiceChild } type StreamOnlyService interface { - EchoBidirectional(stream StreamOnlyService_EchoBidirectionalServer) (err error) + EchoBidirectionalNew(stream StreamOnlyService_EchoBidirectionalNewServer) (err error) } -type StreamOnlyService_EchoBidirectionalServer interface { +type StreamOnlyService_EchoBidirectionalNewServer interface { streaming.Stream Recv() (*EchoRequest, error) @@ -141,6 +159,14 @@ type StreamOnlyService_EchoBidirectionalServer interface { Send(*EchoResponse) error } +type StreamOnlyServiceChild interface { + StreamOnlyService +} + +type StreamOnlyServiceChildChild interface { + StreamOnlyServiceChild +} + // exceptions of methods in EchoService. var ( _ error = (*EchoException)(nil) diff --git a/thrift_streaming/kitex_gen_slim/echo/k-api.go b/thrift_streaming/kitex_gen_slim/echo/k-api.go index 5a77980..c91af16 100644 --- a/thrift_streaming/kitex_gen_slim/echo/k-api.go +++ b/thrift_streaming/kitex_gen_slim/echo/k-api.go @@ -535,154 +535,230 @@ func (p *EchoServicePingResult) GetResult() interface{} { return nil } -type PingPongOnlyServiceEchoPingPongArgs struct { +type PingPongOnlyServiceEchoPingPongNewArgs struct { Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` } -func NewPingPongOnlyServiceEchoPingPongArgs() *PingPongOnlyServiceEchoPingPongArgs { - return &PingPongOnlyServiceEchoPingPongArgs{} +func NewPingPongOnlyServiceEchoPingPongNewArgs() *PingPongOnlyServiceEchoPingPongNewArgs { + return &PingPongOnlyServiceEchoPingPongNewArgs{} } -func (p *PingPongOnlyServiceEchoPingPongArgs) InitDefault() { - *p = PingPongOnlyServiceEchoPingPongArgs{} +func (p *PingPongOnlyServiceEchoPingPongNewArgs) InitDefault() { + *p = PingPongOnlyServiceEchoPingPongNewArgs{} } -var PingPongOnlyServiceEchoPingPongArgs_Req1_DEFAULT *EchoRequest +var PingPongOnlyServiceEchoPingPongNewArgs_Req1_DEFAULT *EchoRequest -func (p *PingPongOnlyServiceEchoPingPongArgs) GetReq1() (v *EchoRequest) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) GetReq1() (v *EchoRequest) { if !p.IsSetReq1() { - return PingPongOnlyServiceEchoPingPongArgs_Req1_DEFAULT + return PingPongOnlyServiceEchoPingPongNewArgs_Req1_DEFAULT } return p.Req1 } -func (p *PingPongOnlyServiceEchoPingPongArgs) SetReq1(val *EchoRequest) { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) SetReq1(val *EchoRequest) { p.Req1 = val } -func (p *PingPongOnlyServiceEchoPingPongArgs) IsSetReq1() bool { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) IsSetReq1() bool { return p.Req1 != nil } -func (p *PingPongOnlyServiceEchoPingPongArgs) String() string { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) String() string { if p == nil { return "" } - return fmt.Sprintf("PingPongOnlyServiceEchoPingPongArgs(%+v)", *p) + return fmt.Sprintf("PingPongOnlyServiceEchoPingPongNewArgs(%+v)", *p) } -func (p *PingPongOnlyServiceEchoPingPongArgs) GetFirstArgument() interface{} { +func (p *PingPongOnlyServiceEchoPingPongNewArgs) GetFirstArgument() interface{} { return p.Req1 } -type PingPongOnlyServiceEchoPingPongResult struct { +type PingPongOnlyServiceEchoPingPongNewResult struct { Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` } -func NewPingPongOnlyServiceEchoPingPongResult() *PingPongOnlyServiceEchoPingPongResult { - return &PingPongOnlyServiceEchoPingPongResult{} +func NewPingPongOnlyServiceEchoPingPongNewResult() *PingPongOnlyServiceEchoPingPongNewResult { + return &PingPongOnlyServiceEchoPingPongNewResult{} } -func (p *PingPongOnlyServiceEchoPingPongResult) InitDefault() { - *p = PingPongOnlyServiceEchoPingPongResult{} +func (p *PingPongOnlyServiceEchoPingPongNewResult) InitDefault() { + *p = PingPongOnlyServiceEchoPingPongNewResult{} } -var PingPongOnlyServiceEchoPingPongResult_Success_DEFAULT *EchoResponse +var PingPongOnlyServiceEchoPingPongNewResult_Success_DEFAULT *EchoResponse -func (p *PingPongOnlyServiceEchoPingPongResult) GetSuccess() (v *EchoResponse) { +func (p *PingPongOnlyServiceEchoPingPongNewResult) GetSuccess() (v *EchoResponse) { if !p.IsSetSuccess() { - return PingPongOnlyServiceEchoPingPongResult_Success_DEFAULT + return PingPongOnlyServiceEchoPingPongNewResult_Success_DEFAULT } return p.Success } -func (p *PingPongOnlyServiceEchoPingPongResult) SetSuccess(x interface{}) { +func (p *PingPongOnlyServiceEchoPingPongNewResult) SetSuccess(x interface{}) { p.Success = x.(*EchoResponse) } -func (p *PingPongOnlyServiceEchoPingPongResult) IsSetSuccess() bool { +func (p *PingPongOnlyServiceEchoPingPongNewResult) IsSetSuccess() bool { return p.Success != nil } -func (p *PingPongOnlyServiceEchoPingPongResult) String() string { +func (p *PingPongOnlyServiceEchoPingPongNewResult) String() string { if p == nil { return "" } - return fmt.Sprintf("PingPongOnlyServiceEchoPingPongResult(%+v)", *p) + return fmt.Sprintf("PingPongOnlyServiceEchoPingPongNewResult(%+v)", *p) } -func (p *PingPongOnlyServiceEchoPingPongResult) GetResult() interface{} { +func (p *PingPongOnlyServiceEchoPingPongNewResult) GetResult() interface{} { return p.Success } -type StreamOnlyServiceEchoBidirectionalArgs struct { +type PingPongOnlyServiceChildEchoBidirectionalExtendedArgs struct { Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` } -func NewStreamOnlyServiceEchoBidirectionalArgs() *StreamOnlyServiceEchoBidirectionalArgs { - return &StreamOnlyServiceEchoBidirectionalArgs{} +func NewPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs { + return &PingPongOnlyServiceChildEchoBidirectionalExtendedArgs{} } -func (p *StreamOnlyServiceEchoBidirectionalArgs) InitDefault() { - *p = StreamOnlyServiceEchoBidirectionalArgs{} +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) InitDefault() { + *p = PingPongOnlyServiceChildEchoBidirectionalExtendedArgs{} } -var StreamOnlyServiceEchoBidirectionalArgs_Req1_DEFAULT *EchoRequest +var PingPongOnlyServiceChildEchoBidirectionalExtendedArgs_Req1_DEFAULT *EchoRequest -func (p *StreamOnlyServiceEchoBidirectionalArgs) GetReq1() (v *EchoRequest) { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) GetReq1() (v *EchoRequest) { if !p.IsSetReq1() { - return StreamOnlyServiceEchoBidirectionalArgs_Req1_DEFAULT + return PingPongOnlyServiceChildEchoBidirectionalExtendedArgs_Req1_DEFAULT } return p.Req1 } -func (p *StreamOnlyServiceEchoBidirectionalArgs) SetReq1(val *EchoRequest) { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) SetReq1(val *EchoRequest) { p.Req1 = val } -func (p *StreamOnlyServiceEchoBidirectionalArgs) IsSetReq1() bool { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) IsSetReq1() bool { return p.Req1 != nil } -func (p *StreamOnlyServiceEchoBidirectionalArgs) String() string { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) String() string { if p == nil { return "" } - return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalArgs(%+v)", *p) + return fmt.Sprintf("PingPongOnlyServiceChildEchoBidirectionalExtendedArgs(%+v)", *p) } -func (p *StreamOnlyServiceEchoBidirectionalArgs) GetFirstArgument() interface{} { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) GetFirstArgument() interface{} { return p.Req1 } -type StreamOnlyServiceEchoBidirectionalResult struct { +type PingPongOnlyServiceChildEchoBidirectionalExtendedResult struct { Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` } -func NewStreamOnlyServiceEchoBidirectionalResult() *StreamOnlyServiceEchoBidirectionalResult { - return &StreamOnlyServiceEchoBidirectionalResult{} +func NewPingPongOnlyServiceChildEchoBidirectionalExtendedResult() *PingPongOnlyServiceChildEchoBidirectionalExtendedResult { + return &PingPongOnlyServiceChildEchoBidirectionalExtendedResult{} } -func (p *StreamOnlyServiceEchoBidirectionalResult) InitDefault() { - *p = StreamOnlyServiceEchoBidirectionalResult{} +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) InitDefault() { + *p = PingPongOnlyServiceChildEchoBidirectionalExtendedResult{} } -var StreamOnlyServiceEchoBidirectionalResult_Success_DEFAULT *EchoResponse +var PingPongOnlyServiceChildEchoBidirectionalExtendedResult_Success_DEFAULT *EchoResponse -func (p *StreamOnlyServiceEchoBidirectionalResult) GetSuccess() (v *EchoResponse) { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) GetSuccess() (v *EchoResponse) { if !p.IsSetSuccess() { - return StreamOnlyServiceEchoBidirectionalResult_Success_DEFAULT + return PingPongOnlyServiceChildEchoBidirectionalExtendedResult_Success_DEFAULT } return p.Success } -func (p *StreamOnlyServiceEchoBidirectionalResult) SetSuccess(x interface{}) { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) SetSuccess(x interface{}) { p.Success = x.(*EchoResponse) } -func (p *StreamOnlyServiceEchoBidirectionalResult) IsSetSuccess() bool { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) IsSetSuccess() bool { return p.Success != nil } -func (p *StreamOnlyServiceEchoBidirectionalResult) String() string { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) String() string { if p == nil { return "" } - return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalResult(%+v)", *p) + return fmt.Sprintf("PingPongOnlyServiceChildEchoBidirectionalExtendedResult(%+v)", *p) } -func (p *StreamOnlyServiceEchoBidirectionalResult) GetResult() interface{} { +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) GetResult() interface{} { + return p.Success +} + +type StreamOnlyServiceEchoBidirectionalNewArgs struct { + Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` +} + +func NewStreamOnlyServiceEchoBidirectionalNewArgs() *StreamOnlyServiceEchoBidirectionalNewArgs { + return &StreamOnlyServiceEchoBidirectionalNewArgs{} +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) InitDefault() { + *p = StreamOnlyServiceEchoBidirectionalNewArgs{} +} + +var StreamOnlyServiceEchoBidirectionalNewArgs_Req1_DEFAULT *EchoRequest + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) GetReq1() (v *EchoRequest) { + if !p.IsSetReq1() { + return StreamOnlyServiceEchoBidirectionalNewArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) SetReq1(val *EchoRequest) { + p.Req1 = val +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalNewArgs(%+v)", *p) +} +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +type StreamOnlyServiceEchoBidirectionalNewResult struct { + Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` +} + +func NewStreamOnlyServiceEchoBidirectionalNewResult() *StreamOnlyServiceEchoBidirectionalNewResult { + return &StreamOnlyServiceEchoBidirectionalNewResult{} +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) InitDefault() { + *p = StreamOnlyServiceEchoBidirectionalNewResult{} +} + +var StreamOnlyServiceEchoBidirectionalNewResult_Success_DEFAULT *EchoResponse + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) GetSuccess() (v *EchoResponse) { + if !p.IsSetSuccess() { + return StreamOnlyServiceEchoBidirectionalNewResult_Success_DEFAULT + } + return p.Success +} +func (p *StreamOnlyServiceEchoBidirectionalNewResult) SetSuccess(x interface{}) { + p.Success = x.(*EchoResponse) +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalNewResult(%+v)", *p) +} +func (p *StreamOnlyServiceEchoBidirectionalNewResult) GetResult() interface{} { return p.Success } diff --git a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/client.go b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/client.go index ac9f6f8..fa1ebe9 100644 --- a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/client.go +++ b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/client.go @@ -11,7 +11,7 @@ import ( // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. type Client interface { - EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) + EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) } // NewClient creates a client for the service defined in IDL. @@ -43,7 +43,7 @@ type kPingPongOnlyServiceClient struct { *kClient } -func (p *kPingPongOnlyServiceClient) EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { +func (p *kPingPongOnlyServiceClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.EchoPingPong(ctx, req1) + return p.kClient.EchoPingPongNew(ctx, req1) } diff --git a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/pingpongonlyservice.go b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/pingpongonlyservice.go index 1c8ada6..8125a3c 100644 --- a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/pingpongonlyservice.go +++ b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservice/pingpongonlyservice.go @@ -13,10 +13,10 @@ import ( var errInvalidMessageType = errors.New("invalid message type for service method handler") var serviceMethods = map[string]kitex.MethodInfo{ - "EchoPingPong": kitex.NewMethodInfo( - echoPingPongHandler, - newPingPongOnlyServiceEchoPingPongArgs, - newPingPongOnlyServiceEchoPingPongResult, + "EchoPingPongNew": kitex.NewMethodInfo( + echoPingPongNewHandler, + newPingPongOnlyServiceEchoPingPongNewArgs, + newPingPongOnlyServiceEchoPingPongNewResult, false, kitex.WithStreamingMode(kitex.StreamingNone), ), @@ -86,22 +86,22 @@ func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreami return svcInfo } -func echoPingPongHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongArgs) - realResult := result.(*echo.PingPongOnlyServiceEchoPingPongResult) - success, err := handler.(echo.PingPongOnlyService).EchoPingPong(ctx, realArg.Req1) +func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) if err != nil { return err } realResult.Success = success return nil } -func newPingPongOnlyServiceEchoPingPongArgs() interface{} { - return echo.NewPingPongOnlyServiceEchoPingPongArgs() +func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() } -func newPingPongOnlyServiceEchoPingPongResult() interface{} { - return echo.NewPingPongOnlyServiceEchoPingPongResult() +func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewResult() } type kClient struct { @@ -114,11 +114,11 @@ func newServiceClient(c client.Client) *kClient { } } -func (p *kClient) EchoPingPong(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { - var _args echo.PingPongOnlyServiceEchoPingPongArgs +func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongNewArgs _args.Req1 = req1 - var _result echo.PingPongOnlyServiceEchoPingPongResult - if err = p.c.Call(ctx, "EchoPingPong", &_args, &_result); err != nil { + var _result echo.PingPongOnlyServiceEchoPingPongNewResult + if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { return } return _result.GetSuccess(), nil diff --git a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechild/client.go b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechild/client.go new file mode 100644 index 0000000..82f48eb --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechild/client.go @@ -0,0 +1,99 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalExtended(ctx context.Context, callOptions ...streamcall.Option) (stream PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, err error) +} + +type PingPongOnlyServiceChild_EchoBidirectionalExtendedClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceChildClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceChildClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceChildClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPongNew(ctx, req1) +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceChildStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceChildStreamClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceChildStreamClient) EchoBidirectionalExtended(ctx context.Context, callOptions ...streamcall.Option) (stream PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalExtended(ctx) +} diff --git a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechild/invoker.go b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechild/invoker.go new file mode 100644 index 0000000..e964ffe --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechild/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.PingPongOnlyServiceChild, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechild/pingpongonlyservicechild.go b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechild/pingpongonlyservicechild.go new file mode 100644 index 0000000..66c3709 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechild/pingpongonlyservicechild.go @@ -0,0 +1,190 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechild + +import ( + "context" + "errors" + "fmt" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoPingPongNew": kitex.NewMethodInfo( + echoPingPongNewHandler, + newPingPongOnlyServiceEchoPingPongNewArgs, + newPingPongOnlyServiceEchoPingPongNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "EchoBidirectionalExtended": kitex.NewMethodInfo( + echoBidirectionalExtendedHandler, + newPingPongOnlyServiceChildEchoBidirectionalExtendedArgs, + newPingPongOnlyServiceChildEchoBidirectionalExtendedResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + pingPongOnlyServiceChildServiceInfo = NewServiceInfo() + pingPongOnlyServiceChildServiceInfoForClient = NewServiceInfoForClient() + pingPongOnlyServiceChildServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return pingPongOnlyServiceChildServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return pingPongOnlyServiceChildServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return pingPongOnlyServiceChildServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "PingPongOnlyServiceChild" + handlerType := (*echo.PingPongOnlyServiceChild)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "echo", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() +} + +func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewResult() +} + +func echoBidirectionalExtendedHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("PingPongOnlyServiceChild.EchoBidirectionalExtended is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &pingPongOnlyServiceChildEchoBidirectionalExtendedServer{st.Stream} + return handler.(echo.PingPongOnlyServiceChild).EchoBidirectionalExtended(stream) +} + +type pingPongOnlyServiceChildEchoBidirectionalExtendedClient struct { + streaming.Stream +} + +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type pingPongOnlyServiceChildEchoBidirectionalExtendedServer struct { + streaming.Stream +} + +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() interface{} { + return echo.NewPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() +} + +func newPingPongOnlyServiceChildEchoBidirectionalExtendedResult() interface{} { + return echo.NewPingPongOnlyServiceChildEchoBidirectionalExtendedResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongNewArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceEchoPingPongNewResult + if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) EchoBidirectionalExtended(ctx context.Context) (PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectionalExtended", nil, res) + if err != nil { + return nil, err + } + stream := &pingPongOnlyServiceChildEchoBidirectionalExtendedClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechild/server.go b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechild/server.go new file mode 100644 index 0000000..e552eed --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechild/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package pingpongonlyservicechild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.PingPongOnlyServiceChild, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/client.go b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/client.go new file mode 100644 index 0000000..95c27e7 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/client.go @@ -0,0 +1,99 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechildchild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalExtended(ctx context.Context, callOptions ...streamcall.Option) (stream PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, err error) +} + +type PingPongOnlyServiceChild_EchoBidirectionalExtendedClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceChildChildClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceChildChildClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceChildChildClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPongNew(ctx, req1) +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceChildChildStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceChildChildStreamClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceChildChildStreamClient) EchoBidirectionalExtended(ctx context.Context, callOptions ...streamcall.Option) (stream PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalExtended(ctx) +} diff --git a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/invoker.go b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/invoker.go new file mode 100644 index 0000000..cffb1aa --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechildchild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.PingPongOnlyServiceChildChild, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go new file mode 100644 index 0000000..927e9f3 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go @@ -0,0 +1,190 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechildchild + +import ( + "context" + "errors" + "fmt" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoPingPongNew": kitex.NewMethodInfo( + echoPingPongNewHandler, + newPingPongOnlyServiceEchoPingPongNewArgs, + newPingPongOnlyServiceEchoPingPongNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "EchoBidirectionalExtended": kitex.NewMethodInfo( + echoBidirectionalExtendedHandler, + newPingPongOnlyServiceChildEchoBidirectionalExtendedArgs, + newPingPongOnlyServiceChildEchoBidirectionalExtendedResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + pingPongOnlyServiceChildChildServiceInfo = NewServiceInfo() + pingPongOnlyServiceChildChildServiceInfoForClient = NewServiceInfoForClient() + pingPongOnlyServiceChildChildServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return pingPongOnlyServiceChildChildServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return pingPongOnlyServiceChildChildServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return pingPongOnlyServiceChildChildServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "PingPongOnlyServiceChildChild" + handlerType := (*echo.PingPongOnlyServiceChildChild)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "echo", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() +} + +func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewResult() +} + +func echoBidirectionalExtendedHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("PingPongOnlyServiceChild.EchoBidirectionalExtended is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &pingPongOnlyServiceChildEchoBidirectionalExtendedServer{st.Stream} + return handler.(echo.PingPongOnlyServiceChild).EchoBidirectionalExtended(stream) +} + +type pingPongOnlyServiceChildEchoBidirectionalExtendedClient struct { + streaming.Stream +} + +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type pingPongOnlyServiceChildEchoBidirectionalExtendedServer struct { + streaming.Stream +} + +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() interface{} { + return echo.NewPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() +} + +func newPingPongOnlyServiceChildEchoBidirectionalExtendedResult() interface{} { + return echo.NewPingPongOnlyServiceChildEchoBidirectionalExtendedResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongNewArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceEchoPingPongNewResult + if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) EchoBidirectionalExtended(ctx context.Context) (PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectionalExtended", nil, res) + if err != nil { + return nil, err + } + stream := &pingPongOnlyServiceChildEchoBidirectionalExtendedClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/server.go b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/server.go new file mode 100644 index 0000000..e7fb143 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package pingpongonlyservicechildchild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.PingPongOnlyServiceChildChild, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/client.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/client.go index 618bc55..5f46814 100644 --- a/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/client.go +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/client.go @@ -18,10 +18,10 @@ type Client interface { // StreamClient is designed to provide Interface for Streaming APIs. type StreamClient interface { - EchoBidirectional(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalClient, err error) + EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) } -type StreamOnlyService_EchoBidirectionalClient interface { +type StreamOnlyService_EchoBidirectionalNewClient interface { streaming.Stream Send(*echo.EchoRequest) error Recv() (*echo.EchoResponse, error) @@ -86,7 +86,7 @@ type kStreamOnlyServiceStreamClient struct { *kClient } -func (p *kStreamOnlyServiceStreamClient) EchoBidirectional(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalClient, err error) { +func (p *kStreamOnlyServiceStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.EchoBidirectional(ctx) + return p.kClient.EchoBidirectionalNew(ctx) } diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/streamonlyservice.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/streamonlyservice.go index 6a65c23..10dcbb2 100644 --- a/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/streamonlyservice.go +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/streamonlyservice.go @@ -15,10 +15,10 @@ import ( var errInvalidMessageType = errors.New("invalid message type for service method handler") var serviceMethods = map[string]kitex.MethodInfo{ - "EchoBidirectional": kitex.NewMethodInfo( - echoBidirectionalHandler, - newStreamOnlyServiceEchoBidirectionalArgs, - newStreamOnlyServiceEchoBidirectionalResult, + "EchoBidirectionalNew": kitex.NewMethodInfo( + echoBidirectionalNewHandler, + newStreamOnlyServiceEchoBidirectionalNewArgs, + newStreamOnlyServiceEchoBidirectionalNewResult, false, kitex.WithStreamingMode(kitex.StreamingBidirectional), ), @@ -88,46 +88,46 @@ func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreami return svcInfo } -func echoBidirectionalHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { +func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { st, ok := arg.(*streaming.Args) if !ok { - return errors.New("StreamOnlyService.EchoBidirectional is a thrift streaming method, please call with Kitex StreamClient") + return errors.New("StreamOnlyService.EchoBidirectionalNew is a thrift streaming method, please call with Kitex StreamClient") } - stream := &streamOnlyServiceEchoBidirectionalServer{st.Stream} - return handler.(echo.StreamOnlyService).EchoBidirectional(stream) + stream := &streamOnlyServiceEchoBidirectionalNewServer{st.Stream} + return handler.(echo.StreamOnlyService).EchoBidirectionalNew(stream) } -type streamOnlyServiceEchoBidirectionalClient struct { +type streamOnlyServiceEchoBidirectionalNewClient struct { streaming.Stream } -func (x *streamOnlyServiceEchoBidirectionalClient) Send(m *echo.EchoRequest) error { +func (x *streamOnlyServiceEchoBidirectionalNewClient) Send(m *echo.EchoRequest) error { return x.Stream.SendMsg(m) } -func (x *streamOnlyServiceEchoBidirectionalClient) Recv() (*echo.EchoResponse, error) { +func (x *streamOnlyServiceEchoBidirectionalNewClient) Recv() (*echo.EchoResponse, error) { m := new(echo.EchoResponse) return m, x.Stream.RecvMsg(m) } -type streamOnlyServiceEchoBidirectionalServer struct { +type streamOnlyServiceEchoBidirectionalNewServer struct { streaming.Stream } -func (x *streamOnlyServiceEchoBidirectionalServer) Send(m *echo.EchoResponse) error { +func (x *streamOnlyServiceEchoBidirectionalNewServer) Send(m *echo.EchoResponse) error { return x.Stream.SendMsg(m) } -func (x *streamOnlyServiceEchoBidirectionalServer) Recv() (*echo.EchoRequest, error) { +func (x *streamOnlyServiceEchoBidirectionalNewServer) Recv() (*echo.EchoRequest, error) { m := new(echo.EchoRequest) return m, x.Stream.RecvMsg(m) } -func newStreamOnlyServiceEchoBidirectionalArgs() interface{} { - return echo.NewStreamOnlyServiceEchoBidirectionalArgs() +func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() } -func newStreamOnlyServiceEchoBidirectionalResult() interface{} { - return echo.NewStreamOnlyServiceEchoBidirectionalResult() +func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() } type kClient struct { @@ -140,16 +140,16 @@ func newServiceClient(c client.Client) *kClient { } } -func (p *kClient) EchoBidirectional(ctx context.Context) (StreamOnlyService_EchoBidirectionalClient, error) { +func (p *kClient) EchoBidirectionalNew(ctx context.Context) (StreamOnlyService_EchoBidirectionalNewClient, error) { streamClient, ok := p.c.(client.Streaming) if !ok { return nil, fmt.Errorf("client not support streaming") } res := new(streaming.Result) - err := streamClient.Stream(ctx, "EchoBidirectional", nil, res) + err := streamClient.Stream(ctx, "EchoBidirectionalNew", nil, res) if err != nil { return nil, err } - stream := &streamOnlyServiceEchoBidirectionalClient{res.Stream} + stream := &streamOnlyServiceEchoBidirectionalNewClient{res.Stream} return stream, nil } diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/client.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/client.go new file mode 100644 index 0000000..6264905 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/client.go @@ -0,0 +1,92 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + client "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) +} + +type StreamOnlyService_EchoBidirectionalNewClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceChildClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceChildClient struct { + *kClient +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceChildStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceChildStreamClient struct { + *kClient +} + +func (p *kStreamOnlyServiceChildStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalNew(ctx) +} diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/invoker.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/invoker.go new file mode 100644 index 0000000..936d195 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.StreamOnlyServiceChild, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/server.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/server.go new file mode 100644 index 0000000..0d78d41 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package streamonlyservicechild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.StreamOnlyServiceChild, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/streamonlyservicechild.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/streamonlyservicechild.go new file mode 100644 index 0000000..ef1d65e --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/streamonlyservicechild.go @@ -0,0 +1,155 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechild + +import ( + "context" + "errors" + "fmt" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoBidirectionalNew": kitex.NewMethodInfo( + echoBidirectionalNewHandler, + newStreamOnlyServiceEchoBidirectionalNewArgs, + newStreamOnlyServiceEchoBidirectionalNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + streamOnlyServiceChildServiceInfo = NewServiceInfo() + streamOnlyServiceChildServiceInfoForClient = NewServiceInfoForClient() + streamOnlyServiceChildServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return streamOnlyServiceChildServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return streamOnlyServiceChildServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return streamOnlyServiceChildServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "StreamOnlyServiceChild" + handlerType := (*echo.StreamOnlyServiceChild)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "echo", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("StreamOnlyService.EchoBidirectionalNew is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &streamOnlyServiceEchoBidirectionalNewServer{st.Stream} + return handler.(echo.StreamOnlyService).EchoBidirectionalNew(stream) +} + +type streamOnlyServiceEchoBidirectionalNewClient struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *streamOnlyServiceEchoBidirectionalNewClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type streamOnlyServiceEchoBidirectionalNewServer struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() +} + +func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoBidirectionalNew(ctx context.Context) (StreamOnlyService_EchoBidirectionalNewClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectionalNew", nil, res) + if err != nil { + return nil, err + } + stream := &streamOnlyServiceEchoBidirectionalNewClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/client.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/client.go new file mode 100644 index 0000000..bfd6bbc --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/client.go @@ -0,0 +1,92 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechildchild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + client "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) +} + +type StreamOnlyService_EchoBidirectionalNewClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceChildChildClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceChildChildClient struct { + *kClient +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceChildChildStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceChildChildStreamClient struct { + *kClient +} + +func (p *kStreamOnlyServiceChildChildStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalNew(ctx) +} diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/invoker.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/invoker.go new file mode 100644 index 0000000..f7fe65f --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechildchild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.StreamOnlyServiceChildChild, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/server.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/server.go new file mode 100644 index 0000000..e8ae8e7 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package streamonlyservicechildchild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.StreamOnlyServiceChildChild, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/streamonlyservicechildchild.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/streamonlyservicechildchild.go new file mode 100644 index 0000000..fffaaa8 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/streamonlyservicechildchild.go @@ -0,0 +1,155 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechildchild + +import ( + "context" + "errors" + "fmt" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoBidirectionalNew": kitex.NewMethodInfo( + echoBidirectionalNewHandler, + newStreamOnlyServiceEchoBidirectionalNewArgs, + newStreamOnlyServiceEchoBidirectionalNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + streamOnlyServiceChildChildServiceInfo = NewServiceInfo() + streamOnlyServiceChildChildServiceInfoForClient = NewServiceInfoForClient() + streamOnlyServiceChildChildServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return streamOnlyServiceChildChildServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return streamOnlyServiceChildChildServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return streamOnlyServiceChildChildServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "StreamOnlyServiceChildChild" + handlerType := (*echo.StreamOnlyServiceChildChild)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "echo", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("StreamOnlyService.EchoBidirectionalNew is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &streamOnlyServiceEchoBidirectionalNewServer{st.Stream} + return handler.(echo.StreamOnlyService).EchoBidirectionalNew(stream) +} + +type streamOnlyServiceEchoBidirectionalNewClient struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *streamOnlyServiceEchoBidirectionalNewClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type streamOnlyServiceEchoBidirectionalNewServer struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() +} + +func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoBidirectionalNew(ctx context.Context) (StreamOnlyService_EchoBidirectionalNewClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectionalNew", nil, res) + if err != nil { + return nil, err + } + stream := &streamOnlyServiceEchoBidirectionalNewClient{res.Stream} + return stream, nil +} From 75c42335e2385ddfd9014866de9e098328088e8f Mon Sep 17 00:00:00 2001 From: YangruiEmma Date: Thu, 18 Jan 2024 10:24:25 +0800 Subject: [PATCH 5/7] feat: add kitex grpc abc test (#53) --- common/common.go | 32 + kitexgrpc/abc/abc_test.go | 67 + kitexgrpc/abc/consts/common.go | 20 + kitexgrpc/abc/servicea/main/main.go | 29 + kitexgrpc/abc/servicea/servicea.go | 114 + kitexgrpc/abc/serviceb/main/main.go | 24 + kitexgrpc/abc/serviceb/serviceb.go | 135 + kitexgrpc/abc/servicec/main/main.go | 24 + kitexgrpc/abc/servicec/servicec.go | 80 + {grpc => kitexgrpc}/compressor/grpc_client.go | 11 +- .../compressor/grpc_compressor_test.go | 13 +- {grpc => kitexgrpc}/compressor/grpc_server.go | 0 .../compressor/kitex_client.go | 0 .../compressor/kitex_server.go | 7 +- .../multi_service/multi_service_test.go | 0 .../normalcall/normalcall_test.go | 0 .../unknown_service_handler_test.go | 0 run.sh | 10 +- thrift_streaming/kitex_gen/combine/a/a.go | 125 - .../kitex_gen/combine/a/client.go | 49 - .../kitex_gen/combine/a/invoker.go | 24 - .../kitex_gen/combine/a/server.go | 21 - thrift_streaming/kitex_gen/combine/b/b.go | 155 - .../kitex_gen/combine/b/client.go | 92 - .../kitex_gen/combine/b/invoker.go | 24 - .../kitex_gen/combine/b/server.go | 21 - thrift_streaming/kitex_gen/combine/combine.go | 1251 ----- .../combine/combineservice/client.go | 99 - .../combine/combineservice/combineservice.go | 197 - .../combine/combineservice/invoker.go | 23 - .../combine/combineservice/server.go | 20 - .../kitex_gen/combine/k-combine.go | 832 --- .../kitex_gen/combine/k-consts.go | 4 - .../kitex_gen/combine_extend/a/a.go | 126 - .../kitex_gen/combine_extend/a/client.go | 49 - .../kitex_gen/combine_extend/a/invoker.go | 24 - .../kitex_gen/combine_extend/a/server.go | 21 - .../kitex_gen/combine_extend/b/b.go | 156 - .../kitex_gen/combine_extend/b/client.go | 92 - .../kitex_gen/combine_extend/b/invoker.go | 24 - .../kitex_gen/combine_extend/b/server.go | 21 - .../combine_extend/combine_extend.go | 78 - .../combine_extend/combineservice/client.go | 99 - .../combineservice/combineservice.go | 198 - .../combine_extend/combineservice/invoker.go | 23 - .../combine_extend/combineservice/server.go | 20 - .../combine_extend/k-combine_extend.go | 27 - .../kitex_gen/combine_extend/k-consts.go | 4 - thrift_streaming/kitex_gen/echo/api.go | 4530 ----------------- .../kitex_gen/echo/echoservice/client.go | 140 - .../kitex_gen/echo/echoservice/echoservice.go | 440 -- .../kitex_gen/echo/echoservice/invoker.go | 24 - .../kitex_gen/echo/echoservice/server.go | 21 - thrift_streaming/kitex_gen/echo/k-api.go | 3026 ----------- thrift_streaming/kitex_gen/echo/k-consts.go | 4 - .../echo/pingpongonlyservice/client.go | 49 - .../echo/pingpongonlyservice/invoker.go | 24 - .../pingpongonlyservice.go | 125 - .../echo/pingpongonlyservice/server.go | 21 - .../echo/pingpongonlyservicechild/client.go | 99 - .../echo/pingpongonlyservicechild/invoker.go | 24 - .../pingpongonlyservicechild.go | 190 - .../echo/pingpongonlyservicechild/server.go | 21 - .../pingpongonlyservicechildchild/client.go | 99 - .../pingpongonlyservicechildchild/invoker.go | 24 - .../pingpongonlyservicechildchild.go | 190 - .../pingpongonlyservicechildchild/server.go | 21 - .../echo/streamonlyservice/client.go | 92 - .../echo/streamonlyservice/invoker.go | 24 - .../echo/streamonlyservice/server.go | 21 - .../streamonlyservice/streamonlyservice.go | 155 - .../echo/streamonlyservicechild/client.go | 92 - .../echo/streamonlyservicechild/invoker.go | 24 - .../echo/streamonlyservicechild/server.go | 21 - .../streamonlyservicechild.go | 155 - .../streamonlyservicechildchild/client.go | 92 - .../streamonlyservicechildchild/invoker.go | 24 - .../streamonlyservicechildchild/server.go | 21 - .../streamonlyservicechildchild.go | 155 - .../kitex_gen/grpc_pb/api.pb.fast.go | 135 - thrift_streaming/kitex_gen/grpc_pb/api.pb.go | 274 - .../kitex_gen/grpc_pb/pbservice/client.go | 142 - .../kitex_gen/grpc_pb/pbservice/invoker.go | 24 - .../kitex_gen/grpc_pb/pbservice/pbservice.go | 809 --- .../kitex_gen/grpc_pb/pbservice/server.go | 20 - .../kitex_pb/api_no_stream.pb.fast.go | 135 - .../kitex_gen/kitex_pb/api_no_stream.pb.go | 238 - .../kitex_gen/kitex_pb/pbservice/client.go | 49 - .../kitex_gen/kitex_pb/pbservice/invoker.go | 24 - .../kitex_gen/kitex_pb/pbservice/pbservice.go | 262 - .../kitex_gen/kitex_pb/pbservice/server.go | 20 - .../kitex_gen_slim/combine/b/client.go | 1 + .../combine/combineservice/client.go | 44 - .../combine/combineservice/combineservice.go | 2 +- .../kitex_gen_slim/combine_extend/b/b.go | 2 +- .../kitex_gen_slim/combine_extend/b/client.go | 45 +- .../combine_extend/combineservice/client.go | 44 - .../combineservice/combineservice.go | 2 +- .../pingpongonlyservicechildchild/client.go | 44 - .../pingpongonlyservicechildchild.go | 2 +- .../echo/streamonlyservice/client.go | 1 + .../echo/streamonlyservicechild/client.go | 45 +- .../streamonlyservicechild.go | 2 +- .../streamonlyservicechildchild/client.go | 45 +- .../streamonlyservicechildchild.go | 2 +- thrift_streaming/main_test.go | 34 +- thrift_streaming/thrift_slim_amd64_test.go | 3 +- thrift_streaming/thrift_slim_others_test.go | 4 +- 108 files changed, 574 insertions(+), 16293 deletions(-) create mode 100644 common/common.go create mode 100644 kitexgrpc/abc/abc_test.go create mode 100644 kitexgrpc/abc/consts/common.go create mode 100644 kitexgrpc/abc/servicea/main/main.go create mode 100644 kitexgrpc/abc/servicea/servicea.go create mode 100644 kitexgrpc/abc/serviceb/main/main.go create mode 100644 kitexgrpc/abc/serviceb/serviceb.go create mode 100644 kitexgrpc/abc/servicec/main/main.go create mode 100644 kitexgrpc/abc/servicec/servicec.go rename {grpc => kitexgrpc}/compressor/grpc_client.go (94%) rename {grpc => kitexgrpc}/compressor/grpc_compressor_test.go (93%) rename {grpc => kitexgrpc}/compressor/grpc_server.go (100%) rename {grpc => kitexgrpc}/compressor/kitex_client.go (100%) rename {grpc => kitexgrpc}/compressor/kitex_server.go (99%) rename {grpc => kitexgrpc}/multi_service/multi_service_test.go (100%) rename {grpc => kitexgrpc}/normalcall/normalcall_test.go (100%) rename {grpc => kitexgrpc}/unknown_handler/unknown_service_handler_test.go (100%) delete mode 100644 thrift_streaming/kitex_gen/combine/a/a.go delete mode 100644 thrift_streaming/kitex_gen/combine/a/client.go delete mode 100644 thrift_streaming/kitex_gen/combine/a/invoker.go delete mode 100644 thrift_streaming/kitex_gen/combine/a/server.go delete mode 100644 thrift_streaming/kitex_gen/combine/b/b.go delete mode 100644 thrift_streaming/kitex_gen/combine/b/client.go delete mode 100644 thrift_streaming/kitex_gen/combine/b/invoker.go delete mode 100644 thrift_streaming/kitex_gen/combine/b/server.go delete mode 100644 thrift_streaming/kitex_gen/combine/combine.go delete mode 100644 thrift_streaming/kitex_gen/combine/combineservice/client.go delete mode 100644 thrift_streaming/kitex_gen/combine/combineservice/combineservice.go delete mode 100644 thrift_streaming/kitex_gen/combine/combineservice/invoker.go delete mode 100644 thrift_streaming/kitex_gen/combine/combineservice/server.go delete mode 100644 thrift_streaming/kitex_gen/combine/k-combine.go delete mode 100644 thrift_streaming/kitex_gen/combine/k-consts.go delete mode 100644 thrift_streaming/kitex_gen/combine_extend/a/a.go delete mode 100644 thrift_streaming/kitex_gen/combine_extend/a/client.go delete mode 100644 thrift_streaming/kitex_gen/combine_extend/a/invoker.go delete mode 100644 thrift_streaming/kitex_gen/combine_extend/a/server.go delete mode 100644 thrift_streaming/kitex_gen/combine_extend/b/b.go delete mode 100644 thrift_streaming/kitex_gen/combine_extend/b/client.go delete mode 100644 thrift_streaming/kitex_gen/combine_extend/b/invoker.go delete mode 100644 thrift_streaming/kitex_gen/combine_extend/b/server.go delete mode 100644 thrift_streaming/kitex_gen/combine_extend/combine_extend.go delete mode 100644 thrift_streaming/kitex_gen/combine_extend/combineservice/client.go delete mode 100644 thrift_streaming/kitex_gen/combine_extend/combineservice/combineservice.go delete mode 100644 thrift_streaming/kitex_gen/combine_extend/combineservice/invoker.go delete mode 100644 thrift_streaming/kitex_gen/combine_extend/combineservice/server.go delete mode 100644 thrift_streaming/kitex_gen/combine_extend/k-combine_extend.go delete mode 100644 thrift_streaming/kitex_gen/combine_extend/k-consts.go delete mode 100644 thrift_streaming/kitex_gen/echo/api.go delete mode 100644 thrift_streaming/kitex_gen/echo/echoservice/client.go delete mode 100644 thrift_streaming/kitex_gen/echo/echoservice/echoservice.go delete mode 100644 thrift_streaming/kitex_gen/echo/echoservice/invoker.go delete mode 100644 thrift_streaming/kitex_gen/echo/echoservice/server.go delete mode 100644 thrift_streaming/kitex_gen/echo/k-api.go delete mode 100644 thrift_streaming/kitex_gen/echo/k-consts.go delete mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservice/client.go delete mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservice/invoker.go delete mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservice/pingpongonlyservice.go delete mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservice/server.go delete mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/client.go delete mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/invoker.go delete mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/pingpongonlyservicechild.go delete mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/server.go delete mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/client.go delete mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/invoker.go delete mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go delete mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/server.go delete mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservice/client.go delete mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservice/invoker.go delete mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservice/server.go delete mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservice/streamonlyservice.go delete mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechild/client.go delete mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechild/invoker.go delete mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechild/server.go delete mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechild/streamonlyservicechild.go delete mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/client.go delete mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/invoker.go delete mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/server.go delete mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/streamonlyservicechildchild.go delete mode 100644 thrift_streaming/kitex_gen/grpc_pb/api.pb.fast.go delete mode 100644 thrift_streaming/kitex_gen/grpc_pb/api.pb.go delete mode 100644 thrift_streaming/kitex_gen/grpc_pb/pbservice/client.go delete mode 100644 thrift_streaming/kitex_gen/grpc_pb/pbservice/invoker.go delete mode 100644 thrift_streaming/kitex_gen/grpc_pb/pbservice/pbservice.go delete mode 100644 thrift_streaming/kitex_gen/grpc_pb/pbservice/server.go delete mode 100644 thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.fast.go delete mode 100644 thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.go delete mode 100644 thrift_streaming/kitex_gen/kitex_pb/pbservice/client.go delete mode 100644 thrift_streaming/kitex_gen/kitex_pb/pbservice/invoker.go delete mode 100644 thrift_streaming/kitex_gen/kitex_pb/pbservice/pbservice.go delete mode 100644 thrift_streaming/kitex_gen/kitex_pb/pbservice/server.go diff --git a/common/common.go b/common/common.go new file mode 100644 index 0000000..40b1421 --- /dev/null +++ b/common/common.go @@ -0,0 +1,32 @@ +// Copyright 2024 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package common + +import ( + "net" + "time" + + "github.com/cloudwego/kitex/pkg/klog" +) + +func WaitServer(hostPort string) { + for begin := time.Now(); time.Since(begin) < time.Second; { + if _, err := net.Dial("tcp", hostPort); err == nil { + klog.Infof("server %s is up", hostPort) + return + } + time.Sleep(time.Millisecond * 10) + } +} diff --git a/kitexgrpc/abc/abc_test.go b/kitexgrpc/abc/abc_test.go new file mode 100644 index 0000000..b891791 --- /dev/null +++ b/kitexgrpc/abc/abc_test.go @@ -0,0 +1,67 @@ +// Copyright 2024 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package abc + +import ( + "testing" + + "github.com/cloudwego/kitex-tests/common" + "github.com/cloudwego/kitex-tests/kitexgrpc/abc/consts" + "github.com/cloudwego/kitex-tests/kitexgrpc/abc/servicea" + "github.com/cloudwego/kitex-tests/kitexgrpc/abc/serviceb" + "github.com/cloudwego/kitex-tests/kitexgrpc/abc/servicec" + "github.com/cloudwego/kitex-tests/pkg/test" +) + +func TestMain(m *testing.M) { + svrC := servicec.InitServiceCServer() + go func() { + defer svrC.Stop() + err := svrC.Run() + if err != nil { + panic(err) + } + }() + svrB := serviceb.InitServiceBServer() + go func() { + defer svrB.Stop() + err := svrB.Run() + if err != nil { + panic(err) + } + }() + + common.WaitServer(consts.ServiceCAddr) + common.WaitServer(consts.ServiceBAddr) + + m.Run() +} + +func TestABC(t *testing.T) { + cli, err := servicea.InitServiceAClient() + test.Assert(t, err == nil, err) + + err = servicea.SendUnary(cli) + test.Assert(t, err == nil, err) + + err = servicea.SendClientStreaming(cli) + test.Assert(t, err == nil, err) + + err = servicea.SendServerStreaming(cli) + test.Assert(t, err == nil, err) + + err = servicea.SendBidiStreaming(cli) + test.Assert(t, err == nil, err) +} diff --git a/kitexgrpc/abc/consts/common.go b/kitexgrpc/abc/consts/common.go new file mode 100644 index 0000000..d446518 --- /dev/null +++ b/kitexgrpc/abc/consts/common.go @@ -0,0 +1,20 @@ +// Copyright 2024 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package consts + +const ( + ServiceBAddr = "localhost:9990" + ServiceCAddr = "localhost:9991" +) diff --git a/kitexgrpc/abc/servicea/main/main.go b/kitexgrpc/abc/servicea/main/main.go new file mode 100644 index 0000000..3cf7c89 --- /dev/null +++ b/kitexgrpc/abc/servicea/main/main.go @@ -0,0 +1,29 @@ +// Copyright 2024 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import "github.com/cloudwego/kitex-tests/kitexgrpc/abc/servicea" + +func main() { + cli, err := servicea.InitServiceAClient() + if err != nil { + panic(err) + } + + servicea.SendUnary(cli) + servicea.SendClientStreaming(cli) + servicea.SendServerStreaming(cli) + servicea.SendBidiStreaming(cli) +} diff --git a/kitexgrpc/abc/servicea/servicea.go b/kitexgrpc/abc/servicea/servicea.go new file mode 100644 index 0000000..7971fa8 --- /dev/null +++ b/kitexgrpc/abc/servicea/servicea.go @@ -0,0 +1,114 @@ +// Copyright 2024 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package servicea + +import ( + "context" + "fmt" + "io" + "time" + + "github.com/cloudwego/kitex-tests/kitex_gen/protobuf/grpc_demo" + "github.com/cloudwego/kitex-tests/kitex_gen/protobuf/grpc_demo/servicea" + "github.com/cloudwego/kitex-tests/kitexgrpc/abc/consts" + "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/pkg/endpoint" + "github.com/cloudwego/kitex/transport" +) + +func myMiddleware(next endpoint.Endpoint) endpoint.Endpoint { + return func(ctx context.Context, req, resp interface{}) (err error) { + err = next(ctx, req, resp) + return err + } +} + +func InitServiceAClient() (servicea.Client, error) { + cli, err := servicea.NewClient("serviceB", + client.WithRPCTimeout(1000*time.Millisecond), + client.WithHostPorts(consts.ServiceBAddr), client.WithTransportProtocol(transport.GRPC), + client.WithMiddleware(myMiddleware)) + return cli, err +} + +func SendUnary(cli servicea.Client) error { + // case 1: unary + req := &grpc_demo.Request{Name: "service_a_CallUnary"} + resp, err := cli.CallUnary(context.Background(), req) + fmt.Println(resp, err) + return err +} + +func SendClientStreaming(cli servicea.Client) error { + // case 2: client streaming + req := &grpc_demo.Request{Name: "service_a_CallClientStream"} + stream1, err := cli.CallClientStream(context.Background()) + if err != nil { + return err + } + for i := 0; i < 3; i++ { + if err := stream1.Send(req); err != nil { + return err + } + } + _, err = stream1.CloseAndRecv() + return err +} + +func SendServerStreaming(cli servicea.Client) error { + // case 3: server streaming + req := &grpc_demo.Request{Name: "service_a_CallServerStream"} + stream2, err := cli.CallServerStream(context.Background(), req) + if err != nil { + return err + } + for { + reply, err := stream2.Recv() + if err != nil { + if err == io.EOF { + break + } + return err + } + fmt.Println(reply) + } + return err +} + +func SendBidiStreaming(cli servicea.Client) error { + // case 4: bidi streaming + req := &grpc_demo.Request{Name: "service_a_CallBidiStream"} + stream3, err := cli.CallBidiStream(context.Background()) + if err != nil { + return err + } + for i := 0; i < 3; i++ { + if err := stream3.Send(req); err != nil { + return err + } + } + stream3.Close() + for { + reply, err := stream3.Recv() + if err != nil { + if err == io.EOF { + break + } + return err + } + fmt.Println("serviceA", reply) + } + return err +} diff --git a/kitexgrpc/abc/serviceb/main/main.go b/kitexgrpc/abc/serviceb/main/main.go new file mode 100644 index 0000000..f60fc0c --- /dev/null +++ b/kitexgrpc/abc/serviceb/main/main.go @@ -0,0 +1,24 @@ +// Copyright 2024 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import "github.com/cloudwego/kitex-tests/kitexgrpc/abc/serviceb" + +func main() { + svr := serviceb.InitServiceBServer() + defer svr.Stop() + err := svr.Run() + panic(err) +} diff --git a/kitexgrpc/abc/serviceb/serviceb.go b/kitexgrpc/abc/serviceb/serviceb.go new file mode 100644 index 0000000..70d8b15 --- /dev/null +++ b/kitexgrpc/abc/serviceb/serviceb.go @@ -0,0 +1,135 @@ +// Copyright 2024 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package serviceb + +import ( + "context" + "fmt" + "io" + "net" + + "github.com/cloudwego/kitex-tests/kitex_gen/protobuf/grpc_demo" + "github.com/cloudwego/kitex-tests/kitex_gen/protobuf/grpc_demo/servicea" + "github.com/cloudwego/kitex-tests/kitexgrpc/abc/consts" + "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/pkg/endpoint" + "github.com/cloudwego/kitex/pkg/klog" + "github.com/cloudwego/kitex/server" + "github.com/cloudwego/kitex/transport" +) + +func myMiddleware(next endpoint.Endpoint) endpoint.Endpoint { + return func(ctx context.Context, req, resp interface{}) (err error) { + err = next(ctx, req, resp) + //time.Sleep(500 * time.Millisecond) + return err + } +} + +func InitServiceBServer() server.Server { + cli, err := servicea.NewClient("serviceC", + client.WithMiddleware(myMiddleware), + client.WithHostPorts(consts.ServiceCAddr), client.WithTransportProtocol(transport.GRPC)) + if err != nil { + panic(err) + } + addr, _ := net.ResolveTCPAddr("tcp", consts.ServiceBAddr) + svr := servicea.NewServer(&ServiceBImpl{cli: cli}, server.WithServiceAddr(addr)) + return svr +} + +type ServiceBImpl struct { + cli servicea.Client +} + +func (s ServiceBImpl) CallUnary(ctx context.Context, req *grpc_demo.Request) (res *grpc_demo.Reply, err error) { + res, err = s.cli.CallUnary(ctx, req) + fmt.Println(res, err) + if dl, ok := ctx.Deadline(); ok { + klog.Infof("dl=%v", dl) + } + return +} + +func (s ServiceBImpl) CallClientStream(stream grpc_demo.ServiceA_CallClientStreamServer) (err error) { + svcCStream, err := s.cli.CallClientStream(stream.Context()) + if err != nil { + return err + } + for { + msg, err := stream.Recv() + if err != nil { + if err == io.EOF { + break + } + return err + } + if err = svcCStream.Send(msg); err != nil { + return err + } + } + reply, err := svcCStream.CloseAndRecv() + if err != nil { + return err + } + return stream.SendAndClose(reply) +} + +func (s ServiceBImpl) CallServerStream(req *grpc_demo.Request, stream grpc_demo.ServiceA_CallServerStreamServer) (err error) { + svcCStream, err := s.cli.CallServerStream(stream.Context(), req) + if err != nil { + return err + } + for { + msg, err := svcCStream.Recv() + if err != nil { + if err == io.EOF { + break + } + return err + } + if err = stream.Send(msg); err != nil { + return err + } + } + return +} + +func (s ServiceBImpl) CallBidiStream(stream grpc_demo.ServiceA_CallBidiStreamServer) error { + svcCStream, err := s.cli.CallBidiStream(stream.Context()) + if err != nil { + return err + } + for { + msg, rErr := stream.Recv() + if rErr != nil { + if rErr == io.EOF { + break + } + return rErr + } + if sErr := svcCStream.Send(msg); sErr != nil { + return sErr + } + reply, rErr := svcCStream.Recv() + if rErr != nil { + return rErr + } + if sErr := stream.Send(reply); sErr != nil { + return sErr + } + } + return nil +} diff --git a/kitexgrpc/abc/servicec/main/main.go b/kitexgrpc/abc/servicec/main/main.go new file mode 100644 index 0000000..f8345ca --- /dev/null +++ b/kitexgrpc/abc/servicec/main/main.go @@ -0,0 +1,24 @@ +// Copyright 2024 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import "github.com/cloudwego/kitex-tests/kitexgrpc/abc/servicec" + +func main() { + svr := servicec.InitServiceCServer() + defer svr.Stop() + err := svr.Run() + panic(err) +} diff --git a/kitexgrpc/abc/servicec/servicec.go b/kitexgrpc/abc/servicec/servicec.go new file mode 100644 index 0000000..6aba140 --- /dev/null +++ b/kitexgrpc/abc/servicec/servicec.go @@ -0,0 +1,80 @@ +// Copyright 2024 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package servicec + +import ( + "context" + "io" + "net" + + "github.com/cloudwego/kitex-tests/kitex_gen/protobuf/grpc_demo" + "github.com/cloudwego/kitex-tests/kitex_gen/protobuf/grpc_demo/servicea" + "github.com/cloudwego/kitex-tests/kitexgrpc/abc/consts" + "github.com/cloudwego/kitex/server" +) + +func InitServiceCServer() server.Server { + addr, _ := net.ResolveTCPAddr("tcp", consts.ServiceCAddr) + svr := servicea.NewServer(new(ServiceCImpl), server.WithServiceAddr(addr)) + return svr +} + +type ServiceCImpl struct { +} + +func (s ServiceCImpl) CallUnary(ctx context.Context, req *grpc_demo.Request) (res *grpc_demo.Reply, err error) { + res = &grpc_demo.Reply{Message: req.Name} + return +} + +func (s ServiceCImpl) CallClientStream(stream grpc_demo.ServiceA_CallClientStreamServer) (err error) { + replyMsg := "" + for { + msg, err := stream.Recv() + if err == nil { + replyMsg = msg.Name + } else if err == io.EOF { + break + } else { + return err + } + } + return stream.SendAndClose(&grpc_demo.Reply{Message: replyMsg}) +} + +func (s ServiceCImpl) CallServerStream(req *grpc_demo.Request, stream grpc_demo.ServiceA_CallServerStreamServer) (err error) { + for i := 0; i < 3; i++ { + if err = stream.Send(&grpc_demo.Reply{Message: req.Name}); err != nil { + return err + } + } + return +} + +func (s ServiceCImpl) CallBidiStream(stream grpc_demo.ServiceA_CallBidiStreamServer) (err error) { + for { + msg, err := stream.Recv() + if err != nil { + if err == io.EOF { + return nil + } + return err + } + err = stream.Send(&grpc_demo.Reply{Message: msg.Name}) + if err != nil { + return err + } + } +} diff --git a/grpc/compressor/grpc_client.go b/kitexgrpc/compressor/grpc_client.go similarity index 94% rename from grpc/compressor/grpc_client.go rename to kitexgrpc/compressor/grpc_client.go index 0fdc466..afda029 100644 --- a/grpc/compressor/grpc_client.go +++ b/kitexgrpc/compressor/grpc_client.go @@ -16,10 +16,11 @@ package compressor import ( "context" - grpc_demo "github.com/cloudwego/kitex-tests/grpc_gen/protobuf/grpc_demo_2" - "google.golang.org/grpc" "io" "strconv" + + grpc_demo "github.com/cloudwego/kitex-tests/grpc_gen/protobuf/grpc_demo_2" + "google.golang.org/grpc" ) type ClientWrapperGRPC struct { @@ -47,7 +48,7 @@ func (c *ClientWrapperGRPC) RunClientStream(opts ...grpc.CallOption) (*grpc_demo return nil, err } for i := 0; i < 3; i++ { - req := &grpc_demo.Request{Name: "grpc-" + strconv.Itoa(i)} + req := &grpc_demo.Request{Name: "kitexgrpc-" + strconv.Itoa(i)} err = streamCli.SendMsg(req) if err != nil { return nil, err @@ -58,7 +59,7 @@ func (c *ClientWrapperGRPC) RunClientStream(opts ...grpc.CallOption) (*grpc_demo func (c *ClientWrapperGRPC) RunServerStream(opts ...grpc.CallOption) ([]*grpc_demo.Reply, error) { ctx := context.Background() - req := &grpc_demo.Request{Name: "grpc"} + req := &grpc_demo.Request{Name: "kitexgrpc"} streamCli, err := c.client.CallServerStream(ctx, req) if err != nil { return nil, err @@ -87,7 +88,7 @@ func (c *ClientWrapperGRPC) RunBidiStream(opts ...grpc.CallOption) ([]*grpc_demo errChan := make(chan error) go func() { for i := 0; i < 3; i++ { - req := &grpc_demo.Request{Name: "grpc-" + strconv.Itoa(i)} + req := &grpc_demo.Request{Name: "kitexgrpc-" + strconv.Itoa(i)} err = stream.Send(req) if err != nil { errChan <- err diff --git a/grpc/compressor/grpc_compressor_test.go b/kitexgrpc/compressor/grpc_compressor_test.go similarity index 93% rename from grpc/compressor/grpc_compressor_test.go rename to kitexgrpc/compressor/grpc_compressor_test.go index 0b767c9..96f1dd1 100644 --- a/grpc/compressor/grpc_compressor_test.go +++ b/kitexgrpc/compressor/grpc_compressor_test.go @@ -17,6 +17,10 @@ package compressor import ( "context" "errors" + "net" + "testing" + "time" + "github.com/cloudwego/kitex-tests/kitex_gen/protobuf/grpc_demo/servicea" "github.com/cloudwego/kitex-tests/pkg/test" client_opt "github.com/cloudwego/kitex/client" @@ -27,9 +31,6 @@ import ( "github.com/cloudwego/kitex/server" "google.golang.org/grpc" "google.golang.org/grpc/encoding/gzip" - "net" - "testing" - "time" ) func TestKitexWithoutCompressor(t *testing.T) { @@ -105,13 +106,13 @@ func TestKitexCompressorWithGRPCClient(t *testing.T) { test.Assert(t, resp != nil && resp.Message == "Grpc Hello!") resp, err = client.RunClientStream(grpc.UseCompressor(gzip.Name)) test.Assert(t, err == nil, err) - test.Assert(t, resp != nil && resp.Message == "all message: grpc-0, grpc-1, grpc-2") + test.Assert(t, resp != nil && resp.Message == "all message: kitexgrpc-0, kitexgrpc-1, kitexgrpc-2") respArr, err := client.RunServerStream(grpc.UseCompressor(gzip.Name)) test.Assert(t, err == nil, err) - test.Assert(t, len(respArr) == 3 && respArr[0].Message == "grpc-0" && respArr[1].Message == "grpc-1" && respArr[2].Message == "grpc-2") + test.Assert(t, len(respArr) == 3 && respArr[0].Message == "kitexgrpc-0" && respArr[1].Message == "kitexgrpc-1" && respArr[2].Message == "kitexgrpc-2") respArr, err = client.RunBidiStream(grpc.UseCompressor(gzip.Name)) test.Assert(t, err == nil, err) - test.Assert(t, len(respArr) == 3 && respArr[0].Message == "grpc-0" && respArr[1].Message == "grpc-1" && respArr[2].Message == "grpc-2") + test.Assert(t, len(respArr) == 3 && respArr[0].Message == "kitexgrpc-0" && respArr[1].Message == "kitexgrpc-1" && respArr[2].Message == "kitexgrpc-2") } func ServiceNameMW(next endpoint.Endpoint) endpoint.Endpoint { diff --git a/grpc/compressor/grpc_server.go b/kitexgrpc/compressor/grpc_server.go similarity index 100% rename from grpc/compressor/grpc_server.go rename to kitexgrpc/compressor/grpc_server.go diff --git a/grpc/compressor/kitex_client.go b/kitexgrpc/compressor/kitex_client.go similarity index 100% rename from grpc/compressor/kitex_client.go rename to kitexgrpc/compressor/kitex_client.go diff --git a/grpc/compressor/kitex_server.go b/kitexgrpc/compressor/kitex_server.go similarity index 99% rename from grpc/compressor/kitex_server.go rename to kitexgrpc/compressor/kitex_server.go index f093db2..6a357f9 100644 --- a/grpc/compressor/kitex_server.go +++ b/kitexgrpc/compressor/kitex_server.go @@ -17,13 +17,14 @@ package compressor import ( "context" "fmt" - "github.com/cloudwego/kitex-tests/kitex_gen/protobuf/grpc_demo" - "github.com/cloudwego/kitex-tests/kitex_gen/protobuf/grpc_demo/servicea" - "github.com/cloudwego/kitex/server" "io" "log" "net" "strings" + + "github.com/cloudwego/kitex-tests/kitex_gen/protobuf/grpc_demo" + "github.com/cloudwego/kitex-tests/kitex_gen/protobuf/grpc_demo/servicea" + "github.com/cloudwego/kitex/server" ) type ServiceAImpl struct{} diff --git a/grpc/multi_service/multi_service_test.go b/kitexgrpc/multi_service/multi_service_test.go similarity index 100% rename from grpc/multi_service/multi_service_test.go rename to kitexgrpc/multi_service/multi_service_test.go diff --git a/grpc/normalcall/normalcall_test.go b/kitexgrpc/normalcall/normalcall_test.go similarity index 100% rename from grpc/normalcall/normalcall_test.go rename to kitexgrpc/normalcall/normalcall_test.go diff --git a/grpc/unknown_handler/unknown_service_handler_test.go b/kitexgrpc/unknown_handler/unknown_service_handler_test.go similarity index 100% rename from grpc/unknown_handler/unknown_service_handler_test.go rename to kitexgrpc/unknown_handler/unknown_service_handler_test.go diff --git a/run.sh b/run.sh index a81b68f..81dfde7 100755 --- a/run.sh +++ b/run.sh @@ -62,9 +62,9 @@ go_install() { which protoc || install_protoc -# install protoc-gen-go and protoc-gen-go-grpc +# install protoc-gen-go and protoc-gen-go-kitexgrpc which protoc-gen-go || go_install google.golang.org/protobuf/cmd/protoc-gen-go@latest -# install protoc-gen-go and protoc-gen-go-grpc +# install protoc-gen-go and protoc-gen-go-kitexgrpc which protoc-gen-go-grpc || go_install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest # Install thriftgo @@ -90,6 +90,8 @@ kitex -module github.com/cloudwego/kitex-tests -I idl ./idl/unknown_handler.prot kitex -module github.com/cloudwego/kitex-tests -I idl ./idl/grpc_demo.proto kitex -module github.com/cloudwego/kitex-tests -I idl ./idl/multi_service.proto kitex -module github.com/cloudwego/kitex-tests -I idl ./idl/multi_service_2.proto +# generate thrift streaming code +LOCAL_REPO=$LOCAL_REPO ./thrift_streaming/generate.sh test -d grpc_gen && rm -rf grpc_gen mkdir grpc_gen protoc --go_out=grpc_gen/. ./idl/grpc_demo_2.proto @@ -124,12 +126,10 @@ packages=( ./pbrpc/failedcall/... ./generic/http/... ./generic/map/... -./grpc/... +./kitexgrpc/... ./thrift_streaming/... ) -LOCAL_REPO=$LOCAL_REPO ./thrift_streaming/generate.sh - for pkg in ${packages[@]} do if [[ -n $LOCAL_REPO ]]; then diff --git a/thrift_streaming/kitex_gen/combine/a/a.go b/thrift_streaming/kitex_gen/combine/a/a.go deleted file mode 100644 index aac12d5..0000000 --- a/thrift_streaming/kitex_gen/combine/a/a.go +++ /dev/null @@ -1,125 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package a - -import ( - "context" - "errors" - combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" - client "github.com/cloudwego/kitex/client" - kitex "github.com/cloudwego/kitex/pkg/serviceinfo" -) - -var errInvalidMessageType = errors.New("invalid message type for service method handler") - -var serviceMethods = map[string]kitex.MethodInfo{ - "Foo": kitex.NewMethodInfo( - fooHandler, - newAFooArgs, - newAFooResult, - false, - kitex.WithStreamingMode(kitex.StreamingNone), - ), -} - -var ( - aServiceInfo = NewServiceInfo() - aServiceInfoForClient = NewServiceInfoForClient() - aServiceInfoForStreamClient = NewServiceInfoForStreamClient() -) - -// for server -func serviceInfo() *kitex.ServiceInfo { - return aServiceInfo -} - -// for client -func serviceInfoForStreamClient() *kitex.ServiceInfo { - return aServiceInfoForStreamClient -} - -// for stream client -func serviceInfoForClient() *kitex.ServiceInfo { - return aServiceInfoForClient -} - -// NewServiceInfo creates a new ServiceInfo containing all methods -func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(false, true, true) -} - -// NewServiceInfo creates a new ServiceInfo containing non-streaming methods -func NewServiceInfoForClient() *kitex.ServiceInfo { - return newServiceInfo(false, false, true) -} -func NewServiceInfoForStreamClient() *kitex.ServiceInfo { - return newServiceInfo(true, true, false) -} - -func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { - serviceName := "A" - handlerType := (*combine.A)(nil) - methods := map[string]kitex.MethodInfo{} - for name, m := range serviceMethods { - if m.IsStreaming() && !keepStreamingMethods { - continue - } - if !m.IsStreaming() && !keepNonStreamingMethods { - continue - } - methods[name] = m - } - extra := map[string]interface{}{ - "PackageName": "combine", - } - if hasStreaming { - extra["streaming"] = hasStreaming - } - svcInfo := &kitex.ServiceInfo{ - ServiceName: serviceName, - HandlerType: handlerType, - Methods: methods, - PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.8.0", - Extra: extra, - } - return svcInfo -} - -func fooHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - realArg := arg.(*combine.AFooArgs) - realResult := result.(*combine.AFooResult) - success, err := handler.(combine.A).Foo(ctx, realArg.Req) - if err != nil { - return err - } - realResult.Success = success - return nil -} -func newAFooArgs() interface{} { - return combine.NewAFooArgs() -} - -func newAFooResult() interface{} { - return combine.NewAFooResult() -} - -type kClient struct { - c client.Client -} - -func newServiceClient(c client.Client) *kClient { - return &kClient{ - c: c, - } -} - -func (p *kClient) Foo(ctx context.Context, req *combine.Req) (r *combine.Rsp, err error) { - var _args combine.AFooArgs - _args.Req = req - var _result combine.AFooResult - if err = p.c.Call(ctx, "Foo", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} diff --git a/thrift_streaming/kitex_gen/combine/a/client.go b/thrift_streaming/kitex_gen/combine/a/client.go deleted file mode 100644 index dd7a1c2..0000000 --- a/thrift_streaming/kitex_gen/combine/a/client.go +++ /dev/null @@ -1,49 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package a - -import ( - "context" - combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" - client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" -) - -// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. -type Client interface { - Foo(ctx context.Context, req *combine.Req, callOptions ...callopt.Option) (r *combine.Rsp, err error) -} - -// NewClient creates a client for the service defined in IDL. -func NewClient(destService string, opts ...client.Option) (Client, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - - options = append(options, opts...) - - kc, err := client.NewClient(serviceInfoForClient(), options...) - if err != nil { - return nil, err - } - return &kAClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. -func MustNewClient(destService string, opts ...client.Option) Client { - kc, err := NewClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kAClient struct { - *kClient -} - -func (p *kAClient) Foo(ctx context.Context, req *combine.Req, callOptions ...callopt.Option) (r *combine.Rsp, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.Foo(ctx, req) -} diff --git a/thrift_streaming/kitex_gen/combine/a/invoker.go b/thrift_streaming/kitex_gen/combine/a/invoker.go deleted file mode 100644 index 72c632c..0000000 --- a/thrift_streaming/kitex_gen/combine/a/invoker.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package a - -import ( - combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" - server "github.com/cloudwego/kitex/server" -) - -// NewInvoker creates a server.Invoker with the given handler and options. -func NewInvoker(handler combine.A, opts ...server.Option) server.Invoker { - var options []server.Option - - options = append(options, opts...) - - s := server.NewInvoker(options...) - if err := s.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - if err := s.Init(); err != nil { - panic(err) - } - return s -} diff --git a/thrift_streaming/kitex_gen/combine/a/server.go b/thrift_streaming/kitex_gen/combine/a/server.go deleted file mode 100644 index 6b6a2d7..0000000 --- a/thrift_streaming/kitex_gen/combine/a/server.go +++ /dev/null @@ -1,21 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. -package a - -import ( - combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" - server "github.com/cloudwego/kitex/server" -) - -// NewServer creates a server.Server with the given handler and options. -func NewServer(handler combine.A, opts ...server.Option) server.Server { - var options []server.Option - - options = append(options, opts...) - options = append(options, server.WithCompatibleMiddlewareForUnary()) - - svr := server.NewServer(options...) - if err := svr.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - return svr -} diff --git a/thrift_streaming/kitex_gen/combine/b/b.go b/thrift_streaming/kitex_gen/combine/b/b.go deleted file mode 100644 index 75ea7e1..0000000 --- a/thrift_streaming/kitex_gen/combine/b/b.go +++ /dev/null @@ -1,155 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package b - -import ( - "context" - "errors" - "fmt" - combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" - client "github.com/cloudwego/kitex/client" - kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" -) - -var errInvalidMessageType = errors.New("invalid message type for service method handler") - -var serviceMethods = map[string]kitex.MethodInfo{ - "Bar": kitex.NewMethodInfo( - barHandler, - newBBarArgs, - newBBarResult, - false, - kitex.WithStreamingMode(kitex.StreamingBidirectional), - ), -} - -var ( - bServiceInfo = NewServiceInfo() - bServiceInfoForClient = NewServiceInfoForClient() - bServiceInfoForStreamClient = NewServiceInfoForStreamClient() -) - -// for server -func serviceInfo() *kitex.ServiceInfo { - return bServiceInfo -} - -// for client -func serviceInfoForStreamClient() *kitex.ServiceInfo { - return bServiceInfoForStreamClient -} - -// for stream client -func serviceInfoForClient() *kitex.ServiceInfo { - return bServiceInfoForClient -} - -// NewServiceInfo creates a new ServiceInfo containing all methods -func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(true, true, true) -} - -// NewServiceInfo creates a new ServiceInfo containing non-streaming methods -func NewServiceInfoForClient() *kitex.ServiceInfo { - return newServiceInfo(false, false, true) -} -func NewServiceInfoForStreamClient() *kitex.ServiceInfo { - return newServiceInfo(true, true, false) -} - -func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { - serviceName := "B" - handlerType := (*combine.B)(nil) - methods := map[string]kitex.MethodInfo{} - for name, m := range serviceMethods { - if m.IsStreaming() && !keepStreamingMethods { - continue - } - if !m.IsStreaming() && !keepNonStreamingMethods { - continue - } - methods[name] = m - } - extra := map[string]interface{}{ - "PackageName": "combine", - } - if hasStreaming { - extra["streaming"] = hasStreaming - } - svcInfo := &kitex.ServiceInfo{ - ServiceName: serviceName, - HandlerType: handlerType, - Methods: methods, - PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.8.0", - Extra: extra, - } - return svcInfo -} - -func barHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - st, ok := arg.(*streaming.Args) - if !ok { - return errors.New("B.Bar is a thrift streaming method, please call with Kitex StreamClient") - } - stream := &bBarServer{st.Stream} - return handler.(combine.B).Bar(stream) -} - -type bBarClient struct { - streaming.Stream -} - -func (x *bBarClient) Send(m *combine.Req) error { - return x.Stream.SendMsg(m) -} -func (x *bBarClient) Recv() (*combine.Rsp, error) { - m := new(combine.Rsp) - return m, x.Stream.RecvMsg(m) -} - -type bBarServer struct { - streaming.Stream -} - -func (x *bBarServer) Send(m *combine.Rsp) error { - return x.Stream.SendMsg(m) -} - -func (x *bBarServer) Recv() (*combine.Req, error) { - m := new(combine.Req) - return m, x.Stream.RecvMsg(m) -} - -func newBBarArgs() interface{} { - return combine.NewBBarArgs() -} - -func newBBarResult() interface{} { - return combine.NewBBarResult() -} - -type kClient struct { - c client.Client -} - -func newServiceClient(c client.Client) *kClient { - return &kClient{ - c: c, - } -} - -func (p *kClient) Bar(ctx context.Context) (B_BarClient, error) { - streamClient, ok := p.c.(client.Streaming) - if !ok { - return nil, fmt.Errorf("client not support streaming") - } - res := new(streaming.Result) - err := streamClient.Stream(ctx, "Bar", nil, res) - if err != nil { - return nil, err - } - stream := &bBarClient{res.Stream} - return stream, nil -} diff --git a/thrift_streaming/kitex_gen/combine/b/client.go b/thrift_streaming/kitex_gen/combine/b/client.go deleted file mode 100644 index 828cecf..0000000 --- a/thrift_streaming/kitex_gen/combine/b/client.go +++ /dev/null @@ -1,92 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package b - -import ( - "context" - combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" - client "github.com/cloudwego/kitex/client" - "github.com/cloudwego/kitex/client/callopt/streamcall" - "github.com/cloudwego/kitex/client/streamclient" - streaming "github.com/cloudwego/kitex/pkg/streaming" - transport "github.com/cloudwego/kitex/transport" -) - -// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. -type Client interface { -} - -// StreamClient is designed to provide Interface for Streaming APIs. -type StreamClient interface { - Bar(ctx context.Context, callOptions ...streamcall.Option) (stream B_BarClient, err error) -} - -type B_BarClient interface { - streaming.Stream - Send(*combine.Req) error - Recv() (*combine.Rsp, error) -} - -// NewClient creates a client for the service defined in IDL. -func NewClient(destService string, opts ...client.Option) (Client, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - - options = append(options, opts...) - - kc, err := client.NewClient(serviceInfoForClient(), options...) - if err != nil { - return nil, err - } - return &kBClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. -func MustNewClient(destService string, opts ...client.Option) Client { - kc, err := NewClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kBClient struct { - *kClient -} - -// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - options = append(options, client.WithTransportProtocol(transport.GRPC)) - options = append(options, streamclient.GetClientOptions(opts)...) - - kc, err := client.NewClient(serviceInfoForStreamClient(), options...) - if err != nil { - return nil, err - } - return &kBStreamClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -// It panics if any error occurs. -func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { - kc, err := NewStreamClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kBStreamClient struct { - *kClient -} - -func (p *kBStreamClient) Bar(ctx context.Context, callOptions ...streamcall.Option) (stream B_BarClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.Bar(ctx) -} diff --git a/thrift_streaming/kitex_gen/combine/b/invoker.go b/thrift_streaming/kitex_gen/combine/b/invoker.go deleted file mode 100644 index 2a1760f..0000000 --- a/thrift_streaming/kitex_gen/combine/b/invoker.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package b - -import ( - combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" - server "github.com/cloudwego/kitex/server" -) - -// NewInvoker creates a server.Invoker with the given handler and options. -func NewInvoker(handler combine.B, opts ...server.Option) server.Invoker { - var options []server.Option - - options = append(options, opts...) - - s := server.NewInvoker(options...) - if err := s.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - if err := s.Init(); err != nil { - panic(err) - } - return s -} diff --git a/thrift_streaming/kitex_gen/combine/b/server.go b/thrift_streaming/kitex_gen/combine/b/server.go deleted file mode 100644 index 0987a70..0000000 --- a/thrift_streaming/kitex_gen/combine/b/server.go +++ /dev/null @@ -1,21 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. -package b - -import ( - combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" - server "github.com/cloudwego/kitex/server" -) - -// NewServer creates a server.Server with the given handler and options. -func NewServer(handler combine.B, opts ...server.Option) server.Server { - var options []server.Option - - options = append(options, opts...) - options = append(options, server.WithCompatibleMiddlewareForUnary()) - - svr := server.NewServer(options...) - if err := svr.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - return svr -} diff --git a/thrift_streaming/kitex_gen/combine/combine.go b/thrift_streaming/kitex_gen/combine/combine.go deleted file mode 100644 index 5012c4f..0000000 --- a/thrift_streaming/kitex_gen/combine/combine.go +++ /dev/null @@ -1,1251 +0,0 @@ -// Code generated by thriftgo (0.3.5). DO NOT EDIT. - -package combine - -import ( - "context" - "fmt" - "github.com/apache/thrift/lib/go/thrift" - "github.com/cloudwego/kitex/pkg/streaming" - "strings" -) - -type Req struct { - Message string `thrift:"message,1,required" frugal:"1,required,string" json:"message"` -} - -func NewReq() *Req { - return &Req{} -} - -func (p *Req) InitDefault() { - *p = Req{} -} - -func (p *Req) GetMessage() (v string) { - return p.Message -} -func (p *Req) SetMessage(val string) { - p.Message = val -} - -var fieldIDToName_Req = map[int16]string{ - 1: "message", -} - -func (p *Req) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - var issetMessage bool = false - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - issetMessage = true - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - if !issetMessage { - fieldId = 1 - goto RequiredFieldNotSetError - } - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Req[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_Req[fieldId])) -} - -func (p *Req) ReadField1(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Message = v - } - return nil -} - -func (p *Req) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Req"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *Req) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Message); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *Req) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Req(%+v)", *p) - -} - -func (p *Req) DeepEqual(ano *Req) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Message) { - return false - } - return true -} - -func (p *Req) Field1DeepEqual(src string) bool { - - if strings.Compare(p.Message, src) != 0 { - return false - } - return true -} - -type Rsp struct { - Message string `thrift:"message,1,required" frugal:"1,required,string" json:"message"` -} - -func NewRsp() *Rsp { - return &Rsp{} -} - -func (p *Rsp) InitDefault() { - *p = Rsp{} -} - -func (p *Rsp) GetMessage() (v string) { - return p.Message -} -func (p *Rsp) SetMessage(val string) { - p.Message = val -} - -var fieldIDToName_Rsp = map[int16]string{ - 1: "message", -} - -func (p *Rsp) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - var issetMessage bool = false - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - issetMessage = true - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - if !issetMessage { - fieldId = 1 - goto RequiredFieldNotSetError - } - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Rsp[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_Rsp[fieldId])) -} - -func (p *Rsp) ReadField1(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Message = v - } - return nil -} - -func (p *Rsp) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Rsp"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *Rsp) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Message); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *Rsp) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Rsp(%+v)", *p) - -} - -func (p *Rsp) DeepEqual(ano *Rsp) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Message) { - return false - } - return true -} - -func (p *Rsp) Field1DeepEqual(src string) bool { - - if strings.Compare(p.Message, src) != 0 { - return false - } - return true -} - -type A interface { - Foo(ctx context.Context, req *Req) (r *Rsp, err error) -} - -type AClient struct { - c thrift.TClient -} - -func NewAClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *AClient { - return &AClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewAClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *AClient { - return &AClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewAClient(c thrift.TClient) *AClient { - return &AClient{ - c: c, - } -} - -func (p *AClient) Client_() thrift.TClient { - return p.c -} - -func (p *AClient) Foo(ctx context.Context, req *Req) (r *Rsp, err error) { - var _args AFooArgs - _args.Req = req - var _result AFooResult - if err = p.Client_().Call(ctx, "Foo", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -type B interface { - Bar(stream B_BarServer) (err error) -} - -type BClient struct { - c thrift.TClient -} - -func NewBClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *BClient { - return &BClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewBClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *BClient { - return &BClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewBClient(c thrift.TClient) *BClient { - return &BClient{ - c: c, - } -} - -func (p *BClient) Client_() thrift.TClient { - return p.c -} - -func (p *BClient) Bar(stream B_BarServer) (err error) { - panic("streaming method B.Bar(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") -} - -type B_BarServer interface { - streaming.Stream - - Recv() (*Req, error) - - Send(*Rsp) error -} - -type AProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler A -} - -func (p *AProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *AProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *AProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewAProcessor(handler A) *AProcessor { - self := &AProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("Foo", &aProcessorFoo{handler: handler}) - return self -} -func (p *AProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - name, _, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return false, err - } - if processor, ok := p.GetProcessorFunction(name); ok { - return processor.Process(ctx, seqId, iprot, oprot) - } - iprot.Skip(thrift.STRUCT) - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) - oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, x -} - -type aProcessorFoo struct { - handler A -} - -func (p *aProcessorFoo) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AFooArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("Foo", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := AFooResult{} - var retval *Rsp - if retval, err2 = p.handler.Foo(ctx, args.Req); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Foo: "+err2.Error()) - oprot.WriteMessageBegin("Foo", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("Foo", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type AFooArgs struct { - Req *Req `thrift:"req,1" frugal:"1,default,Req" json:"req"` -} - -func NewAFooArgs() *AFooArgs { - return &AFooArgs{} -} - -func (p *AFooArgs) InitDefault() { - *p = AFooArgs{} -} - -var AFooArgs_Req_DEFAULT *Req - -func (p *AFooArgs) GetReq() (v *Req) { - if !p.IsSetReq() { - return AFooArgs_Req_DEFAULT - } - return p.Req -} -func (p *AFooArgs) SetReq(val *Req) { - p.Req = val -} - -var fieldIDToName_AFooArgs = map[int16]string{ - 1: "req", -} - -func (p *AFooArgs) IsSetReq() bool { - return p.Req != nil -} - -func (p *AFooArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_AFooArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *AFooArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewReq() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *AFooArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Foo_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *AFooArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *AFooArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AFooArgs(%+v)", *p) - -} - -func (p *AFooArgs) DeepEqual(ano *AFooArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *AFooArgs) Field1DeepEqual(src *Req) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true -} - -type AFooResult struct { - Success *Rsp `thrift:"success,0,optional" frugal:"0,optional,Rsp" json:"success,omitempty"` -} - -func NewAFooResult() *AFooResult { - return &AFooResult{} -} - -func (p *AFooResult) InitDefault() { - *p = AFooResult{} -} - -var AFooResult_Success_DEFAULT *Rsp - -func (p *AFooResult) GetSuccess() (v *Rsp) { - if !p.IsSetSuccess() { - return AFooResult_Success_DEFAULT - } - return p.Success -} -func (p *AFooResult) SetSuccess(x interface{}) { - p.Success = x.(*Rsp) -} - -var fieldIDToName_AFooResult = map[int16]string{ - 0: "success", -} - -func (p *AFooResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AFooResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_AFooResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *AFooResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewRsp() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *AFooResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Foo_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *AFooResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - -func (p *AFooResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AFooResult(%+v)", *p) - -} - -func (p *AFooResult) DeepEqual(ano *AFooResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *AFooResult) Field0DeepEqual(src *Rsp) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true -} - -type BProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler B -} - -func (p *BProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *BProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *BProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewBProcessor(handler B) *BProcessor { - self := &BProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("Bar", &bProcessorBar{handler: handler}) - return self -} -func (p *BProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - name, _, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return false, err - } - if processor, ok := p.GetProcessorFunction(name); ok { - return processor.Process(ctx, seqId, iprot, oprot) - } - iprot.Skip(thrift.STRUCT) - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) - oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, x -} - -type bProcessorBar struct { - handler B -} - -func (p *bProcessorBar) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - panic("streaming method B.Bar(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") -} - -type BBarArgs struct { - Req *Req `thrift:"req,1" frugal:"1,default,Req" json:"req"` -} - -func NewBBarArgs() *BBarArgs { - return &BBarArgs{} -} - -func (p *BBarArgs) InitDefault() { - *p = BBarArgs{} -} - -var BBarArgs_Req_DEFAULT *Req - -func (p *BBarArgs) GetReq() (v *Req) { - if !p.IsSetReq() { - return BBarArgs_Req_DEFAULT - } - return p.Req -} -func (p *BBarArgs) SetReq(val *Req) { - p.Req = val -} - -var fieldIDToName_BBarArgs = map[int16]string{ - 1: "req", -} - -func (p *BBarArgs) IsSetReq() bool { - return p.Req != nil -} - -func (p *BBarArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BBarArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BBarArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req = NewReq() - if err := p.Req.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BBarArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Bar_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BBarArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *BBarArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("BBarArgs(%+v)", *p) - -} - -func (p *BBarArgs) DeepEqual(ano *BBarArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req) { - return false - } - return true -} - -func (p *BBarArgs) Field1DeepEqual(src *Req) bool { - - if !p.Req.DeepEqual(src) { - return false - } - return true -} - -type BBarResult struct { - Success *Rsp `thrift:"success,0,optional" frugal:"0,optional,Rsp" json:"success,omitempty"` -} - -func NewBBarResult() *BBarResult { - return &BBarResult{} -} - -func (p *BBarResult) InitDefault() { - *p = BBarResult{} -} - -var BBarResult_Success_DEFAULT *Rsp - -func (p *BBarResult) GetSuccess() (v *Rsp) { - if !p.IsSetSuccess() { - return BBarResult_Success_DEFAULT - } - return p.Success -} -func (p *BBarResult) SetSuccess(x interface{}) { - p.Success = x.(*Rsp) -} - -var fieldIDToName_BBarResult = map[int16]string{ - 0: "success", -} - -func (p *BBarResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *BBarResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BBarResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BBarResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewRsp() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *BBarResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("Bar_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *BBarResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - -func (p *BBarResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("BBarResult(%+v)", *p) - -} - -func (p *BBarResult) DeepEqual(ano *BBarResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *BBarResult) Field0DeepEqual(src *Rsp) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true -} diff --git a/thrift_streaming/kitex_gen/combine/combineservice/client.go b/thrift_streaming/kitex_gen/combine/combineservice/client.go deleted file mode 100644 index 701ff12..0000000 --- a/thrift_streaming/kitex_gen/combine/combineservice/client.go +++ /dev/null @@ -1,99 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package combineservice - -import ( - "context" - combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" - client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" - "github.com/cloudwego/kitex/client/callopt/streamcall" - "github.com/cloudwego/kitex/client/streamclient" - streaming "github.com/cloudwego/kitex/pkg/streaming" - transport "github.com/cloudwego/kitex/transport" -) - -// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. -type Client interface { - Foo(ctx context.Context, req *combine.Req, callOptions ...callopt.Option) (r *combine.Rsp, err error) -} - -// StreamClient is designed to provide Interface for Streaming APIs. -type StreamClient interface { - Bar(ctx context.Context, callOptions ...streamcall.Option) (stream B_BarClient, err error) -} - -type B_BarClient interface { - streaming.Stream - Send(*combine.Req) error - Recv() (*combine.Rsp, error) -} - -// NewClient creates a client for the service defined in IDL. -func NewClient(destService string, opts ...client.Option) (Client, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - - options = append(options, opts...) - - kc, err := client.NewClient(serviceInfoForClient(), options...) - if err != nil { - return nil, err - } - return &kCombineServiceClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. -func MustNewClient(destService string, opts ...client.Option) Client { - kc, err := NewClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kCombineServiceClient struct { - *kClient -} - -func (p *kCombineServiceClient) Foo(ctx context.Context, req *combine.Req, callOptions ...callopt.Option) (r *combine.Rsp, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.Foo(ctx, req) -} - -// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - options = append(options, client.WithTransportProtocol(transport.GRPC)) - options = append(options, streamclient.GetClientOptions(opts)...) - - kc, err := client.NewClient(serviceInfoForStreamClient(), options...) - if err != nil { - return nil, err - } - return &kCombineServiceStreamClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -// It panics if any error occurs. -func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { - kc, err := NewStreamClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kCombineServiceStreamClient struct { - *kClient -} - -func (p *kCombineServiceStreamClient) Bar(ctx context.Context, callOptions ...streamcall.Option) (stream B_BarClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.Bar(ctx) -} diff --git a/thrift_streaming/kitex_gen/combine/combineservice/combineservice.go b/thrift_streaming/kitex_gen/combine/combineservice/combineservice.go deleted file mode 100644 index d6a31b5..0000000 --- a/thrift_streaming/kitex_gen/combine/combineservice/combineservice.go +++ /dev/null @@ -1,197 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package combineservice - -import ( - "context" - "errors" - "fmt" - combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" - client "github.com/cloudwego/kitex/client" - kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" -) - -var errInvalidMessageType = errors.New("invalid message type for service method handler") - -type CombineService interface { - combine.A - combine.B -} - -var serviceMethods = map[string]kitex.MethodInfo{ - "Foo": kitex.NewMethodInfo( - fooHandler, - newAFooArgs, - newAFooResult, - false, - kitex.WithStreamingMode(kitex.StreamingNone), - ), - "Bar": kitex.NewMethodInfo( - barHandler, - newBBarArgs, - newBBarResult, - false, - kitex.WithStreamingMode(kitex.StreamingBidirectional), - ), -} - -var ( - combineServiceServiceInfo = NewServiceInfo() - combineServiceServiceInfoForClient = NewServiceInfoForClient() - combineServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() -) - -// for server -func serviceInfo() *kitex.ServiceInfo { - return combineServiceServiceInfo -} - -// for client -func serviceInfoForStreamClient() *kitex.ServiceInfo { - return combineServiceServiceInfoForStreamClient -} - -// for stream client -func serviceInfoForClient() *kitex.ServiceInfo { - return combineServiceServiceInfoForClient -} - -// NewServiceInfo creates a new ServiceInfo containing all methods -func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(true, true, true) -} - -// NewServiceInfo creates a new ServiceInfo containing non-streaming methods -func NewServiceInfoForClient() *kitex.ServiceInfo { - return newServiceInfo(false, false, true) -} -func NewServiceInfoForStreamClient() *kitex.ServiceInfo { - return newServiceInfo(true, true, false) -} - -func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { - serviceName := "CombineService" - handlerType := (*CombineService)(nil) - methods := map[string]kitex.MethodInfo{} - for name, m := range serviceMethods { - if m.IsStreaming() && !keepStreamingMethods { - continue - } - if !m.IsStreaming() && !keepNonStreamingMethods { - continue - } - methods[name] = m - } - extra := map[string]interface{}{ - "PackageName": "combine", - } - extra["combine_service"] = true - extra["combined_service_list"] = []string{"A", "B"} - if hasStreaming { - extra["streaming"] = hasStreaming - } - svcInfo := &kitex.ServiceInfo{ - ServiceName: serviceName, - HandlerType: handlerType, - Methods: methods, - PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.8.0", - Extra: extra, - } - return svcInfo -} - -func fooHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - realArg := arg.(*combine.AFooArgs) - realResult := result.(*combine.AFooResult) - success, err := handler.(combine.A).Foo(ctx, realArg.Req) - if err != nil { - return err - } - realResult.Success = success - return nil -} -func newAFooArgs() interface{} { - return combine.NewAFooArgs() -} - -func newAFooResult() interface{} { - return combine.NewAFooResult() -} - -func barHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - st, ok := arg.(*streaming.Args) - if !ok { - return errors.New("B.Bar is a thrift streaming method, please call with Kitex StreamClient") - } - stream := &bBarServer{st.Stream} - return handler.(combine.B).Bar(stream) -} - -type bBarClient struct { - streaming.Stream -} - -func (x *bBarClient) Send(m *combine.Req) error { - return x.Stream.SendMsg(m) -} -func (x *bBarClient) Recv() (*combine.Rsp, error) { - m := new(combine.Rsp) - return m, x.Stream.RecvMsg(m) -} - -type bBarServer struct { - streaming.Stream -} - -func (x *bBarServer) Send(m *combine.Rsp) error { - return x.Stream.SendMsg(m) -} - -func (x *bBarServer) Recv() (*combine.Req, error) { - m := new(combine.Req) - return m, x.Stream.RecvMsg(m) -} - -func newBBarArgs() interface{} { - return combine.NewBBarArgs() -} - -func newBBarResult() interface{} { - return combine.NewBBarResult() -} - -type kClient struct { - c client.Client -} - -func newServiceClient(c client.Client) *kClient { - return &kClient{ - c: c, - } -} - -func (p *kClient) Foo(ctx context.Context, req *combine.Req) (r *combine.Rsp, err error) { - var _args combine.AFooArgs - _args.Req = req - var _result combine.AFooResult - if err = p.c.Call(ctx, "Foo", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) Bar(ctx context.Context) (B_BarClient, error) { - streamClient, ok := p.c.(client.Streaming) - if !ok { - return nil, fmt.Errorf("client not support streaming") - } - res := new(streaming.Result) - err := streamClient.Stream(ctx, "Bar", nil, res) - if err != nil { - return nil, err - } - stream := &bBarClient{res.Stream} - return stream, nil -} diff --git a/thrift_streaming/kitex_gen/combine/combineservice/invoker.go b/thrift_streaming/kitex_gen/combine/combineservice/invoker.go deleted file mode 100644 index 5605702..0000000 --- a/thrift_streaming/kitex_gen/combine/combineservice/invoker.go +++ /dev/null @@ -1,23 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package combineservice - -import ( - server "github.com/cloudwego/kitex/server" -) - -// NewInvoker creates a server.Invoker with the given handler and options. -func NewInvoker(handler CombineService, opts ...server.Option) server.Invoker { - var options []server.Option - - options = append(options, opts...) - - s := server.NewInvoker(options...) - if err := s.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - if err := s.Init(); err != nil { - panic(err) - } - return s -} diff --git a/thrift_streaming/kitex_gen/combine/combineservice/server.go b/thrift_streaming/kitex_gen/combine/combineservice/server.go deleted file mode 100644 index 39f663b..0000000 --- a/thrift_streaming/kitex_gen/combine/combineservice/server.go +++ /dev/null @@ -1,20 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. -package combineservice - -import ( - server "github.com/cloudwego/kitex/server" -) - -// NewServer creates a server.Server with the given handler and options. -func NewServer(handler CombineService, opts ...server.Option) server.Server { - var options []server.Option - - options = append(options, opts...) - options = append(options, server.WithCompatibleMiddlewareForUnary()) - - svr := server.NewServer(options...) - if err := svr.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - return svr -} diff --git a/thrift_streaming/kitex_gen/combine/k-combine.go b/thrift_streaming/kitex_gen/combine/k-combine.go deleted file mode 100644 index eca2fed..0000000 --- a/thrift_streaming/kitex_gen/combine/k-combine.go +++ /dev/null @@ -1,832 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package combine - -import ( - "bytes" - "fmt" - "reflect" - "strings" - - "github.com/apache/thrift/lib/go/thrift" - - "github.com/cloudwego/kitex/pkg/protocol/bthrift" -) - -// unused protection -var ( - _ = fmt.Formatter(nil) - _ = (*bytes.Buffer)(nil) - _ = (*strings.Builder)(nil) - _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) -) - -func (p *Req) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - var issetMessage bool = false - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetMessage = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - if !issetMessage { - fieldId = 1 - goto RequiredFieldNotSetError - } - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Req[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_Req[fieldId])) -} - -func (p *Req) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Message = v - - } - return offset, nil -} - -// for compatibility -func (p *Req) FastWrite(buf []byte) int { - return 0 -} - -func (p *Req) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Req") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *Req) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Req") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *Req) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Req) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Message) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *Rsp) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - var issetMessage bool = false - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetMessage = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - if !issetMessage { - fieldId = 1 - goto RequiredFieldNotSetError - } - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Rsp[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_Rsp[fieldId])) -} - -func (p *Rsp) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Message = v - - } - return offset, nil -} - -// for compatibility -func (p *Rsp) FastWrite(buf []byte) int { - return 0 -} - -func (p *Rsp) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Rsp") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *Rsp) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Rsp") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *Rsp) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *Rsp) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Message) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *AFooArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_AFooArgs[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *AFooArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - - tmp := NewReq() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Req = tmp - return offset, nil -} - -// for compatibility -func (p *AFooArgs) FastWrite(buf []byte) int { - return 0 -} - -func (p *AFooArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Foo_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *AFooArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Foo_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *AFooArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *AFooArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *AFooResult) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_AFooResult[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *AFooResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - - tmp := NewRsp() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Success = tmp - return offset, nil -} - -// for compatibility -func (p *AFooResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *AFooResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Foo_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *AFooResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Foo_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *AFooResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *AFooResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *BBarArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BBarArgs[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BBarArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - - tmp := NewReq() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Req = tmp - return offset, nil -} - -// for compatibility -func (p *BBarArgs) FastWrite(buf []byte) int { - return 0 -} - -func (p *BBarArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Bar_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *BBarArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Bar_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *BBarArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) - offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *BBarArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) - l += p.Req.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *BBarResult) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BBarResult[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *BBarResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - - tmp := NewRsp() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Success = tmp - return offset, nil -} - -// for compatibility -func (p *BBarResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *BBarResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Bar_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *BBarResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Bar_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *BBarResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *BBarResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *AFooArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *AFooResult) GetResult() interface{} { - return p.Success -} - -func (p *BBarArgs) GetFirstArgument() interface{} { - return p.Req -} - -func (p *BBarResult) GetResult() interface{} { - return p.Success -} diff --git a/thrift_streaming/kitex_gen/combine/k-consts.go b/thrift_streaming/kitex_gen/combine/k-consts.go deleted file mode 100644 index 653b83e..0000000 --- a/thrift_streaming/kitex_gen/combine/k-consts.go +++ /dev/null @@ -1,4 +0,0 @@ -package combine - -// KitexUnusedProtection is used to prevent 'imported and not used' error. -var KitexUnusedProtection = struct{}{} diff --git a/thrift_streaming/kitex_gen/combine_extend/a/a.go b/thrift_streaming/kitex_gen/combine_extend/a/a.go deleted file mode 100644 index fc84980..0000000 --- a/thrift_streaming/kitex_gen/combine_extend/a/a.go +++ /dev/null @@ -1,126 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package a - -import ( - "context" - "errors" - combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine_extend" - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - client "github.com/cloudwego/kitex/client" - kitex "github.com/cloudwego/kitex/pkg/serviceinfo" -) - -var errInvalidMessageType = errors.New("invalid message type for service method handler") - -var serviceMethods = map[string]kitex.MethodInfo{ - "EchoPingPongNew": kitex.NewMethodInfo( - echoPingPongNewHandler, - newPingPongOnlyServiceEchoPingPongNewArgs, - newPingPongOnlyServiceEchoPingPongNewResult, - false, - kitex.WithStreamingMode(kitex.StreamingNone), - ), -} - -var ( - aServiceInfo = NewServiceInfo() - aServiceInfoForClient = NewServiceInfoForClient() - aServiceInfoForStreamClient = NewServiceInfoForStreamClient() -) - -// for server -func serviceInfo() *kitex.ServiceInfo { - return aServiceInfo -} - -// for client -func serviceInfoForStreamClient() *kitex.ServiceInfo { - return aServiceInfoForStreamClient -} - -// for stream client -func serviceInfoForClient() *kitex.ServiceInfo { - return aServiceInfoForClient -} - -// NewServiceInfo creates a new ServiceInfo containing all methods -func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(false, true, true) -} - -// NewServiceInfo creates a new ServiceInfo containing non-streaming methods -func NewServiceInfoForClient() *kitex.ServiceInfo { - return newServiceInfo(false, false, true) -} -func NewServiceInfoForStreamClient() *kitex.ServiceInfo { - return newServiceInfo(true, true, false) -} - -func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { - serviceName := "A" - handlerType := (*combine_extend.A)(nil) - methods := map[string]kitex.MethodInfo{} - for name, m := range serviceMethods { - if m.IsStreaming() && !keepStreamingMethods { - continue - } - if !m.IsStreaming() && !keepNonStreamingMethods { - continue - } - methods[name] = m - } - extra := map[string]interface{}{ - "PackageName": "combine_extend", - } - if hasStreaming { - extra["streaming"] = hasStreaming - } - svcInfo := &kitex.ServiceInfo{ - ServiceName: serviceName, - HandlerType: handlerType, - Methods: methods, - PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.8.0", - Extra: extra, - } - return svcInfo -} - -func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) - realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) - success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) - if err != nil { - return err - } - realResult.Success = success - return nil -} -func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { - return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() -} - -func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { - return echo.NewPingPongOnlyServiceEchoPingPongNewResult() -} - -type kClient struct { - c client.Client -} - -func newServiceClient(c client.Client) *kClient { - return &kClient{ - c: c, - } -} - -func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { - var _args echo.PingPongOnlyServiceEchoPingPongNewArgs - _args.Req1 = req1 - var _result echo.PingPongOnlyServiceEchoPingPongNewResult - if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} diff --git a/thrift_streaming/kitex_gen/combine_extend/a/client.go b/thrift_streaming/kitex_gen/combine_extend/a/client.go deleted file mode 100644 index 5b397f3..0000000 --- a/thrift_streaming/kitex_gen/combine_extend/a/client.go +++ /dev/null @@ -1,49 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package a - -import ( - "context" - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" -) - -// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. -type Client interface { - EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) -} - -// NewClient creates a client for the service defined in IDL. -func NewClient(destService string, opts ...client.Option) (Client, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - - options = append(options, opts...) - - kc, err := client.NewClient(serviceInfoForClient(), options...) - if err != nil { - return nil, err - } - return &kAClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. -func MustNewClient(destService string, opts ...client.Option) Client { - kc, err := NewClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kAClient struct { - *kClient -} - -func (p *kAClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.EchoPingPongNew(ctx, req1) -} diff --git a/thrift_streaming/kitex_gen/combine_extend/a/invoker.go b/thrift_streaming/kitex_gen/combine_extend/a/invoker.go deleted file mode 100644 index 18adccc..0000000 --- a/thrift_streaming/kitex_gen/combine_extend/a/invoker.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package a - -import ( - combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine_extend" - server "github.com/cloudwego/kitex/server" -) - -// NewInvoker creates a server.Invoker with the given handler and options. -func NewInvoker(handler combine_extend.A, opts ...server.Option) server.Invoker { - var options []server.Option - - options = append(options, opts...) - - s := server.NewInvoker(options...) - if err := s.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - if err := s.Init(); err != nil { - panic(err) - } - return s -} diff --git a/thrift_streaming/kitex_gen/combine_extend/a/server.go b/thrift_streaming/kitex_gen/combine_extend/a/server.go deleted file mode 100644 index fcfeef1..0000000 --- a/thrift_streaming/kitex_gen/combine_extend/a/server.go +++ /dev/null @@ -1,21 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. -package a - -import ( - combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine_extend" - server "github.com/cloudwego/kitex/server" -) - -// NewServer creates a server.Server with the given handler and options. -func NewServer(handler combine_extend.A, opts ...server.Option) server.Server { - var options []server.Option - - options = append(options, opts...) - options = append(options, server.WithCompatibleMiddlewareForUnary()) - - svr := server.NewServer(options...) - if err := svr.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - return svr -} diff --git a/thrift_streaming/kitex_gen/combine_extend/b/b.go b/thrift_streaming/kitex_gen/combine_extend/b/b.go deleted file mode 100644 index 3d7980f..0000000 --- a/thrift_streaming/kitex_gen/combine_extend/b/b.go +++ /dev/null @@ -1,156 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package b - -import ( - "context" - "errors" - "fmt" - combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine_extend" - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - client "github.com/cloudwego/kitex/client" - kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" -) - -var errInvalidMessageType = errors.New("invalid message type for service method handler") - -var serviceMethods = map[string]kitex.MethodInfo{ - "EchoBidirectionalNew": kitex.NewMethodInfo( - echoBidirectionalNewHandler, - newStreamOnlyServiceEchoBidirectionalNewArgs, - newStreamOnlyServiceEchoBidirectionalNewResult, - false, - kitex.WithStreamingMode(kitex.StreamingBidirectional), - ), -} - -var ( - bServiceInfo = NewServiceInfo() - bServiceInfoForClient = NewServiceInfoForClient() - bServiceInfoForStreamClient = NewServiceInfoForStreamClient() -) - -// for server -func serviceInfo() *kitex.ServiceInfo { - return bServiceInfo -} - -// for client -func serviceInfoForStreamClient() *kitex.ServiceInfo { - return bServiceInfoForStreamClient -} - -// for stream client -func serviceInfoForClient() *kitex.ServiceInfo { - return bServiceInfoForClient -} - -// NewServiceInfo creates a new ServiceInfo containing all methods -func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(true, true, true) -} - -// NewServiceInfo creates a new ServiceInfo containing non-streaming methods -func NewServiceInfoForClient() *kitex.ServiceInfo { - return newServiceInfo(false, false, true) -} -func NewServiceInfoForStreamClient() *kitex.ServiceInfo { - return newServiceInfo(true, true, false) -} - -func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { - serviceName := "B" - handlerType := (*combine_extend.B)(nil) - methods := map[string]kitex.MethodInfo{} - for name, m := range serviceMethods { - if m.IsStreaming() && !keepStreamingMethods { - continue - } - if !m.IsStreaming() && !keepNonStreamingMethods { - continue - } - methods[name] = m - } - extra := map[string]interface{}{ - "PackageName": "combine_extend", - } - if hasStreaming { - extra["streaming"] = hasStreaming - } - svcInfo := &kitex.ServiceInfo{ - ServiceName: serviceName, - HandlerType: handlerType, - Methods: methods, - PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.8.0", - Extra: extra, - } - return svcInfo -} - -func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - st, ok := arg.(*streaming.Args) - if !ok { - return errors.New("StreamOnlyService.EchoBidirectionalNew is a thrift streaming method, please call with Kitex StreamClient") - } - stream := &streamOnlyServiceEchoBidirectionalNewServer{st.Stream} - return handler.(echo.StreamOnlyService).EchoBidirectionalNew(stream) -} - -type streamOnlyServiceEchoBidirectionalNewClient struct { - streaming.Stream -} - -func (x *streamOnlyServiceEchoBidirectionalNewClient) Send(m *echo.EchoRequest) error { - return x.Stream.SendMsg(m) -} -func (x *streamOnlyServiceEchoBidirectionalNewClient) Recv() (*echo.EchoResponse, error) { - m := new(echo.EchoResponse) - return m, x.Stream.RecvMsg(m) -} - -type streamOnlyServiceEchoBidirectionalNewServer struct { - streaming.Stream -} - -func (x *streamOnlyServiceEchoBidirectionalNewServer) Send(m *echo.EchoResponse) error { - return x.Stream.SendMsg(m) -} - -func (x *streamOnlyServiceEchoBidirectionalNewServer) Recv() (*echo.EchoRequest, error) { - m := new(echo.EchoRequest) - return m, x.Stream.RecvMsg(m) -} - -func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { - return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() -} - -func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { - return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() -} - -type kClient struct { - c client.Client -} - -func newServiceClient(c client.Client) *kClient { - return &kClient{ - c: c, - } -} - -func (p *kClient) EchoBidirectionalNew(ctx context.Context) (StreamOnlyService_EchoBidirectionalNewClient, error) { - streamClient, ok := p.c.(client.Streaming) - if !ok { - return nil, fmt.Errorf("client not support streaming") - } - res := new(streaming.Result) - err := streamClient.Stream(ctx, "EchoBidirectionalNew", nil, res) - if err != nil { - return nil, err - } - stream := &streamOnlyServiceEchoBidirectionalNewClient{res.Stream} - return stream, nil -} diff --git a/thrift_streaming/kitex_gen/combine_extend/b/client.go b/thrift_streaming/kitex_gen/combine_extend/b/client.go deleted file mode 100644 index 645ae56..0000000 --- a/thrift_streaming/kitex_gen/combine_extend/b/client.go +++ /dev/null @@ -1,92 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package b - -import ( - "context" - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - client "github.com/cloudwego/kitex/client" - "github.com/cloudwego/kitex/client/callopt/streamcall" - "github.com/cloudwego/kitex/client/streamclient" - streaming "github.com/cloudwego/kitex/pkg/streaming" - transport "github.com/cloudwego/kitex/transport" -) - -// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. -type Client interface { -} - -// StreamClient is designed to provide Interface for Streaming APIs. -type StreamClient interface { - EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) -} - -type StreamOnlyService_EchoBidirectionalNewClient interface { - streaming.Stream - Send(*echo.EchoRequest) error - Recv() (*echo.EchoResponse, error) -} - -// NewClient creates a client for the service defined in IDL. -func NewClient(destService string, opts ...client.Option) (Client, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - - options = append(options, opts...) - - kc, err := client.NewClient(serviceInfoForClient(), options...) - if err != nil { - return nil, err - } - return &kBClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. -func MustNewClient(destService string, opts ...client.Option) Client { - kc, err := NewClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kBClient struct { - *kClient -} - -// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - options = append(options, client.WithTransportProtocol(transport.GRPC)) - options = append(options, streamclient.GetClientOptions(opts)...) - - kc, err := client.NewClient(serviceInfoForStreamClient(), options...) - if err != nil { - return nil, err - } - return &kBStreamClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -// It panics if any error occurs. -func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { - kc, err := NewStreamClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kBStreamClient struct { - *kClient -} - -func (p *kBStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.EchoBidirectionalNew(ctx) -} diff --git a/thrift_streaming/kitex_gen/combine_extend/b/invoker.go b/thrift_streaming/kitex_gen/combine_extend/b/invoker.go deleted file mode 100644 index 3fbd965..0000000 --- a/thrift_streaming/kitex_gen/combine_extend/b/invoker.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package b - -import ( - combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine_extend" - server "github.com/cloudwego/kitex/server" -) - -// NewInvoker creates a server.Invoker with the given handler and options. -func NewInvoker(handler combine_extend.B, opts ...server.Option) server.Invoker { - var options []server.Option - - options = append(options, opts...) - - s := server.NewInvoker(options...) - if err := s.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - if err := s.Init(); err != nil { - panic(err) - } - return s -} diff --git a/thrift_streaming/kitex_gen/combine_extend/b/server.go b/thrift_streaming/kitex_gen/combine_extend/b/server.go deleted file mode 100644 index 54ea26b..0000000 --- a/thrift_streaming/kitex_gen/combine_extend/b/server.go +++ /dev/null @@ -1,21 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. -package b - -import ( - combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine_extend" - server "github.com/cloudwego/kitex/server" -) - -// NewServer creates a server.Server with the given handler and options. -func NewServer(handler combine_extend.B, opts ...server.Option) server.Server { - var options []server.Option - - options = append(options, opts...) - options = append(options, server.WithCompatibleMiddlewareForUnary()) - - svr := server.NewServer(options...) - if err := svr.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - return svr -} diff --git a/thrift_streaming/kitex_gen/combine_extend/combine_extend.go b/thrift_streaming/kitex_gen/combine_extend/combine_extend.go deleted file mode 100644 index 5b86a84..0000000 --- a/thrift_streaming/kitex_gen/combine_extend/combine_extend.go +++ /dev/null @@ -1,78 +0,0 @@ -// Code generated by thriftgo (0.3.5). DO NOT EDIT. - -package combine_extend - -import ( - "github.com/apache/thrift/lib/go/thrift" - "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" -) - -type A interface { - echo.PingPongOnlyService -} - -type AClient struct { - *echo.PingPongOnlyServiceClient -} - -func NewAClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *AClient { - return &AClient{ - PingPongOnlyServiceClient: echo.NewPingPongOnlyServiceClientFactory(t, f), - } -} - -func NewAClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *AClient { - return &AClient{ - PingPongOnlyServiceClient: echo.NewPingPongOnlyServiceClientProtocol(t, iprot, oprot), - } -} - -func NewAClient(c thrift.TClient) *AClient { - return &AClient{ - PingPongOnlyServiceClient: echo.NewPingPongOnlyServiceClient(c), - } -} - -type B interface { - echo.StreamOnlyServiceChildChild -} - -type BClient struct { - *echo.StreamOnlyServiceChildChildClient -} - -func NewBClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *BClient { - return &BClient{ - StreamOnlyServiceChildChildClient: echo.NewStreamOnlyServiceChildChildClientFactory(t, f), - } -} - -func NewBClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *BClient { - return &BClient{ - StreamOnlyServiceChildChildClient: echo.NewStreamOnlyServiceChildChildClientProtocol(t, iprot, oprot), - } -} - -func NewBClient(c thrift.TClient) *BClient { - return &BClient{ - StreamOnlyServiceChildChildClient: echo.NewStreamOnlyServiceChildChildClient(c), - } -} - -type AProcessor struct { - *echo.PingPongOnlyServiceProcessor -} - -func NewAProcessor(handler A) *AProcessor { - self := &AProcessor{echo.NewPingPongOnlyServiceProcessor(handler)} - return self -} - -type BProcessor struct { - *echo.StreamOnlyServiceChildChildProcessor -} - -func NewBProcessor(handler B) *BProcessor { - self := &BProcessor{echo.NewStreamOnlyServiceChildChildProcessor(handler)} - return self -} diff --git a/thrift_streaming/kitex_gen/combine_extend/combineservice/client.go b/thrift_streaming/kitex_gen/combine_extend/combineservice/client.go deleted file mode 100644 index 6d71e8d..0000000 --- a/thrift_streaming/kitex_gen/combine_extend/combineservice/client.go +++ /dev/null @@ -1,99 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package combineservice - -import ( - "context" - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" - "github.com/cloudwego/kitex/client/callopt/streamcall" - "github.com/cloudwego/kitex/client/streamclient" - streaming "github.com/cloudwego/kitex/pkg/streaming" - transport "github.com/cloudwego/kitex/transport" -) - -// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. -type Client interface { - EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) -} - -// StreamClient is designed to provide Interface for Streaming APIs. -type StreamClient interface { - EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) -} - -type StreamOnlyService_EchoBidirectionalNewClient interface { - streaming.Stream - Send(*echo.EchoRequest) error - Recv() (*echo.EchoResponse, error) -} - -// NewClient creates a client for the service defined in IDL. -func NewClient(destService string, opts ...client.Option) (Client, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - - options = append(options, opts...) - - kc, err := client.NewClient(serviceInfoForClient(), options...) - if err != nil { - return nil, err - } - return &kCombineServiceClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. -func MustNewClient(destService string, opts ...client.Option) Client { - kc, err := NewClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kCombineServiceClient struct { - *kClient -} - -func (p *kCombineServiceClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.EchoPingPongNew(ctx, req1) -} - -// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - options = append(options, client.WithTransportProtocol(transport.GRPC)) - options = append(options, streamclient.GetClientOptions(opts)...) - - kc, err := client.NewClient(serviceInfoForStreamClient(), options...) - if err != nil { - return nil, err - } - return &kCombineServiceStreamClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -// It panics if any error occurs. -func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { - kc, err := NewStreamClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kCombineServiceStreamClient struct { - *kClient -} - -func (p *kCombineServiceStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.EchoBidirectionalNew(ctx) -} diff --git a/thrift_streaming/kitex_gen/combine_extend/combineservice/combineservice.go b/thrift_streaming/kitex_gen/combine_extend/combineservice/combineservice.go deleted file mode 100644 index 12b5f62..0000000 --- a/thrift_streaming/kitex_gen/combine_extend/combineservice/combineservice.go +++ /dev/null @@ -1,198 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package combineservice - -import ( - "context" - "errors" - "fmt" - combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine_extend" - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - client "github.com/cloudwego/kitex/client" - kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" -) - -var errInvalidMessageType = errors.New("invalid message type for service method handler") - -type CombineService interface { - combine_extend.A - combine_extend.B -} - -var serviceMethods = map[string]kitex.MethodInfo{ - "EchoPingPongNew": kitex.NewMethodInfo( - echoPingPongNewHandler, - newPingPongOnlyServiceEchoPingPongNewArgs, - newPingPongOnlyServiceEchoPingPongNewResult, - false, - kitex.WithStreamingMode(kitex.StreamingNone), - ), - "EchoBidirectionalNew": kitex.NewMethodInfo( - echoBidirectionalNewHandler, - newStreamOnlyServiceEchoBidirectionalNewArgs, - newStreamOnlyServiceEchoBidirectionalNewResult, - false, - kitex.WithStreamingMode(kitex.StreamingBidirectional), - ), -} - -var ( - combineServiceServiceInfo = NewServiceInfo() - combineServiceServiceInfoForClient = NewServiceInfoForClient() - combineServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() -) - -// for server -func serviceInfo() *kitex.ServiceInfo { - return combineServiceServiceInfo -} - -// for client -func serviceInfoForStreamClient() *kitex.ServiceInfo { - return combineServiceServiceInfoForStreamClient -} - -// for stream client -func serviceInfoForClient() *kitex.ServiceInfo { - return combineServiceServiceInfoForClient -} - -// NewServiceInfo creates a new ServiceInfo containing all methods -func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(true, true, true) -} - -// NewServiceInfo creates a new ServiceInfo containing non-streaming methods -func NewServiceInfoForClient() *kitex.ServiceInfo { - return newServiceInfo(false, false, true) -} -func NewServiceInfoForStreamClient() *kitex.ServiceInfo { - return newServiceInfo(true, true, false) -} - -func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { - serviceName := "CombineService" - handlerType := (*CombineService)(nil) - methods := map[string]kitex.MethodInfo{} - for name, m := range serviceMethods { - if m.IsStreaming() && !keepStreamingMethods { - continue - } - if !m.IsStreaming() && !keepNonStreamingMethods { - continue - } - methods[name] = m - } - extra := map[string]interface{}{ - "PackageName": "combine_extend", - } - extra["combine_service"] = true - extra["combined_service_list"] = []string{"A", "B"} - if hasStreaming { - extra["streaming"] = hasStreaming - } - svcInfo := &kitex.ServiceInfo{ - ServiceName: serviceName, - HandlerType: handlerType, - Methods: methods, - PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.8.0", - Extra: extra, - } - return svcInfo -} - -func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) - realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) - success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) - if err != nil { - return err - } - realResult.Success = success - return nil -} -func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { - return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() -} - -func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { - return echo.NewPingPongOnlyServiceEchoPingPongNewResult() -} - -func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - st, ok := arg.(*streaming.Args) - if !ok { - return errors.New("StreamOnlyService.EchoBidirectionalNew is a thrift streaming method, please call with Kitex StreamClient") - } - stream := &streamOnlyServiceEchoBidirectionalNewServer{st.Stream} - return handler.(echo.StreamOnlyService).EchoBidirectionalNew(stream) -} - -type streamOnlyServiceEchoBidirectionalNewClient struct { - streaming.Stream -} - -func (x *streamOnlyServiceEchoBidirectionalNewClient) Send(m *echo.EchoRequest) error { - return x.Stream.SendMsg(m) -} -func (x *streamOnlyServiceEchoBidirectionalNewClient) Recv() (*echo.EchoResponse, error) { - m := new(echo.EchoResponse) - return m, x.Stream.RecvMsg(m) -} - -type streamOnlyServiceEchoBidirectionalNewServer struct { - streaming.Stream -} - -func (x *streamOnlyServiceEchoBidirectionalNewServer) Send(m *echo.EchoResponse) error { - return x.Stream.SendMsg(m) -} - -func (x *streamOnlyServiceEchoBidirectionalNewServer) Recv() (*echo.EchoRequest, error) { - m := new(echo.EchoRequest) - return m, x.Stream.RecvMsg(m) -} - -func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { - return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() -} - -func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { - return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() -} - -type kClient struct { - c client.Client -} - -func newServiceClient(c client.Client) *kClient { - return &kClient{ - c: c, - } -} - -func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { - var _args echo.PingPongOnlyServiceEchoPingPongNewArgs - _args.Req1 = req1 - var _result echo.PingPongOnlyServiceEchoPingPongNewResult - if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) EchoBidirectionalNew(ctx context.Context) (StreamOnlyService_EchoBidirectionalNewClient, error) { - streamClient, ok := p.c.(client.Streaming) - if !ok { - return nil, fmt.Errorf("client not support streaming") - } - res := new(streaming.Result) - err := streamClient.Stream(ctx, "EchoBidirectionalNew", nil, res) - if err != nil { - return nil, err - } - stream := &streamOnlyServiceEchoBidirectionalNewClient{res.Stream} - return stream, nil -} diff --git a/thrift_streaming/kitex_gen/combine_extend/combineservice/invoker.go b/thrift_streaming/kitex_gen/combine_extend/combineservice/invoker.go deleted file mode 100644 index 5605702..0000000 --- a/thrift_streaming/kitex_gen/combine_extend/combineservice/invoker.go +++ /dev/null @@ -1,23 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package combineservice - -import ( - server "github.com/cloudwego/kitex/server" -) - -// NewInvoker creates a server.Invoker with the given handler and options. -func NewInvoker(handler CombineService, opts ...server.Option) server.Invoker { - var options []server.Option - - options = append(options, opts...) - - s := server.NewInvoker(options...) - if err := s.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - if err := s.Init(); err != nil { - panic(err) - } - return s -} diff --git a/thrift_streaming/kitex_gen/combine_extend/combineservice/server.go b/thrift_streaming/kitex_gen/combine_extend/combineservice/server.go deleted file mode 100644 index 39f663b..0000000 --- a/thrift_streaming/kitex_gen/combine_extend/combineservice/server.go +++ /dev/null @@ -1,20 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. -package combineservice - -import ( - server "github.com/cloudwego/kitex/server" -) - -// NewServer creates a server.Server with the given handler and options. -func NewServer(handler CombineService, opts ...server.Option) server.Server { - var options []server.Option - - options = append(options, opts...) - options = append(options, server.WithCompatibleMiddlewareForUnary()) - - svr := server.NewServer(options...) - if err := svr.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - return svr -} diff --git a/thrift_streaming/kitex_gen/combine_extend/k-combine_extend.go b/thrift_streaming/kitex_gen/combine_extend/k-combine_extend.go deleted file mode 100644 index 0eabf31..0000000 --- a/thrift_streaming/kitex_gen/combine_extend/k-combine_extend.go +++ /dev/null @@ -1,27 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package combine_extend - -import ( - "bytes" - "fmt" - "reflect" - "strings" - - "github.com/apache/thrift/lib/go/thrift" - - "github.com/cloudwego/kitex/pkg/protocol/bthrift" - - "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" -) - -// unused protection -var ( - _ = fmt.Formatter(nil) - _ = (*bytes.Buffer)(nil) - _ = (*strings.Builder)(nil) - _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) - _ = echo.KitexUnusedProtection -) diff --git a/thrift_streaming/kitex_gen/combine_extend/k-consts.go b/thrift_streaming/kitex_gen/combine_extend/k-consts.go deleted file mode 100644 index 8e5ff02..0000000 --- a/thrift_streaming/kitex_gen/combine_extend/k-consts.go +++ /dev/null @@ -1,4 +0,0 @@ -package combine_extend - -// KitexUnusedProtection is used to prevent 'imported and not used' error. -var KitexUnusedProtection = struct{}{} diff --git a/thrift_streaming/kitex_gen/echo/api.go b/thrift_streaming/kitex_gen/echo/api.go deleted file mode 100644 index 7923db3..0000000 --- a/thrift_streaming/kitex_gen/echo/api.go +++ /dev/null @@ -1,4530 +0,0 @@ -// Code generated by thriftgo (0.3.5). DO NOT EDIT. - -package echo - -import ( - "context" - "fmt" - "github.com/apache/thrift/lib/go/thrift" - "github.com/cloudwego/kitex/pkg/streaming" - "strings" -) - -type EchoRequest struct { - Message string `thrift:"message,1,required" frugal:"1,required,string" json:"message"` -} - -func NewEchoRequest() *EchoRequest { - return &EchoRequest{} -} - -func (p *EchoRequest) InitDefault() { - *p = EchoRequest{} -} - -func (p *EchoRequest) GetMessage() (v string) { - return p.Message -} -func (p *EchoRequest) SetMessage(val string) { - p.Message = val -} - -var fieldIDToName_EchoRequest = map[int16]string{ - 1: "message", -} - -func (p *EchoRequest) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - var issetMessage bool = false - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - issetMessage = true - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - if !issetMessage { - fieldId = 1 - goto RequiredFieldNotSetError - } - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoRequest[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_EchoRequest[fieldId])) -} - -func (p *EchoRequest) ReadField1(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Message = v - } - return nil -} - -func (p *EchoRequest) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoRequest"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *EchoRequest) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Message); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *EchoRequest) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("EchoRequest(%+v)", *p) - -} - -func (p *EchoRequest) DeepEqual(ano *EchoRequest) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Message) { - return false - } - return true -} - -func (p *EchoRequest) Field1DeepEqual(src string) bool { - - if strings.Compare(p.Message, src) != 0 { - return false - } - return true -} - -type EchoResponse struct { - Message string `thrift:"message,1,required" frugal:"1,required,string" json:"message"` -} - -func NewEchoResponse() *EchoResponse { - return &EchoResponse{} -} - -func (p *EchoResponse) InitDefault() { - *p = EchoResponse{} -} - -func (p *EchoResponse) GetMessage() (v string) { - return p.Message -} -func (p *EchoResponse) SetMessage(val string) { - p.Message = val -} - -var fieldIDToName_EchoResponse = map[int16]string{ - 1: "message", -} - -func (p *EchoResponse) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - var issetMessage bool = false - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - issetMessage = true - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - if !issetMessage { - fieldId = 1 - goto RequiredFieldNotSetError - } - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoResponse[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_EchoResponse[fieldId])) -} - -func (p *EchoResponse) ReadField1(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Message = v - } - return nil -} - -func (p *EchoResponse) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoResponse"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *EchoResponse) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Message); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *EchoResponse) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("EchoResponse(%+v)", *p) - -} - -func (p *EchoResponse) DeepEqual(ano *EchoResponse) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Message) { - return false - } - return true -} - -func (p *EchoResponse) Field1DeepEqual(src string) bool { - - if strings.Compare(p.Message, src) != 0 { - return false - } - return true -} - -type EchoException struct { - Message string `thrift:"message,1" frugal:"1,default,string" json:"message"` -} - -func NewEchoException() *EchoException { - return &EchoException{} -} - -func (p *EchoException) InitDefault() { - *p = EchoException{} -} - -func (p *EchoException) GetMessage() (v string) { - return p.Message -} -func (p *EchoException) SetMessage(val string) { - p.Message = val -} - -var fieldIDToName_EchoException = map[int16]string{ - 1: "message", -} - -func (p *EchoException) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoException[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoException) ReadField1(iprot thrift.TProtocol) error { - - if v, err := iprot.ReadString(); err != nil { - return err - } else { - p.Message = v - } - return nil -} - -func (p *EchoException) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoException"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *EchoException) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { - goto WriteFieldBeginError - } - if err := oprot.WriteString(p.Message); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *EchoException) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("EchoException(%+v)", *p) - -} -func (p *EchoException) Error() string { - return p.String() -} - -func (p *EchoException) DeepEqual(ano *EchoException) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Message) { - return false - } - return true -} - -func (p *EchoException) Field1DeepEqual(src string) bool { - - if strings.Compare(p.Message, src) != 0 { - return false - } - return true -} - -type EchoService interface { - EchoBidirectional(stream EchoService_EchoBidirectionalServer) (err error) - - EchoClient(stream EchoService_EchoClientServer) (err error) - - EchoServer(req *EchoRequest, stream EchoService_EchoServerServer) (err error) - - EchoUnary(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) - - EchoPingPong(ctx context.Context, req1 *EchoRequest, req2 *EchoRequest) (r *EchoResponse, err error) - - EchoOneway(ctx context.Context, req1 *EchoRequest) (err error) - - Ping(ctx context.Context) (err error) -} - -type EchoServiceClient struct { - c thrift.TClient -} - -func NewEchoServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *EchoServiceClient { - return &EchoServiceClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewEchoServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *EchoServiceClient { - return &EchoServiceClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewEchoServiceClient(c thrift.TClient) *EchoServiceClient { - return &EchoServiceClient{ - c: c, - } -} - -func (p *EchoServiceClient) Client_() thrift.TClient { - return p.c -} - -func (p *EchoServiceClient) EchoBidirectional(stream EchoService_EchoBidirectionalServer) (err error) { - panic("streaming method EchoService.EchoBidirectional(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") -} - -type EchoService_EchoBidirectionalServer interface { - streaming.Stream - - Recv() (*EchoRequest, error) - - Send(*EchoResponse) error -} - -func (p *EchoServiceClient) EchoClient(stream EchoService_EchoClientServer) (err error) { - panic("streaming method EchoService.EchoClient(mode = client) not available, please use Kitex Thrift Streaming Client.") -} - -type EchoService_EchoClientServer interface { - streaming.Stream - - Recv() (*EchoRequest, error) - - SendAndClose(*EchoResponse) error -} - -func (p *EchoServiceClient) EchoServer(req *EchoRequest, stream EchoService_EchoServerServer) (err error) { - panic("streaming method EchoService.EchoServer(mode = server) not available, please use Kitex Thrift Streaming Client.") -} - -type EchoService_EchoServerServer interface { - streaming.Stream - - Send(*EchoResponse) error -} - -func (p *EchoServiceClient) EchoUnary(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) { - panic("streaming method EchoService.EchoUnary(mode = unary) not available, please use Kitex Thrift Streaming Client.") -} -func (p *EchoServiceClient) EchoPingPong(ctx context.Context, req1 *EchoRequest, req2 *EchoRequest) (r *EchoResponse, err error) { - var _args EchoServiceEchoPingPongArgs - _args.Req1 = req1 - _args.Req2 = req2 - var _result EchoServiceEchoPingPongResult - if err = p.Client_().Call(ctx, "EchoPingPong", &_args, &_result); err != nil { - return - } - switch { - case _result.E != nil: - return r, _result.E - } - return _result.GetSuccess(), nil -} -func (p *EchoServiceClient) EchoOneway(ctx context.Context, req1 *EchoRequest) (err error) { - var _args EchoServiceEchoOnewayArgs - _args.Req1 = req1 - var _result EchoServiceEchoOnewayResult - if err = p.Client_().Call(ctx, "EchoOneway", &_args, &_result); err != nil { - return - } - return nil -} -func (p *EchoServiceClient) Ping(ctx context.Context) (err error) { - var _args EchoServicePingArgs - var _result EchoServicePingResult - if err = p.Client_().Call(ctx, "Ping", &_args, &_result); err != nil { - return - } - return nil -} - -type PingPongOnlyService interface { - EchoPingPongNew(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) -} - -type PingPongOnlyServiceClient struct { - c thrift.TClient -} - -func NewPingPongOnlyServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *PingPongOnlyServiceClient { - return &PingPongOnlyServiceClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewPingPongOnlyServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *PingPongOnlyServiceClient { - return &PingPongOnlyServiceClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewPingPongOnlyServiceClient(c thrift.TClient) *PingPongOnlyServiceClient { - return &PingPongOnlyServiceClient{ - c: c, - } -} - -func (p *PingPongOnlyServiceClient) Client_() thrift.TClient { - return p.c -} - -func (p *PingPongOnlyServiceClient) EchoPingPongNew(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) { - var _args PingPongOnlyServiceEchoPingPongNewArgs - _args.Req1 = req1 - var _result PingPongOnlyServiceEchoPingPongNewResult - if err = p.Client_().Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -type PingPongOnlyServiceChild interface { - PingPongOnlyService - - EchoBidirectionalExtended(stream PingPongOnlyServiceChild_EchoBidirectionalExtendedServer) (err error) -} - -type PingPongOnlyServiceChildClient struct { - *PingPongOnlyServiceClient -} - -func NewPingPongOnlyServiceChildClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *PingPongOnlyServiceChildClient { - return &PingPongOnlyServiceChildClient{ - PingPongOnlyServiceClient: NewPingPongOnlyServiceClientFactory(t, f), - } -} - -func NewPingPongOnlyServiceChildClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *PingPongOnlyServiceChildClient { - return &PingPongOnlyServiceChildClient{ - PingPongOnlyServiceClient: NewPingPongOnlyServiceClientProtocol(t, iprot, oprot), - } -} - -func NewPingPongOnlyServiceChildClient(c thrift.TClient) *PingPongOnlyServiceChildClient { - return &PingPongOnlyServiceChildClient{ - PingPongOnlyServiceClient: NewPingPongOnlyServiceClient(c), - } -} - -func (p *PingPongOnlyServiceChildClient) EchoBidirectionalExtended(stream PingPongOnlyServiceChild_EchoBidirectionalExtendedServer) (err error) { - panic("streaming method PingPongOnlyServiceChild.EchoBidirectionalExtended(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") -} - -type PingPongOnlyServiceChild_EchoBidirectionalExtendedServer interface { - streaming.Stream - - Recv() (*EchoRequest, error) - - Send(*EchoResponse) error -} - -type PingPongOnlyServiceChildChild interface { - PingPongOnlyServiceChild -} - -type PingPongOnlyServiceChildChildClient struct { - *PingPongOnlyServiceChildClient -} - -func NewPingPongOnlyServiceChildChildClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *PingPongOnlyServiceChildChildClient { - return &PingPongOnlyServiceChildChildClient{ - PingPongOnlyServiceChildClient: NewPingPongOnlyServiceChildClientFactory(t, f), - } -} - -func NewPingPongOnlyServiceChildChildClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *PingPongOnlyServiceChildChildClient { - return &PingPongOnlyServiceChildChildClient{ - PingPongOnlyServiceChildClient: NewPingPongOnlyServiceChildClientProtocol(t, iprot, oprot), - } -} - -func NewPingPongOnlyServiceChildChildClient(c thrift.TClient) *PingPongOnlyServiceChildChildClient { - return &PingPongOnlyServiceChildChildClient{ - PingPongOnlyServiceChildClient: NewPingPongOnlyServiceChildClient(c), - } -} - -type StreamOnlyService interface { - EchoBidirectionalNew(stream StreamOnlyService_EchoBidirectionalNewServer) (err error) -} - -type StreamOnlyServiceClient struct { - c thrift.TClient -} - -func NewStreamOnlyServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *StreamOnlyServiceClient { - return &StreamOnlyServiceClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -func NewStreamOnlyServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *StreamOnlyServiceClient { - return &StreamOnlyServiceClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewStreamOnlyServiceClient(c thrift.TClient) *StreamOnlyServiceClient { - return &StreamOnlyServiceClient{ - c: c, - } -} - -func (p *StreamOnlyServiceClient) Client_() thrift.TClient { - return p.c -} - -func (p *StreamOnlyServiceClient) EchoBidirectionalNew(stream StreamOnlyService_EchoBidirectionalNewServer) (err error) { - panic("streaming method StreamOnlyService.EchoBidirectionalNew(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") -} - -type StreamOnlyService_EchoBidirectionalNewServer interface { - streaming.Stream - - Recv() (*EchoRequest, error) - - Send(*EchoResponse) error -} - -type StreamOnlyServiceChild interface { - StreamOnlyService -} - -type StreamOnlyServiceChildClient struct { - *StreamOnlyServiceClient -} - -func NewStreamOnlyServiceChildClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *StreamOnlyServiceChildClient { - return &StreamOnlyServiceChildClient{ - StreamOnlyServiceClient: NewStreamOnlyServiceClientFactory(t, f), - } -} - -func NewStreamOnlyServiceChildClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *StreamOnlyServiceChildClient { - return &StreamOnlyServiceChildClient{ - StreamOnlyServiceClient: NewStreamOnlyServiceClientProtocol(t, iprot, oprot), - } -} - -func NewStreamOnlyServiceChildClient(c thrift.TClient) *StreamOnlyServiceChildClient { - return &StreamOnlyServiceChildClient{ - StreamOnlyServiceClient: NewStreamOnlyServiceClient(c), - } -} - -type StreamOnlyServiceChildChild interface { - StreamOnlyServiceChild -} - -type StreamOnlyServiceChildChildClient struct { - *StreamOnlyServiceChildClient -} - -func NewStreamOnlyServiceChildChildClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *StreamOnlyServiceChildChildClient { - return &StreamOnlyServiceChildChildClient{ - StreamOnlyServiceChildClient: NewStreamOnlyServiceChildClientFactory(t, f), - } -} - -func NewStreamOnlyServiceChildChildClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *StreamOnlyServiceChildChildClient { - return &StreamOnlyServiceChildChildClient{ - StreamOnlyServiceChildClient: NewStreamOnlyServiceChildClientProtocol(t, iprot, oprot), - } -} - -func NewStreamOnlyServiceChildChildClient(c thrift.TClient) *StreamOnlyServiceChildChildClient { - return &StreamOnlyServiceChildChildClient{ - StreamOnlyServiceChildClient: NewStreamOnlyServiceChildClient(c), - } -} - -type EchoServiceProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler EchoService -} - -func (p *EchoServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *EchoServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *EchoServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewEchoServiceProcessor(handler EchoService) *EchoServiceProcessor { - self := &EchoServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("EchoBidirectional", &echoServiceProcessorEchoBidirectional{handler: handler}) - self.AddToProcessorMap("EchoClient", &echoServiceProcessorEchoClient{handler: handler}) - self.AddToProcessorMap("EchoServer", &echoServiceProcessorEchoServer{handler: handler}) - self.AddToProcessorMap("EchoUnary", &echoServiceProcessorEchoUnary{handler: handler}) - self.AddToProcessorMap("EchoPingPong", &echoServiceProcessorEchoPingPong{handler: handler}) - self.AddToProcessorMap("EchoOneway", &echoServiceProcessorEchoOneway{handler: handler}) - self.AddToProcessorMap("Ping", &echoServiceProcessorPing{handler: handler}) - return self -} -func (p *EchoServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - name, _, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return false, err - } - if processor, ok := p.GetProcessorFunction(name); ok { - return processor.Process(ctx, seqId, iprot, oprot) - } - iprot.Skip(thrift.STRUCT) - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) - oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, x -} - -type echoServiceProcessorEchoBidirectional struct { - handler EchoService -} - -func (p *echoServiceProcessorEchoBidirectional) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - panic("streaming method EchoService.EchoBidirectional(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") -} - -type echoServiceProcessorEchoClient struct { - handler EchoService -} - -func (p *echoServiceProcessorEchoClient) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - panic("streaming method EchoService.EchoClient(mode = client) not available, please use Kitex Thrift Streaming Client.") -} - -type echoServiceProcessorEchoServer struct { - handler EchoService -} - -func (p *echoServiceProcessorEchoServer) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - panic("streaming method EchoService.EchoServer(mode = server) not available, please use Kitex Thrift Streaming Client.") -} - -type echoServiceProcessorEchoUnary struct { - handler EchoService -} - -func (p *echoServiceProcessorEchoUnary) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - panic("streaming method EchoService.EchoUnary(mode = unary) not available, please use Kitex Thrift Streaming Client.") -} - -type echoServiceProcessorEchoPingPong struct { - handler EchoService -} - -func (p *echoServiceProcessorEchoPingPong) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := EchoServiceEchoPingPongArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("EchoPingPong", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := EchoServiceEchoPingPongResult{} - var retval *EchoResponse - if retval, err2 = p.handler.EchoPingPong(ctx, args.Req1, args.Req2); err2 != nil { - switch v := err2.(type) { - case *EchoException: - result.E = v - default: - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoPingPong: "+err2.Error()) - oprot.WriteMessageBegin("EchoPingPong", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("EchoPingPong", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type echoServiceProcessorEchoOneway struct { - handler EchoService -} - -func (p *echoServiceProcessorEchoOneway) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := EchoServiceEchoOnewayArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("EchoOneway", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := EchoServiceEchoOnewayResult{} - if err2 = p.handler.EchoOneway(ctx, args.Req1); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoOneway: "+err2.Error()) - oprot.WriteMessageBegin("EchoOneway", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } - if err2 = oprot.WriteMessageBegin("EchoOneway", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type echoServiceProcessorPing struct { - handler EchoService -} - -func (p *echoServiceProcessorPing) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := EchoServicePingArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("Ping", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := EchoServicePingResult{} - if err2 = p.handler.Ping(ctx); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Ping: "+err2.Error()) - oprot.WriteMessageBegin("Ping", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } - if err2 = oprot.WriteMessageBegin("Ping", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type EchoServiceEchoBidirectionalArgs struct { - Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` -} - -func NewEchoServiceEchoBidirectionalArgs() *EchoServiceEchoBidirectionalArgs { - return &EchoServiceEchoBidirectionalArgs{} -} - -func (p *EchoServiceEchoBidirectionalArgs) InitDefault() { - *p = EchoServiceEchoBidirectionalArgs{} -} - -var EchoServiceEchoBidirectionalArgs_Req1_DEFAULT *EchoRequest - -func (p *EchoServiceEchoBidirectionalArgs) GetReq1() (v *EchoRequest) { - if !p.IsSetReq1() { - return EchoServiceEchoBidirectionalArgs_Req1_DEFAULT - } - return p.Req1 -} -func (p *EchoServiceEchoBidirectionalArgs) SetReq1(val *EchoRequest) { - p.Req1 = val -} - -var fieldIDToName_EchoServiceEchoBidirectionalArgs = map[int16]string{ - 1: "req1", -} - -func (p *EchoServiceEchoBidirectionalArgs) IsSetReq1() bool { - return p.Req1 != nil -} - -func (p *EchoServiceEchoBidirectionalArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoBidirectionalArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoBidirectionalArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req1 = NewEchoRequest() - if err := p.Req1.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *EchoServiceEchoBidirectionalArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoBidirectional_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *EchoServiceEchoBidirectionalArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req1.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *EchoServiceEchoBidirectionalArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("EchoServiceEchoBidirectionalArgs(%+v)", *p) - -} - -func (p *EchoServiceEchoBidirectionalArgs) DeepEqual(ano *EchoServiceEchoBidirectionalArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req1) { - return false - } - return true -} - -func (p *EchoServiceEchoBidirectionalArgs) Field1DeepEqual(src *EchoRequest) bool { - - if !p.Req1.DeepEqual(src) { - return false - } - return true -} - -type EchoServiceEchoBidirectionalResult struct { - Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` -} - -func NewEchoServiceEchoBidirectionalResult() *EchoServiceEchoBidirectionalResult { - return &EchoServiceEchoBidirectionalResult{} -} - -func (p *EchoServiceEchoBidirectionalResult) InitDefault() { - *p = EchoServiceEchoBidirectionalResult{} -} - -var EchoServiceEchoBidirectionalResult_Success_DEFAULT *EchoResponse - -func (p *EchoServiceEchoBidirectionalResult) GetSuccess() (v *EchoResponse) { - if !p.IsSetSuccess() { - return EchoServiceEchoBidirectionalResult_Success_DEFAULT - } - return p.Success -} -func (p *EchoServiceEchoBidirectionalResult) SetSuccess(x interface{}) { - p.Success = x.(*EchoResponse) -} - -var fieldIDToName_EchoServiceEchoBidirectionalResult = map[int16]string{ - 0: "success", -} - -func (p *EchoServiceEchoBidirectionalResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *EchoServiceEchoBidirectionalResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoBidirectionalResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoBidirectionalResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewEchoResponse() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *EchoServiceEchoBidirectionalResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoBidirectional_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *EchoServiceEchoBidirectionalResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - -func (p *EchoServiceEchoBidirectionalResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("EchoServiceEchoBidirectionalResult(%+v)", *p) - -} - -func (p *EchoServiceEchoBidirectionalResult) DeepEqual(ano *EchoServiceEchoBidirectionalResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *EchoServiceEchoBidirectionalResult) Field0DeepEqual(src *EchoResponse) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true -} - -type EchoServiceEchoClientArgs struct { - Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` -} - -func NewEchoServiceEchoClientArgs() *EchoServiceEchoClientArgs { - return &EchoServiceEchoClientArgs{} -} - -func (p *EchoServiceEchoClientArgs) InitDefault() { - *p = EchoServiceEchoClientArgs{} -} - -var EchoServiceEchoClientArgs_Req1_DEFAULT *EchoRequest - -func (p *EchoServiceEchoClientArgs) GetReq1() (v *EchoRequest) { - if !p.IsSetReq1() { - return EchoServiceEchoClientArgs_Req1_DEFAULT - } - return p.Req1 -} -func (p *EchoServiceEchoClientArgs) SetReq1(val *EchoRequest) { - p.Req1 = val -} - -var fieldIDToName_EchoServiceEchoClientArgs = map[int16]string{ - 1: "req1", -} - -func (p *EchoServiceEchoClientArgs) IsSetReq1() bool { - return p.Req1 != nil -} - -func (p *EchoServiceEchoClientArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoClientArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoClientArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req1 = NewEchoRequest() - if err := p.Req1.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *EchoServiceEchoClientArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoClient_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *EchoServiceEchoClientArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req1.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *EchoServiceEchoClientArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("EchoServiceEchoClientArgs(%+v)", *p) - -} - -func (p *EchoServiceEchoClientArgs) DeepEqual(ano *EchoServiceEchoClientArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req1) { - return false - } - return true -} - -func (p *EchoServiceEchoClientArgs) Field1DeepEqual(src *EchoRequest) bool { - - if !p.Req1.DeepEqual(src) { - return false - } - return true -} - -type EchoServiceEchoClientResult struct { - Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` -} - -func NewEchoServiceEchoClientResult() *EchoServiceEchoClientResult { - return &EchoServiceEchoClientResult{} -} - -func (p *EchoServiceEchoClientResult) InitDefault() { - *p = EchoServiceEchoClientResult{} -} - -var EchoServiceEchoClientResult_Success_DEFAULT *EchoResponse - -func (p *EchoServiceEchoClientResult) GetSuccess() (v *EchoResponse) { - if !p.IsSetSuccess() { - return EchoServiceEchoClientResult_Success_DEFAULT - } - return p.Success -} -func (p *EchoServiceEchoClientResult) SetSuccess(x interface{}) { - p.Success = x.(*EchoResponse) -} - -var fieldIDToName_EchoServiceEchoClientResult = map[int16]string{ - 0: "success", -} - -func (p *EchoServiceEchoClientResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *EchoServiceEchoClientResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoClientResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoClientResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewEchoResponse() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *EchoServiceEchoClientResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoClient_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *EchoServiceEchoClientResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - -func (p *EchoServiceEchoClientResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("EchoServiceEchoClientResult(%+v)", *p) - -} - -func (p *EchoServiceEchoClientResult) DeepEqual(ano *EchoServiceEchoClientResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *EchoServiceEchoClientResult) Field0DeepEqual(src *EchoResponse) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true -} - -type EchoServiceEchoServerArgs struct { - Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` -} - -func NewEchoServiceEchoServerArgs() *EchoServiceEchoServerArgs { - return &EchoServiceEchoServerArgs{} -} - -func (p *EchoServiceEchoServerArgs) InitDefault() { - *p = EchoServiceEchoServerArgs{} -} - -var EchoServiceEchoServerArgs_Req1_DEFAULT *EchoRequest - -func (p *EchoServiceEchoServerArgs) GetReq1() (v *EchoRequest) { - if !p.IsSetReq1() { - return EchoServiceEchoServerArgs_Req1_DEFAULT - } - return p.Req1 -} -func (p *EchoServiceEchoServerArgs) SetReq1(val *EchoRequest) { - p.Req1 = val -} - -var fieldIDToName_EchoServiceEchoServerArgs = map[int16]string{ - 1: "req1", -} - -func (p *EchoServiceEchoServerArgs) IsSetReq1() bool { - return p.Req1 != nil -} - -func (p *EchoServiceEchoServerArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoServerArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoServerArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req1 = NewEchoRequest() - if err := p.Req1.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *EchoServiceEchoServerArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoServer_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *EchoServiceEchoServerArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req1.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *EchoServiceEchoServerArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("EchoServiceEchoServerArgs(%+v)", *p) - -} - -func (p *EchoServiceEchoServerArgs) DeepEqual(ano *EchoServiceEchoServerArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req1) { - return false - } - return true -} - -func (p *EchoServiceEchoServerArgs) Field1DeepEqual(src *EchoRequest) bool { - - if !p.Req1.DeepEqual(src) { - return false - } - return true -} - -type EchoServiceEchoServerResult struct { - Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` -} - -func NewEchoServiceEchoServerResult() *EchoServiceEchoServerResult { - return &EchoServiceEchoServerResult{} -} - -func (p *EchoServiceEchoServerResult) InitDefault() { - *p = EchoServiceEchoServerResult{} -} - -var EchoServiceEchoServerResult_Success_DEFAULT *EchoResponse - -func (p *EchoServiceEchoServerResult) GetSuccess() (v *EchoResponse) { - if !p.IsSetSuccess() { - return EchoServiceEchoServerResult_Success_DEFAULT - } - return p.Success -} -func (p *EchoServiceEchoServerResult) SetSuccess(x interface{}) { - p.Success = x.(*EchoResponse) -} - -var fieldIDToName_EchoServiceEchoServerResult = map[int16]string{ - 0: "success", -} - -func (p *EchoServiceEchoServerResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *EchoServiceEchoServerResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoServerResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoServerResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewEchoResponse() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *EchoServiceEchoServerResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoServer_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *EchoServiceEchoServerResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - -func (p *EchoServiceEchoServerResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("EchoServiceEchoServerResult(%+v)", *p) - -} - -func (p *EchoServiceEchoServerResult) DeepEqual(ano *EchoServiceEchoServerResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *EchoServiceEchoServerResult) Field0DeepEqual(src *EchoResponse) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true -} - -type EchoServiceEchoUnaryArgs struct { - Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` -} - -func NewEchoServiceEchoUnaryArgs() *EchoServiceEchoUnaryArgs { - return &EchoServiceEchoUnaryArgs{} -} - -func (p *EchoServiceEchoUnaryArgs) InitDefault() { - *p = EchoServiceEchoUnaryArgs{} -} - -var EchoServiceEchoUnaryArgs_Req1_DEFAULT *EchoRequest - -func (p *EchoServiceEchoUnaryArgs) GetReq1() (v *EchoRequest) { - if !p.IsSetReq1() { - return EchoServiceEchoUnaryArgs_Req1_DEFAULT - } - return p.Req1 -} -func (p *EchoServiceEchoUnaryArgs) SetReq1(val *EchoRequest) { - p.Req1 = val -} - -var fieldIDToName_EchoServiceEchoUnaryArgs = map[int16]string{ - 1: "req1", -} - -func (p *EchoServiceEchoUnaryArgs) IsSetReq1() bool { - return p.Req1 != nil -} - -func (p *EchoServiceEchoUnaryArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoUnaryArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoUnaryArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req1 = NewEchoRequest() - if err := p.Req1.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *EchoServiceEchoUnaryArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoUnary_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *EchoServiceEchoUnaryArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req1.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *EchoServiceEchoUnaryArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("EchoServiceEchoUnaryArgs(%+v)", *p) - -} - -func (p *EchoServiceEchoUnaryArgs) DeepEqual(ano *EchoServiceEchoUnaryArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req1) { - return false - } - return true -} - -func (p *EchoServiceEchoUnaryArgs) Field1DeepEqual(src *EchoRequest) bool { - - if !p.Req1.DeepEqual(src) { - return false - } - return true -} - -type EchoServiceEchoUnaryResult struct { - Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` -} - -func NewEchoServiceEchoUnaryResult() *EchoServiceEchoUnaryResult { - return &EchoServiceEchoUnaryResult{} -} - -func (p *EchoServiceEchoUnaryResult) InitDefault() { - *p = EchoServiceEchoUnaryResult{} -} - -var EchoServiceEchoUnaryResult_Success_DEFAULT *EchoResponse - -func (p *EchoServiceEchoUnaryResult) GetSuccess() (v *EchoResponse) { - if !p.IsSetSuccess() { - return EchoServiceEchoUnaryResult_Success_DEFAULT - } - return p.Success -} -func (p *EchoServiceEchoUnaryResult) SetSuccess(x interface{}) { - p.Success = x.(*EchoResponse) -} - -var fieldIDToName_EchoServiceEchoUnaryResult = map[int16]string{ - 0: "success", -} - -func (p *EchoServiceEchoUnaryResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *EchoServiceEchoUnaryResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoUnaryResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoUnaryResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewEchoResponse() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *EchoServiceEchoUnaryResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoUnary_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *EchoServiceEchoUnaryResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - -func (p *EchoServiceEchoUnaryResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("EchoServiceEchoUnaryResult(%+v)", *p) - -} - -func (p *EchoServiceEchoUnaryResult) DeepEqual(ano *EchoServiceEchoUnaryResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *EchoServiceEchoUnaryResult) Field0DeepEqual(src *EchoResponse) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true -} - -type EchoServiceEchoPingPongArgs struct { - Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` - Req2 *EchoRequest `thrift:"req2,2" frugal:"2,default,EchoRequest" json:"req2"` -} - -func NewEchoServiceEchoPingPongArgs() *EchoServiceEchoPingPongArgs { - return &EchoServiceEchoPingPongArgs{} -} - -func (p *EchoServiceEchoPingPongArgs) InitDefault() { - *p = EchoServiceEchoPingPongArgs{} -} - -var EchoServiceEchoPingPongArgs_Req1_DEFAULT *EchoRequest - -func (p *EchoServiceEchoPingPongArgs) GetReq1() (v *EchoRequest) { - if !p.IsSetReq1() { - return EchoServiceEchoPingPongArgs_Req1_DEFAULT - } - return p.Req1 -} - -var EchoServiceEchoPingPongArgs_Req2_DEFAULT *EchoRequest - -func (p *EchoServiceEchoPingPongArgs) GetReq2() (v *EchoRequest) { - if !p.IsSetReq2() { - return EchoServiceEchoPingPongArgs_Req2_DEFAULT - } - return p.Req2 -} -func (p *EchoServiceEchoPingPongArgs) SetReq1(val *EchoRequest) { - p.Req1 = val -} -func (p *EchoServiceEchoPingPongArgs) SetReq2(val *EchoRequest) { - p.Req2 = val -} - -var fieldIDToName_EchoServiceEchoPingPongArgs = map[int16]string{ - 1: "req1", - 2: "req2", -} - -func (p *EchoServiceEchoPingPongArgs) IsSetReq1() bool { - return p.Req1 != nil -} - -func (p *EchoServiceEchoPingPongArgs) IsSetReq2() bool { - return p.Req2 != nil -} - -func (p *EchoServiceEchoPingPongArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 2: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField2(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoPingPongArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoPingPongArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req1 = NewEchoRequest() - if err := p.Req1.Read(iprot); err != nil { - return err - } - return nil -} -func (p *EchoServiceEchoPingPongArgs) ReadField2(iprot thrift.TProtocol) error { - p.Req2 = NewEchoRequest() - if err := p.Req2.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *EchoServiceEchoPingPongArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoPingPong_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - if err = p.writeField2(oprot); err != nil { - fieldId = 2 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *EchoServiceEchoPingPongArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req1.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *EchoServiceEchoPingPongArgs) writeField2(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req2", thrift.STRUCT, 2); err != nil { - goto WriteFieldBeginError - } - if err := p.Req2.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) -} - -func (p *EchoServiceEchoPingPongArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("EchoServiceEchoPingPongArgs(%+v)", *p) - -} - -func (p *EchoServiceEchoPingPongArgs) DeepEqual(ano *EchoServiceEchoPingPongArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req1) { - return false - } - if !p.Field2DeepEqual(ano.Req2) { - return false - } - return true -} - -func (p *EchoServiceEchoPingPongArgs) Field1DeepEqual(src *EchoRequest) bool { - - if !p.Req1.DeepEqual(src) { - return false - } - return true -} -func (p *EchoServiceEchoPingPongArgs) Field2DeepEqual(src *EchoRequest) bool { - - if !p.Req2.DeepEqual(src) { - return false - } - return true -} - -type EchoServiceEchoPingPongResult struct { - Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` - E *EchoException `thrift:"e,1,optional" frugal:"1,optional,EchoException" json:"e,omitempty"` -} - -func NewEchoServiceEchoPingPongResult() *EchoServiceEchoPingPongResult { - return &EchoServiceEchoPingPongResult{} -} - -func (p *EchoServiceEchoPingPongResult) InitDefault() { - *p = EchoServiceEchoPingPongResult{} -} - -var EchoServiceEchoPingPongResult_Success_DEFAULT *EchoResponse - -func (p *EchoServiceEchoPingPongResult) GetSuccess() (v *EchoResponse) { - if !p.IsSetSuccess() { - return EchoServiceEchoPingPongResult_Success_DEFAULT - } - return p.Success -} - -var EchoServiceEchoPingPongResult_E_DEFAULT *EchoException - -func (p *EchoServiceEchoPingPongResult) GetE() (v *EchoException) { - if !p.IsSetE() { - return EchoServiceEchoPingPongResult_E_DEFAULT - } - return p.E -} -func (p *EchoServiceEchoPingPongResult) SetSuccess(x interface{}) { - p.Success = x.(*EchoResponse) -} -func (p *EchoServiceEchoPingPongResult) SetE(val *EchoException) { - p.E = val -} - -var fieldIDToName_EchoServiceEchoPingPongResult = map[int16]string{ - 0: "success", - 1: "e", -} - -func (p *EchoServiceEchoPingPongResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *EchoServiceEchoPingPongResult) IsSetE() bool { - return p.E != nil -} - -func (p *EchoServiceEchoPingPongResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoPingPongResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoPingPongResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewEchoResponse() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} -func (p *EchoServiceEchoPingPongResult) ReadField1(iprot thrift.TProtocol) error { - p.E = NewEchoException() - if err := p.E.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *EchoServiceEchoPingPongResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoPingPong_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *EchoServiceEchoPingPongResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - -func (p *EchoServiceEchoPingPongResult) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetE() { - if err = oprot.WriteFieldBegin("e", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.E.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *EchoServiceEchoPingPongResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("EchoServiceEchoPingPongResult(%+v)", *p) - -} - -func (p *EchoServiceEchoPingPongResult) DeepEqual(ano *EchoServiceEchoPingPongResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - if !p.Field1DeepEqual(ano.E) { - return false - } - return true -} - -func (p *EchoServiceEchoPingPongResult) Field0DeepEqual(src *EchoResponse) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true -} -func (p *EchoServiceEchoPingPongResult) Field1DeepEqual(src *EchoException) bool { - - if !p.E.DeepEqual(src) { - return false - } - return true -} - -type EchoServiceEchoOnewayArgs struct { - Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` -} - -func NewEchoServiceEchoOnewayArgs() *EchoServiceEchoOnewayArgs { - return &EchoServiceEchoOnewayArgs{} -} - -func (p *EchoServiceEchoOnewayArgs) InitDefault() { - *p = EchoServiceEchoOnewayArgs{} -} - -var EchoServiceEchoOnewayArgs_Req1_DEFAULT *EchoRequest - -func (p *EchoServiceEchoOnewayArgs) GetReq1() (v *EchoRequest) { - if !p.IsSetReq1() { - return EchoServiceEchoOnewayArgs_Req1_DEFAULT - } - return p.Req1 -} -func (p *EchoServiceEchoOnewayArgs) SetReq1(val *EchoRequest) { - p.Req1 = val -} - -var fieldIDToName_EchoServiceEchoOnewayArgs = map[int16]string{ - 1: "req1", -} - -func (p *EchoServiceEchoOnewayArgs) IsSetReq1() bool { - return p.Req1 != nil -} - -func (p *EchoServiceEchoOnewayArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoOnewayArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoOnewayArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req1 = NewEchoRequest() - if err := p.Req1.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *EchoServiceEchoOnewayArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoOneway_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *EchoServiceEchoOnewayArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req1.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *EchoServiceEchoOnewayArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("EchoServiceEchoOnewayArgs(%+v)", *p) - -} - -func (p *EchoServiceEchoOnewayArgs) DeepEqual(ano *EchoServiceEchoOnewayArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req1) { - return false - } - return true -} - -func (p *EchoServiceEchoOnewayArgs) Field1DeepEqual(src *EchoRequest) bool { - - if !p.Req1.DeepEqual(src) { - return false - } - return true -} - -type EchoServiceEchoOnewayResult struct { -} - -func NewEchoServiceEchoOnewayResult() *EchoServiceEchoOnewayResult { - return &EchoServiceEchoOnewayResult{} -} - -func (p *EchoServiceEchoOnewayResult) InitDefault() { - *p = EchoServiceEchoOnewayResult{} -} - -var fieldIDToName_EchoServiceEchoOnewayResult = map[int16]string{} - -func (p *EchoServiceEchoOnewayResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldTypeError - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -SkipFieldTypeError: - return thrift.PrependError(fmt.Sprintf("%T skip field type %d error", p, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoOnewayResult) Write(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteStructBegin("EchoOneway_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *EchoServiceEchoOnewayResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("EchoServiceEchoOnewayResult(%+v)", *p) - -} - -func (p *EchoServiceEchoOnewayResult) DeepEqual(ano *EchoServiceEchoOnewayResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - return true -} - -type EchoServicePingArgs struct { -} - -func NewEchoServicePingArgs() *EchoServicePingArgs { - return &EchoServicePingArgs{} -} - -func (p *EchoServicePingArgs) InitDefault() { - *p = EchoServicePingArgs{} -} - -var fieldIDToName_EchoServicePingArgs = map[int16]string{} - -func (p *EchoServicePingArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldTypeError - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -SkipFieldTypeError: - return thrift.PrependError(fmt.Sprintf("%T skip field type %d error", p, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServicePingArgs) Write(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteStructBegin("Ping_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *EchoServicePingArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("EchoServicePingArgs(%+v)", *p) - -} - -func (p *EchoServicePingArgs) DeepEqual(ano *EchoServicePingArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - return true -} - -type EchoServicePingResult struct { -} - -func NewEchoServicePingResult() *EchoServicePingResult { - return &EchoServicePingResult{} -} - -func (p *EchoServicePingResult) InitDefault() { - *p = EchoServicePingResult{} -} - -var fieldIDToName_EchoServicePingResult = map[int16]string{} - -func (p *EchoServicePingResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldTypeError - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -SkipFieldTypeError: - return thrift.PrependError(fmt.Sprintf("%T skip field type %d error", p, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServicePingResult) Write(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteStructBegin("Ping_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *EchoServicePingResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("EchoServicePingResult(%+v)", *p) - -} - -func (p *EchoServicePingResult) DeepEqual(ano *EchoServicePingResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - return true -} - -type PingPongOnlyServiceProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler PingPongOnlyService -} - -func (p *PingPongOnlyServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *PingPongOnlyServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *PingPongOnlyServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewPingPongOnlyServiceProcessor(handler PingPongOnlyService) *PingPongOnlyServiceProcessor { - self := &PingPongOnlyServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("EchoPingPongNew", &pingPongOnlyServiceProcessorEchoPingPongNew{handler: handler}) - return self -} -func (p *PingPongOnlyServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - name, _, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return false, err - } - if processor, ok := p.GetProcessorFunction(name); ok { - return processor.Process(ctx, seqId, iprot, oprot) - } - iprot.Skip(thrift.STRUCT) - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) - oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, x -} - -type pingPongOnlyServiceProcessorEchoPingPongNew struct { - handler PingPongOnlyService -} - -func (p *pingPongOnlyServiceProcessorEchoPingPongNew) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := PingPongOnlyServiceEchoPingPongNewArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("EchoPingPongNew", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, err - } - - iprot.ReadMessageEnd() - var err2 error - result := PingPongOnlyServiceEchoPingPongNewResult{} - var retval *EchoResponse - if retval, err2 = p.handler.EchoPingPongNew(ctx, args.Req1); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoPingPongNew: "+err2.Error()) - oprot.WriteMessageBegin("EchoPingPongNew", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("EchoPingPongNew", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(ctx); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type PingPongOnlyServiceEchoPingPongNewArgs struct { - Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` -} - -func NewPingPongOnlyServiceEchoPingPongNewArgs() *PingPongOnlyServiceEchoPingPongNewArgs { - return &PingPongOnlyServiceEchoPingPongNewArgs{} -} - -func (p *PingPongOnlyServiceEchoPingPongNewArgs) InitDefault() { - *p = PingPongOnlyServiceEchoPingPongNewArgs{} -} - -var PingPongOnlyServiceEchoPingPongNewArgs_Req1_DEFAULT *EchoRequest - -func (p *PingPongOnlyServiceEchoPingPongNewArgs) GetReq1() (v *EchoRequest) { - if !p.IsSetReq1() { - return PingPongOnlyServiceEchoPingPongNewArgs_Req1_DEFAULT - } - return p.Req1 -} -func (p *PingPongOnlyServiceEchoPingPongNewArgs) SetReq1(val *EchoRequest) { - p.Req1 = val -} - -var fieldIDToName_PingPongOnlyServiceEchoPingPongNewArgs = map[int16]string{ - 1: "req1", -} - -func (p *PingPongOnlyServiceEchoPingPongNewArgs) IsSetReq1() bool { - return p.Req1 != nil -} - -func (p *PingPongOnlyServiceEchoPingPongNewArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongNewArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *PingPongOnlyServiceEchoPingPongNewArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req1 = NewEchoRequest() - if err := p.Req1.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *PingPongOnlyServiceEchoPingPongNewArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoPingPongNew_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *PingPongOnlyServiceEchoPingPongNewArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req1.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *PingPongOnlyServiceEchoPingPongNewArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("PingPongOnlyServiceEchoPingPongNewArgs(%+v)", *p) - -} - -func (p *PingPongOnlyServiceEchoPingPongNewArgs) DeepEqual(ano *PingPongOnlyServiceEchoPingPongNewArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req1) { - return false - } - return true -} - -func (p *PingPongOnlyServiceEchoPingPongNewArgs) Field1DeepEqual(src *EchoRequest) bool { - - if !p.Req1.DeepEqual(src) { - return false - } - return true -} - -type PingPongOnlyServiceEchoPingPongNewResult struct { - Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` -} - -func NewPingPongOnlyServiceEchoPingPongNewResult() *PingPongOnlyServiceEchoPingPongNewResult { - return &PingPongOnlyServiceEchoPingPongNewResult{} -} - -func (p *PingPongOnlyServiceEchoPingPongNewResult) InitDefault() { - *p = PingPongOnlyServiceEchoPingPongNewResult{} -} - -var PingPongOnlyServiceEchoPingPongNewResult_Success_DEFAULT *EchoResponse - -func (p *PingPongOnlyServiceEchoPingPongNewResult) GetSuccess() (v *EchoResponse) { - if !p.IsSetSuccess() { - return PingPongOnlyServiceEchoPingPongNewResult_Success_DEFAULT - } - return p.Success -} -func (p *PingPongOnlyServiceEchoPingPongNewResult) SetSuccess(x interface{}) { - p.Success = x.(*EchoResponse) -} - -var fieldIDToName_PingPongOnlyServiceEchoPingPongNewResult = map[int16]string{ - 0: "success", -} - -func (p *PingPongOnlyServiceEchoPingPongNewResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *PingPongOnlyServiceEchoPingPongNewResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongNewResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *PingPongOnlyServiceEchoPingPongNewResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewEchoResponse() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *PingPongOnlyServiceEchoPingPongNewResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoPingPongNew_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *PingPongOnlyServiceEchoPingPongNewResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - -func (p *PingPongOnlyServiceEchoPingPongNewResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("PingPongOnlyServiceEchoPingPongNewResult(%+v)", *p) - -} - -func (p *PingPongOnlyServiceEchoPingPongNewResult) DeepEqual(ano *PingPongOnlyServiceEchoPingPongNewResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *PingPongOnlyServiceEchoPingPongNewResult) Field0DeepEqual(src *EchoResponse) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true -} - -type PingPongOnlyServiceChildProcessor struct { - *PingPongOnlyServiceProcessor -} - -func NewPingPongOnlyServiceChildProcessor(handler PingPongOnlyServiceChild) *PingPongOnlyServiceChildProcessor { - self := &PingPongOnlyServiceChildProcessor{NewPingPongOnlyServiceProcessor(handler)} - self.AddToProcessorMap("EchoBidirectionalExtended", &pingPongOnlyServiceChildProcessorEchoBidirectionalExtended{handler: handler}) - return self -} - -type pingPongOnlyServiceChildProcessorEchoBidirectionalExtended struct { - handler PingPongOnlyServiceChild -} - -func (p *pingPongOnlyServiceChildProcessorEchoBidirectionalExtended) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - panic("streaming method PingPongOnlyServiceChild.EchoBidirectionalExtended(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") -} - -type PingPongOnlyServiceChildEchoBidirectionalExtendedArgs struct { - Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` -} - -func NewPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs { - return &PingPongOnlyServiceChildEchoBidirectionalExtendedArgs{} -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) InitDefault() { - *p = PingPongOnlyServiceChildEchoBidirectionalExtendedArgs{} -} - -var PingPongOnlyServiceChildEchoBidirectionalExtendedArgs_Req1_DEFAULT *EchoRequest - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) GetReq1() (v *EchoRequest) { - if !p.IsSetReq1() { - return PingPongOnlyServiceChildEchoBidirectionalExtendedArgs_Req1_DEFAULT - } - return p.Req1 -} -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) SetReq1(val *EchoRequest) { - p.Req1 = val -} - -var fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedArgs = map[int16]string{ - 1: "req1", -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) IsSetReq1() bool { - return p.Req1 != nil -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req1 = NewEchoRequest() - if err := p.Req1.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoBidirectionalExtended_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req1.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("PingPongOnlyServiceChildEchoBidirectionalExtendedArgs(%+v)", *p) - -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) DeepEqual(ano *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req1) { - return false - } - return true -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) Field1DeepEqual(src *EchoRequest) bool { - - if !p.Req1.DeepEqual(src) { - return false - } - return true -} - -type PingPongOnlyServiceChildEchoBidirectionalExtendedResult struct { - Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` -} - -func NewPingPongOnlyServiceChildEchoBidirectionalExtendedResult() *PingPongOnlyServiceChildEchoBidirectionalExtendedResult { - return &PingPongOnlyServiceChildEchoBidirectionalExtendedResult{} -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) InitDefault() { - *p = PingPongOnlyServiceChildEchoBidirectionalExtendedResult{} -} - -var PingPongOnlyServiceChildEchoBidirectionalExtendedResult_Success_DEFAULT *EchoResponse - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) GetSuccess() (v *EchoResponse) { - if !p.IsSetSuccess() { - return PingPongOnlyServiceChildEchoBidirectionalExtendedResult_Success_DEFAULT - } - return p.Success -} -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) SetSuccess(x interface{}) { - p.Success = x.(*EchoResponse) -} - -var fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedResult = map[int16]string{ - 0: "success", -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewEchoResponse() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoBidirectionalExtended_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("PingPongOnlyServiceChildEchoBidirectionalExtendedResult(%+v)", *p) - -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) DeepEqual(ano *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) Field0DeepEqual(src *EchoResponse) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true -} - -type PingPongOnlyServiceChildChildProcessor struct { - *PingPongOnlyServiceChildProcessor -} - -func NewPingPongOnlyServiceChildChildProcessor(handler PingPongOnlyServiceChildChild) *PingPongOnlyServiceChildChildProcessor { - self := &PingPongOnlyServiceChildChildProcessor{NewPingPongOnlyServiceChildProcessor(handler)} - return self -} - -type StreamOnlyServiceProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler StreamOnlyService -} - -func (p *StreamOnlyServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *StreamOnlyServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *StreamOnlyServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewStreamOnlyServiceProcessor(handler StreamOnlyService) *StreamOnlyServiceProcessor { - self := &StreamOnlyServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self.AddToProcessorMap("EchoBidirectionalNew", &streamOnlyServiceProcessorEchoBidirectionalNew{handler: handler}) - return self -} -func (p *StreamOnlyServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - name, _, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return false, err - } - if processor, ok := p.GetProcessorFunction(name); ok { - return processor.Process(ctx, seqId, iprot, oprot) - } - iprot.Skip(thrift.STRUCT) - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) - oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush(ctx) - return false, x -} - -type streamOnlyServiceProcessorEchoBidirectionalNew struct { - handler StreamOnlyService -} - -func (p *streamOnlyServiceProcessorEchoBidirectionalNew) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - panic("streaming method StreamOnlyService.EchoBidirectionalNew(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") -} - -type StreamOnlyServiceEchoBidirectionalNewArgs struct { - Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` -} - -func NewStreamOnlyServiceEchoBidirectionalNewArgs() *StreamOnlyServiceEchoBidirectionalNewArgs { - return &StreamOnlyServiceEchoBidirectionalNewArgs{} -} - -func (p *StreamOnlyServiceEchoBidirectionalNewArgs) InitDefault() { - *p = StreamOnlyServiceEchoBidirectionalNewArgs{} -} - -var StreamOnlyServiceEchoBidirectionalNewArgs_Req1_DEFAULT *EchoRequest - -func (p *StreamOnlyServiceEchoBidirectionalNewArgs) GetReq1() (v *EchoRequest) { - if !p.IsSetReq1() { - return StreamOnlyServiceEchoBidirectionalNewArgs_Req1_DEFAULT - } - return p.Req1 -} -func (p *StreamOnlyServiceEchoBidirectionalNewArgs) SetReq1(val *EchoRequest) { - p.Req1 = val -} - -var fieldIDToName_StreamOnlyServiceEchoBidirectionalNewArgs = map[int16]string{ - 1: "req1", -} - -func (p *StreamOnlyServiceEchoBidirectionalNewArgs) IsSetReq1() bool { - return p.Req1 != nil -} - -func (p *StreamOnlyServiceEchoBidirectionalNewArgs) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField1(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalNewArgs[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *StreamOnlyServiceEchoBidirectionalNewArgs) ReadField1(iprot thrift.TProtocol) error { - p.Req1 = NewEchoRequest() - if err := p.Req1.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *StreamOnlyServiceEchoBidirectionalNewArgs) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoBidirectionalNew_args"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField1(oprot); err != nil { - fieldId = 1 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *StreamOnlyServiceEchoBidirectionalNewArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { - goto WriteFieldBeginError - } - if err := p.Req1.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) -} - -func (p *StreamOnlyServiceEchoBidirectionalNewArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalNewArgs(%+v)", *p) - -} - -func (p *StreamOnlyServiceEchoBidirectionalNewArgs) DeepEqual(ano *StreamOnlyServiceEchoBidirectionalNewArgs) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field1DeepEqual(ano.Req1) { - return false - } - return true -} - -func (p *StreamOnlyServiceEchoBidirectionalNewArgs) Field1DeepEqual(src *EchoRequest) bool { - - if !p.Req1.DeepEqual(src) { - return false - } - return true -} - -type StreamOnlyServiceEchoBidirectionalNewResult struct { - Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` -} - -func NewStreamOnlyServiceEchoBidirectionalNewResult() *StreamOnlyServiceEchoBidirectionalNewResult { - return &StreamOnlyServiceEchoBidirectionalNewResult{} -} - -func (p *StreamOnlyServiceEchoBidirectionalNewResult) InitDefault() { - *p = StreamOnlyServiceEchoBidirectionalNewResult{} -} - -var StreamOnlyServiceEchoBidirectionalNewResult_Success_DEFAULT *EchoResponse - -func (p *StreamOnlyServiceEchoBidirectionalNewResult) GetSuccess() (v *EchoResponse) { - if !p.IsSetSuccess() { - return StreamOnlyServiceEchoBidirectionalNewResult_Success_DEFAULT - } - return p.Success -} -func (p *StreamOnlyServiceEchoBidirectionalNewResult) SetSuccess(x interface{}) { - p.Success = x.(*EchoResponse) -} - -var fieldIDToName_StreamOnlyServiceEchoBidirectionalNewResult = map[int16]string{ - 0: "success", -} - -func (p *StreamOnlyServiceEchoBidirectionalNewResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *StreamOnlyServiceEchoBidirectionalNewResult) Read(iprot thrift.TProtocol) (err error) { - - var fieldTypeId thrift.TType - var fieldId int16 - - if _, err = iprot.ReadStructBegin(); err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err = p.ReadField0(iprot); err != nil { - goto ReadFieldError - } - } else if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - default: - if err = iprot.Skip(fieldTypeId); err != nil { - goto SkipFieldError - } - } - if err = iprot.ReadFieldEnd(); err != nil { - goto ReadFieldEndError - } - } - if err = iprot.ReadStructEnd(); err != nil { - goto ReadStructEndError - } - - return nil -ReadStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalNewResult[fieldId]), err) -SkipFieldError: - return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) - -ReadFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *StreamOnlyServiceEchoBidirectionalNewResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = NewEchoResponse() - if err := p.Success.Read(iprot); err != nil { - return err - } - return nil -} - -func (p *StreamOnlyServiceEchoBidirectionalNewResult) Write(oprot thrift.TProtocol) (err error) { - var fieldId int16 - if err = oprot.WriteStructBegin("EchoBidirectionalNew_result"); err != nil { - goto WriteStructBeginError - } - if p != nil { - if err = p.writeField0(oprot); err != nil { - fieldId = 0 - goto WriteFieldError - } - } - if err = oprot.WriteFieldStop(); err != nil { - goto WriteFieldStopError - } - if err = oprot.WriteStructEnd(); err != nil { - goto WriteStructEndError - } - return nil -WriteStructBeginError: - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) -WriteFieldError: - return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) -WriteFieldStopError: - return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) -WriteStructEndError: - return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) -} - -func (p *StreamOnlyServiceEchoBidirectionalNewResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - goto WriteFieldBeginError - } - if err := p.Success.Write(oprot); err != nil { - return err - } - if err = oprot.WriteFieldEnd(); err != nil { - goto WriteFieldEndError - } - } - return nil -WriteFieldBeginError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) -WriteFieldEndError: - return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) -} - -func (p *StreamOnlyServiceEchoBidirectionalNewResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalNewResult(%+v)", *p) - -} - -func (p *StreamOnlyServiceEchoBidirectionalNewResult) DeepEqual(ano *StreamOnlyServiceEchoBidirectionalNewResult) bool { - if p == ano { - return true - } else if p == nil || ano == nil { - return false - } - if !p.Field0DeepEqual(ano.Success) { - return false - } - return true -} - -func (p *StreamOnlyServiceEchoBidirectionalNewResult) Field0DeepEqual(src *EchoResponse) bool { - - if !p.Success.DeepEqual(src) { - return false - } - return true -} - -type StreamOnlyServiceChildProcessor struct { - *StreamOnlyServiceProcessor -} - -func NewStreamOnlyServiceChildProcessor(handler StreamOnlyServiceChild) *StreamOnlyServiceChildProcessor { - self := &StreamOnlyServiceChildProcessor{NewStreamOnlyServiceProcessor(handler)} - return self -} - -type StreamOnlyServiceChildChildProcessor struct { - *StreamOnlyServiceChildProcessor -} - -func NewStreamOnlyServiceChildChildProcessor(handler StreamOnlyServiceChildChild) *StreamOnlyServiceChildChildProcessor { - self := &StreamOnlyServiceChildChildProcessor{NewStreamOnlyServiceChildProcessor(handler)} - return self -} diff --git a/thrift_streaming/kitex_gen/echo/echoservice/client.go b/thrift_streaming/kitex_gen/echo/echoservice/client.go deleted file mode 100644 index f50d2b8..0000000 --- a/thrift_streaming/kitex_gen/echo/echoservice/client.go +++ /dev/null @@ -1,140 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package echoservice - -import ( - "context" - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" - "github.com/cloudwego/kitex/client/callopt/streamcall" - "github.com/cloudwego/kitex/client/streamclient" - streaming "github.com/cloudwego/kitex/pkg/streaming" - transport "github.com/cloudwego/kitex/transport" -) - -// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. -type Client interface { - EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, req2 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) - EchoOneway(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (err error) - Ping(ctx context.Context, callOptions ...callopt.Option) (err error) -} - -// StreamClient is designed to provide Interface for Streaming APIs. -type StreamClient interface { - EchoBidirectional(ctx context.Context, callOptions ...streamcall.Option) (stream EchoService_EchoBidirectionalClient, err error) - EchoClient(ctx context.Context, callOptions ...streamcall.Option) (stream EchoService_EchoClientClient, err error) - EchoServer(ctx context.Context, req1 *echo.EchoRequest, callOptions ...streamcall.Option) (stream EchoService_EchoServerClient, err error) - EchoUnary(ctx context.Context, req1 *echo.EchoRequest, callOptions ...streamcall.Option) (r *echo.EchoResponse, err error) -} - -type EchoService_EchoBidirectionalClient interface { - streaming.Stream - Send(*echo.EchoRequest) error - Recv() (*echo.EchoResponse, error) -} - -type EchoService_EchoClientClient interface { - streaming.Stream - Send(*echo.EchoRequest) error - CloseAndRecv() (*echo.EchoResponse, error) -} - -type EchoService_EchoServerClient interface { - streaming.Stream - Recv() (*echo.EchoResponse, error) -} - -// NewClient creates a client for the service defined in IDL. -func NewClient(destService string, opts ...client.Option) (Client, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - - options = append(options, opts...) - - kc, err := client.NewClient(serviceInfoForClient(), options...) - if err != nil { - return nil, err - } - return &kEchoServiceClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. -func MustNewClient(destService string, opts ...client.Option) Client { - kc, err := NewClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kEchoServiceClient struct { - *kClient -} - -func (p *kEchoServiceClient) EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, req2 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.EchoPingPong(ctx, req1, req2) -} - -func (p *kEchoServiceClient) EchoOneway(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.EchoOneway(ctx, req1) -} - -func (p *kEchoServiceClient) Ping(ctx context.Context, callOptions ...callopt.Option) (err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.Ping(ctx) -} - -// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - options = append(options, client.WithTransportProtocol(transport.GRPC)) - options = append(options, streamclient.GetClientOptions(opts)...) - - kc, err := client.NewClient(serviceInfoForStreamClient(), options...) - if err != nil { - return nil, err - } - return &kEchoServiceStreamClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -// It panics if any error occurs. -func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { - kc, err := NewStreamClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kEchoServiceStreamClient struct { - *kClient -} - -func (p *kEchoServiceStreamClient) EchoBidirectional(ctx context.Context, callOptions ...streamcall.Option) (stream EchoService_EchoBidirectionalClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.EchoBidirectional(ctx) -} - -func (p *kEchoServiceStreamClient) EchoClient(ctx context.Context, callOptions ...streamcall.Option) (stream EchoService_EchoClientClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.EchoClient(ctx) -} - -func (p *kEchoServiceStreamClient) EchoServer(ctx context.Context, req1 *echo.EchoRequest, callOptions ...streamcall.Option) (stream EchoService_EchoServerClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.EchoServer(ctx, req1) -} - -func (p *kEchoServiceStreamClient) EchoUnary(ctx context.Context, req1 *echo.EchoRequest, callOptions ...streamcall.Option) (r *echo.EchoResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.EchoUnary(ctx, req1) -} diff --git a/thrift_streaming/kitex_gen/echo/echoservice/echoservice.go b/thrift_streaming/kitex_gen/echo/echoservice/echoservice.go deleted file mode 100644 index ddd8b3e..0000000 --- a/thrift_streaming/kitex_gen/echo/echoservice/echoservice.go +++ /dev/null @@ -1,440 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package echoservice - -import ( - "context" - "errors" - "fmt" - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - client "github.com/cloudwego/kitex/client" - kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" -) - -var errInvalidMessageType = errors.New("invalid message type for service method handler") - -var serviceMethods = map[string]kitex.MethodInfo{ - "EchoBidirectional": kitex.NewMethodInfo( - echoBidirectionalHandler, - newEchoServiceEchoBidirectionalArgs, - newEchoServiceEchoBidirectionalResult, - false, - kitex.WithStreamingMode(kitex.StreamingBidirectional), - ), - "EchoClient": kitex.NewMethodInfo( - echoClientHandler, - newEchoServiceEchoClientArgs, - newEchoServiceEchoClientResult, - false, - kitex.WithStreamingMode(kitex.StreamingClient), - ), - "EchoServer": kitex.NewMethodInfo( - echoServerHandler, - newEchoServiceEchoServerArgs, - newEchoServiceEchoServerResult, - false, - kitex.WithStreamingMode(kitex.StreamingServer), - ), - "EchoUnary": kitex.NewMethodInfo( - echoUnaryHandler, - newEchoServiceEchoUnaryArgs, - newEchoServiceEchoUnaryResult, - false, - kitex.WithStreamingMode(kitex.StreamingUnary), - ), - "EchoPingPong": kitex.NewMethodInfo( - echoPingPongHandler, - newEchoServiceEchoPingPongArgs, - newEchoServiceEchoPingPongResult, - false, - kitex.WithStreamingMode(kitex.StreamingNone), - ), - "EchoOneway": kitex.NewMethodInfo( - echoOnewayHandler, - newEchoServiceEchoOnewayArgs, - newEchoServiceEchoOnewayResult, - false, - kitex.WithStreamingMode(kitex.StreamingNone), - ), - "Ping": kitex.NewMethodInfo( - pingHandler, - newEchoServicePingArgs, - newEchoServicePingResult, - false, - kitex.WithStreamingMode(kitex.StreamingNone), - ), -} - -var ( - echoServiceServiceInfo = NewServiceInfo() - echoServiceServiceInfoForClient = NewServiceInfoForClient() - echoServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() -) - -// for server -func serviceInfo() *kitex.ServiceInfo { - return echoServiceServiceInfo -} - -// for client -func serviceInfoForStreamClient() *kitex.ServiceInfo { - return echoServiceServiceInfoForStreamClient -} - -// for stream client -func serviceInfoForClient() *kitex.ServiceInfo { - return echoServiceServiceInfoForClient -} - -// NewServiceInfo creates a new ServiceInfo containing all methods -func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(true, true, true) -} - -// NewServiceInfo creates a new ServiceInfo containing non-streaming methods -func NewServiceInfoForClient() *kitex.ServiceInfo { - return newServiceInfo(false, false, true) -} -func NewServiceInfoForStreamClient() *kitex.ServiceInfo { - return newServiceInfo(true, true, false) -} - -func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { - serviceName := "EchoService" - handlerType := (*echo.EchoService)(nil) - methods := map[string]kitex.MethodInfo{} - for name, m := range serviceMethods { - if m.IsStreaming() && !keepStreamingMethods { - continue - } - if !m.IsStreaming() && !keepNonStreamingMethods { - continue - } - methods[name] = m - } - extra := map[string]interface{}{ - "PackageName": "echo", - } - if hasStreaming { - extra["streaming"] = hasStreaming - } - svcInfo := &kitex.ServiceInfo{ - ServiceName: serviceName, - HandlerType: handlerType, - Methods: methods, - PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.8.0", - Extra: extra, - } - return svcInfo -} - -func echoBidirectionalHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - st, ok := arg.(*streaming.Args) - if !ok { - return errors.New("EchoService.EchoBidirectional is a thrift streaming method, please call with Kitex StreamClient") - } - stream := &echoServiceEchoBidirectionalServer{st.Stream} - return handler.(echo.EchoService).EchoBidirectional(stream) -} - -type echoServiceEchoBidirectionalClient struct { - streaming.Stream -} - -func (x *echoServiceEchoBidirectionalClient) Send(m *echo.EchoRequest) error { - return x.Stream.SendMsg(m) -} -func (x *echoServiceEchoBidirectionalClient) Recv() (*echo.EchoResponse, error) { - m := new(echo.EchoResponse) - return m, x.Stream.RecvMsg(m) -} - -type echoServiceEchoBidirectionalServer struct { - streaming.Stream -} - -func (x *echoServiceEchoBidirectionalServer) Send(m *echo.EchoResponse) error { - return x.Stream.SendMsg(m) -} - -func (x *echoServiceEchoBidirectionalServer) Recv() (*echo.EchoRequest, error) { - m := new(echo.EchoRequest) - return m, x.Stream.RecvMsg(m) -} - -func newEchoServiceEchoBidirectionalArgs() interface{} { - return echo.NewEchoServiceEchoBidirectionalArgs() -} - -func newEchoServiceEchoBidirectionalResult() interface{} { - return echo.NewEchoServiceEchoBidirectionalResult() -} - -func echoClientHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - st, ok := arg.(*streaming.Args) - if !ok { - return errors.New("EchoService.EchoClient is a thrift streaming method, please call with Kitex StreamClient") - } - stream := &echoServiceEchoClientServer{st.Stream} - return handler.(echo.EchoService).EchoClient(stream) -} - -type echoServiceEchoClientClient struct { - streaming.Stream -} - -func (x *echoServiceEchoClientClient) Send(m *echo.EchoRequest) error { - return x.Stream.SendMsg(m) -} -func (x *echoServiceEchoClientClient) CloseAndRecv() (*echo.EchoResponse, error) { - if err := x.Stream.Close(); err != nil { - return nil, err - } - m := new(echo.EchoResponse) - return m, x.Stream.RecvMsg(m) -} - -type echoServiceEchoClientServer struct { - streaming.Stream -} - -func (x *echoServiceEchoClientServer) SendAndClose(m *echo.EchoResponse) error { - return x.Stream.SendMsg(m) -} - -func (x *echoServiceEchoClientServer) Recv() (*echo.EchoRequest, error) { - m := new(echo.EchoRequest) - return m, x.Stream.RecvMsg(m) -} - -func newEchoServiceEchoClientArgs() interface{} { - return echo.NewEchoServiceEchoClientArgs() -} - -func newEchoServiceEchoClientResult() interface{} { - return echo.NewEchoServiceEchoClientResult() -} - -func echoServerHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - st, ok := arg.(*streaming.Args) - if !ok { - return errors.New("EchoService.EchoServer is a thrift streaming method, please call with Kitex StreamClient") - } - stream := &echoServiceEchoServerServer{st.Stream} - req := new(echo.EchoRequest) - if err := st.Stream.RecvMsg(req); err != nil { - return err - } - return handler.(echo.EchoService).EchoServer(req, stream) -} - -type echoServiceEchoServerClient struct { - streaming.Stream -} - -func (x *echoServiceEchoServerClient) Recv() (*echo.EchoResponse, error) { - m := new(echo.EchoResponse) - return m, x.Stream.RecvMsg(m) -} - -type echoServiceEchoServerServer struct { - streaming.Stream -} - -func (x *echoServiceEchoServerServer) Send(m *echo.EchoResponse) error { - return x.Stream.SendMsg(m) -} - -func newEchoServiceEchoServerArgs() interface{} { - return echo.NewEchoServiceEchoServerArgs() -} - -func newEchoServiceEchoServerResult() interface{} { - return echo.NewEchoServiceEchoServerResult() -} - -func echoUnaryHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - if streaming.GetStream(ctx) == nil { - return errors.New("EchoService.EchoUnary is a thrift streaming unary method, please call with Kitex StreamClient or remove the annotation streaming.mode") - } - realArg := arg.(*echo.EchoServiceEchoUnaryArgs) - realResult := result.(*echo.EchoServiceEchoUnaryResult) - success, err := handler.(echo.EchoService).EchoUnary(ctx, realArg.Req1) - if err != nil { - return err - } - realResult.Success = success - return nil -} -func newEchoServiceEchoUnaryArgs() interface{} { - return echo.NewEchoServiceEchoUnaryArgs() -} - -func newEchoServiceEchoUnaryResult() interface{} { - return echo.NewEchoServiceEchoUnaryResult() -} - -func echoPingPongHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - realArg := arg.(*echo.EchoServiceEchoPingPongArgs) - realResult := result.(*echo.EchoServiceEchoPingPongResult) - success, err := handler.(echo.EchoService).EchoPingPong(ctx, realArg.Req1, realArg.Req2) - if err != nil { - switch v := err.(type) { - case *echo.EchoException: - realResult.E = v - default: - return err - } - } else { - realResult.Success = success - } - return nil -} -func newEchoServiceEchoPingPongArgs() interface{} { - return echo.NewEchoServiceEchoPingPongArgs() -} - -func newEchoServiceEchoPingPongResult() interface{} { - return echo.NewEchoServiceEchoPingPongResult() -} - -func echoOnewayHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - realArg := arg.(*echo.EchoServiceEchoOnewayArgs) - - err := handler.(echo.EchoService).EchoOneway(ctx, realArg.Req1) - if err != nil { - return err - } - - return nil -} -func newEchoServiceEchoOnewayArgs() interface{} { - return echo.NewEchoServiceEchoOnewayArgs() -} - -func newEchoServiceEchoOnewayResult() interface{} { - return echo.NewEchoServiceEchoOnewayResult() -} - -func pingHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - _ = arg.(*echo.EchoServicePingArgs) - - err := handler.(echo.EchoService).Ping(ctx) - if err != nil { - return err - } - - return nil -} -func newEchoServicePingArgs() interface{} { - return echo.NewEchoServicePingArgs() -} - -func newEchoServicePingResult() interface{} { - return echo.NewEchoServicePingResult() -} - -type kClient struct { - c client.Client -} - -func newServiceClient(c client.Client) *kClient { - return &kClient{ - c: c, - } -} - -func (p *kClient) EchoBidirectional(ctx context.Context) (EchoService_EchoBidirectionalClient, error) { - streamClient, ok := p.c.(client.Streaming) - if !ok { - return nil, fmt.Errorf("client not support streaming") - } - res := new(streaming.Result) - err := streamClient.Stream(ctx, "EchoBidirectional", nil, res) - if err != nil { - return nil, err - } - stream := &echoServiceEchoBidirectionalClient{res.Stream} - return stream, nil -} - -func (p *kClient) EchoClient(ctx context.Context) (EchoService_EchoClientClient, error) { - streamClient, ok := p.c.(client.Streaming) - if !ok { - return nil, fmt.Errorf("client not support streaming") - } - res := new(streaming.Result) - err := streamClient.Stream(ctx, "EchoClient", nil, res) - if err != nil { - return nil, err - } - stream := &echoServiceEchoClientClient{res.Stream} - return stream, nil -} - -func (p *kClient) EchoServer(ctx context.Context, req1 *echo.EchoRequest) (EchoService_EchoServerClient, error) { - streamClient, ok := p.c.(client.Streaming) - if !ok { - return nil, fmt.Errorf("client not support streaming") - } - res := new(streaming.Result) - err := streamClient.Stream(ctx, "EchoServer", nil, res) - if err != nil { - return nil, err - } - stream := &echoServiceEchoServerClient{res.Stream} - - if err := stream.Stream.SendMsg(req1); err != nil { - return nil, err - } - if err := stream.Stream.Close(); err != nil { - return nil, err - } - return stream, nil -} - -func (p *kClient) EchoUnary(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { - var _args echo.EchoServiceEchoUnaryArgs - _args.Req1 = req1 - var _result echo.EchoServiceEchoUnaryResult - if err = p.c.Call(ctx, "EchoUnary", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, req2 *echo.EchoRequest) (r *echo.EchoResponse, err error) { - var _args echo.EchoServiceEchoPingPongArgs - _args.Req1 = req1 - _args.Req2 = req2 - var _result echo.EchoServiceEchoPingPongResult - if err = p.c.Call(ctx, "EchoPingPong", &_args, &_result); err != nil { - return - } - switch { - case _result.E != nil: - return r, _result.E - } - return _result.GetSuccess(), nil -} - -func (p *kClient) EchoOneway(ctx context.Context, req1 *echo.EchoRequest) (err error) { - var _args echo.EchoServiceEchoOnewayArgs - _args.Req1 = req1 - var _result echo.EchoServiceEchoOnewayResult - if err = p.c.Call(ctx, "EchoOneway", &_args, &_result); err != nil { - return - } - return nil -} - -func (p *kClient) Ping(ctx context.Context) (err error) { - var _args echo.EchoServicePingArgs - var _result echo.EchoServicePingResult - if err = p.c.Call(ctx, "Ping", &_args, &_result); err != nil { - return - } - return nil -} diff --git a/thrift_streaming/kitex_gen/echo/echoservice/invoker.go b/thrift_streaming/kitex_gen/echo/echoservice/invoker.go deleted file mode 100644 index 43818c6..0000000 --- a/thrift_streaming/kitex_gen/echo/echoservice/invoker.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package echoservice - -import ( - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - server "github.com/cloudwego/kitex/server" -) - -// NewInvoker creates a server.Invoker with the given handler and options. -func NewInvoker(handler echo.EchoService, opts ...server.Option) server.Invoker { - var options []server.Option - - options = append(options, opts...) - - s := server.NewInvoker(options...) - if err := s.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - if err := s.Init(); err != nil { - panic(err) - } - return s -} diff --git a/thrift_streaming/kitex_gen/echo/echoservice/server.go b/thrift_streaming/kitex_gen/echo/echoservice/server.go deleted file mode 100644 index c634884..0000000 --- a/thrift_streaming/kitex_gen/echo/echoservice/server.go +++ /dev/null @@ -1,21 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. -package echoservice - -import ( - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - server "github.com/cloudwego/kitex/server" -) - -// NewServer creates a server.Server with the given handler and options. -func NewServer(handler echo.EchoService, opts ...server.Option) server.Server { - var options []server.Option - - options = append(options, opts...) - options = append(options, server.WithCompatibleMiddlewareForUnary()) - - svr := server.NewServer(options...) - if err := svr.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - return svr -} diff --git a/thrift_streaming/kitex_gen/echo/k-api.go b/thrift_streaming/kitex_gen/echo/k-api.go deleted file mode 100644 index 9eaa6c2..0000000 --- a/thrift_streaming/kitex_gen/echo/k-api.go +++ /dev/null @@ -1,3026 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package echo - -import ( - "bytes" - "fmt" - "reflect" - "strings" - - "github.com/apache/thrift/lib/go/thrift" - - "github.com/cloudwego/kitex/pkg/protocol/bthrift" -) - -// unused protection -var ( - _ = fmt.Formatter(nil) - _ = (*bytes.Buffer)(nil) - _ = (*strings.Builder)(nil) - _ = reflect.Type(nil) - _ = thrift.TProtocol(nil) - _ = bthrift.BinaryWriter(nil) -) - -func (p *EchoRequest) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - var issetMessage bool = false - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetMessage = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - if !issetMessage { - fieldId = 1 - goto RequiredFieldNotSetError - } - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoRequest[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_EchoRequest[fieldId])) -} - -func (p *EchoRequest) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Message = v - - } - return offset, nil -} - -// for compatibility -func (p *EchoRequest) FastWrite(buf []byte) int { - return 0 -} - -func (p *EchoRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoRequest") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *EchoRequest) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("EchoRequest") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *EchoRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *EchoRequest) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Message) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *EchoResponse) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - var issetMessage bool = false - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - issetMessage = true - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - if !issetMessage { - fieldId = 1 - goto RequiredFieldNotSetError - } - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoResponse[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -RequiredFieldNotSetError: - return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_EchoResponse[fieldId])) -} - -func (p *EchoResponse) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Message = v - - } - return offset, nil -} - -// for compatibility -func (p *EchoResponse) FastWrite(buf []byte) int { - return 0 -} - -func (p *EchoResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoResponse") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *EchoResponse) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("EchoResponse") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *EchoResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *EchoResponse) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Message) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *EchoException) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoException[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoException) FastReadField1(buf []byte) (int, error) { - offset := 0 - - if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - - p.Message = v - - } - return offset, nil -} - -// for compatibility -func (p *EchoException) FastWrite(buf []byte) int { - return 0 -} - -func (p *EchoException) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoException") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *EchoException) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("EchoException") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *EchoException) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) - offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) - - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *EchoException) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) - l += bthrift.Binary.StringLengthNocopy(p.Message) - - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *EchoServiceEchoBidirectionalArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoBidirectionalArgs[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoBidirectionalArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - - tmp := NewEchoRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Req1 = tmp - return offset, nil -} - -// for compatibility -func (p *EchoServiceEchoBidirectionalArgs) FastWrite(buf []byte) int { - return 0 -} - -func (p *EchoServiceEchoBidirectionalArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectional_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *EchoServiceEchoBidirectionalArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("EchoBidirectional_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *EchoServiceEchoBidirectionalArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) - offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *EchoServiceEchoBidirectionalArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) - l += p.Req1.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *EchoServiceEchoBidirectionalResult) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoBidirectionalResult[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoBidirectionalResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - - tmp := NewEchoResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Success = tmp - return offset, nil -} - -// for compatibility -func (p *EchoServiceEchoBidirectionalResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *EchoServiceEchoBidirectionalResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectional_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *EchoServiceEchoBidirectionalResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("EchoBidirectional_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *EchoServiceEchoBidirectionalResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *EchoServiceEchoBidirectionalResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *EchoServiceEchoClientArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoClientArgs[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoClientArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - - tmp := NewEchoRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Req1 = tmp - return offset, nil -} - -// for compatibility -func (p *EchoServiceEchoClientArgs) FastWrite(buf []byte) int { - return 0 -} - -func (p *EchoServiceEchoClientArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoClient_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *EchoServiceEchoClientArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("EchoClient_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *EchoServiceEchoClientArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) - offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *EchoServiceEchoClientArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) - l += p.Req1.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *EchoServiceEchoClientResult) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoClientResult[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoClientResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - - tmp := NewEchoResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Success = tmp - return offset, nil -} - -// for compatibility -func (p *EchoServiceEchoClientResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *EchoServiceEchoClientResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoClient_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *EchoServiceEchoClientResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("EchoClient_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *EchoServiceEchoClientResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *EchoServiceEchoClientResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *EchoServiceEchoServerArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoServerArgs[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoServerArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - - tmp := NewEchoRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Req1 = tmp - return offset, nil -} - -// for compatibility -func (p *EchoServiceEchoServerArgs) FastWrite(buf []byte) int { - return 0 -} - -func (p *EchoServiceEchoServerArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoServer_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *EchoServiceEchoServerArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("EchoServer_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *EchoServiceEchoServerArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) - offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *EchoServiceEchoServerArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) - l += p.Req1.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *EchoServiceEchoServerResult) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoServerResult[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoServerResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - - tmp := NewEchoResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Success = tmp - return offset, nil -} - -// for compatibility -func (p *EchoServiceEchoServerResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *EchoServiceEchoServerResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoServer_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *EchoServiceEchoServerResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("EchoServer_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *EchoServiceEchoServerResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *EchoServiceEchoServerResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *EchoServiceEchoUnaryArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoUnaryArgs[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoUnaryArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - - tmp := NewEchoRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Req1 = tmp - return offset, nil -} - -// for compatibility -func (p *EchoServiceEchoUnaryArgs) FastWrite(buf []byte) int { - return 0 -} - -func (p *EchoServiceEchoUnaryArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoUnary_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *EchoServiceEchoUnaryArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("EchoUnary_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *EchoServiceEchoUnaryArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) - offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *EchoServiceEchoUnaryArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) - l += p.Req1.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *EchoServiceEchoUnaryResult) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoUnaryResult[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoUnaryResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - - tmp := NewEchoResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Success = tmp - return offset, nil -} - -// for compatibility -func (p *EchoServiceEchoUnaryResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *EchoServiceEchoUnaryResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoUnary_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *EchoServiceEchoUnaryResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("EchoUnary_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *EchoServiceEchoUnaryResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *EchoServiceEchoUnaryResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *EchoServiceEchoPingPongArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 2: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField2(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoPingPongArgs[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoPingPongArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - - tmp := NewEchoRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Req1 = tmp - return offset, nil -} - -func (p *EchoServiceEchoPingPongArgs) FastReadField2(buf []byte) (int, error) { - offset := 0 - - tmp := NewEchoRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Req2 = tmp - return offset, nil -} - -// for compatibility -func (p *EchoServiceEchoPingPongArgs) FastWrite(buf []byte) int { - return 0 -} - -func (p *EchoServiceEchoPingPongArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPong_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - offset += p.fastWriteField2(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *EchoServiceEchoPingPongArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("EchoPingPong_args") - if p != nil { - l += p.field1Length() - l += p.field2Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *EchoServiceEchoPingPongArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) - offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *EchoServiceEchoPingPongArgs) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req2", thrift.STRUCT, 2) - offset += p.Req2.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *EchoServiceEchoPingPongArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) - l += p.Req1.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *EchoServiceEchoPingPongArgs) field2Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req2", thrift.STRUCT, 2) - l += p.Req2.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *EchoServiceEchoPingPongResult) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoPingPongResult[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoPingPongResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - - tmp := NewEchoResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Success = tmp - return offset, nil -} - -func (p *EchoServiceEchoPingPongResult) FastReadField1(buf []byte) (int, error) { - offset := 0 - - tmp := NewEchoException() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.E = tmp - return offset, nil -} - -// for compatibility -func (p *EchoServiceEchoPingPongResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *EchoServiceEchoPingPongResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPong_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *EchoServiceEchoPingPongResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("EchoPingPong_result") - if p != nil { - l += p.field0Length() - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *EchoServiceEchoPingPongResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *EchoServiceEchoPingPongResult) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetE() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "e", thrift.STRUCT, 1) - offset += p.E.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *EchoServiceEchoPingPongResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *EchoServiceEchoPingPongResult) field1Length() int { - l := 0 - if p.IsSetE() { - l += bthrift.Binary.FieldBeginLength("e", thrift.STRUCT, 1) - l += p.E.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *EchoServiceEchoOnewayArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoOnewayArgs[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *EchoServiceEchoOnewayArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - - tmp := NewEchoRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Req1 = tmp - return offset, nil -} - -// for compatibility -func (p *EchoServiceEchoOnewayArgs) FastWrite(buf []byte) int { - return 0 -} - -func (p *EchoServiceEchoOnewayArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoOneway_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *EchoServiceEchoOnewayArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("EchoOneway_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *EchoServiceEchoOnewayArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) - offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *EchoServiceEchoOnewayArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) - l += p.Req1.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *EchoServiceEchoOnewayResult) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -// for compatibility -func (p *EchoServiceEchoOnewayResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *EchoServiceEchoOnewayResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoOneway_result") - if p != nil { - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *EchoServiceEchoOnewayResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("EchoOneway_result") - if p != nil { - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *EchoServicePingArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -// for compatibility -func (p *EchoServicePingArgs) FastWrite(buf []byte) int { - return 0 -} - -func (p *EchoServicePingArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Ping_args") - if p != nil { - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *EchoServicePingArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Ping_args") - if p != nil { - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *EchoServicePingResult) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -// for compatibility -func (p *EchoServicePingResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *EchoServicePingResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Ping_result") - if p != nil { - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *EchoServicePingResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("Ping_result") - if p != nil { - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *PingPongOnlyServiceEchoPingPongNewArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongNewArgs[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *PingPongOnlyServiceEchoPingPongNewArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - - tmp := NewEchoRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Req1 = tmp - return offset, nil -} - -// for compatibility -func (p *PingPongOnlyServiceEchoPingPongNewArgs) FastWrite(buf []byte) int { - return 0 -} - -func (p *PingPongOnlyServiceEchoPingPongNewArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPongNew_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *PingPongOnlyServiceEchoPingPongNewArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("EchoPingPongNew_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *PingPongOnlyServiceEchoPingPongNewArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) - offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *PingPongOnlyServiceEchoPingPongNewArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) - l += p.Req1.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *PingPongOnlyServiceEchoPingPongNewResult) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongNewResult[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *PingPongOnlyServiceEchoPingPongNewResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - - tmp := NewEchoResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Success = tmp - return offset, nil -} - -// for compatibility -func (p *PingPongOnlyServiceEchoPingPongNewResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *PingPongOnlyServiceEchoPingPongNewResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPongNew_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *PingPongOnlyServiceEchoPingPongNewResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("EchoPingPongNew_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *PingPongOnlyServiceEchoPingPongNewResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *PingPongOnlyServiceEchoPingPongNewResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedArgs[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - - tmp := NewEchoRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Req1 = tmp - return offset, nil -} - -// for compatibility -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) FastWrite(buf []byte) int { - return 0 -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectionalExtended_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("EchoBidirectionalExtended_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) - offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) - l += p.Req1.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedResult[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - - tmp := NewEchoResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Success = tmp - return offset, nil -} - -// for compatibility -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectionalExtended_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("EchoBidirectionalExtended_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *StreamOnlyServiceEchoBidirectionalNewArgs) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField1(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalNewArgs[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *StreamOnlyServiceEchoBidirectionalNewArgs) FastReadField1(buf []byte) (int, error) { - offset := 0 - - tmp := NewEchoRequest() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Req1 = tmp - return offset, nil -} - -// for compatibility -func (p *StreamOnlyServiceEchoBidirectionalNewArgs) FastWrite(buf []byte) int { - return 0 -} - -func (p *StreamOnlyServiceEchoBidirectionalNewArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectionalNew_args") - if p != nil { - offset += p.fastWriteField1(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *StreamOnlyServiceEchoBidirectionalNewArgs) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("EchoBidirectionalNew_args") - if p != nil { - l += p.field1Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *StreamOnlyServiceEchoBidirectionalNewArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) - offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - return offset -} - -func (p *StreamOnlyServiceEchoBidirectionalNewArgs) field1Length() int { - l := 0 - l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) - l += p.Req1.BLength() - l += bthrift.Binary.FieldEndLength() - return l -} - -func (p *StreamOnlyServiceEchoBidirectionalNewResult) FastRead(buf []byte) (int, error) { - var err error - var offset int - var l int - var fieldTypeId thrift.TType - var fieldId int16 - _, l, err = bthrift.Binary.ReadStructBegin(buf) - offset += l - if err != nil { - goto ReadStructBeginError - } - - for { - _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldBeginError - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - l, err = p.FastReadField0(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldError - } - } else { - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - default: - l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) - offset += l - if err != nil { - goto SkipFieldError - } - } - - l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadFieldEndError - } - } - l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) - offset += l - if err != nil { - goto ReadStructEndError - } - - return offset, nil -ReadStructBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) -ReadFieldBeginError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) -ReadFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalNewResult[fieldId]), err) -SkipFieldError: - return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) -ReadFieldEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) -ReadStructEndError: - return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) -} - -func (p *StreamOnlyServiceEchoBidirectionalNewResult) FastReadField0(buf []byte) (int, error) { - offset := 0 - - tmp := NewEchoResponse() - if l, err := tmp.FastRead(buf[offset:]); err != nil { - return offset, err - } else { - offset += l - } - p.Success = tmp - return offset, nil -} - -// for compatibility -func (p *StreamOnlyServiceEchoBidirectionalNewResult) FastWrite(buf []byte) int { - return 0 -} - -func (p *StreamOnlyServiceEchoBidirectionalNewResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectionalNew_result") - if p != nil { - offset += p.fastWriteField0(buf[offset:], binaryWriter) - } - offset += bthrift.Binary.WriteFieldStop(buf[offset:]) - offset += bthrift.Binary.WriteStructEnd(buf[offset:]) - return offset -} - -func (p *StreamOnlyServiceEchoBidirectionalNewResult) BLength() int { - l := 0 - l += bthrift.Binary.StructBeginLength("EchoBidirectionalNew_result") - if p != nil { - l += p.field0Length() - } - l += bthrift.Binary.FieldStopLength() - l += bthrift.Binary.StructEndLength() - return l -} - -func (p *StreamOnlyServiceEchoBidirectionalNewResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { - offset := 0 - if p.IsSetSuccess() { - offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) - offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) - offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) - } - return offset -} - -func (p *StreamOnlyServiceEchoBidirectionalNewResult) field0Length() int { - l := 0 - if p.IsSetSuccess() { - l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) - l += p.Success.BLength() - l += bthrift.Binary.FieldEndLength() - } - return l -} - -func (p *EchoServiceEchoBidirectionalArgs) GetFirstArgument() interface{} { - return p.Req1 -} - -func (p *EchoServiceEchoBidirectionalResult) GetResult() interface{} { - return p.Success -} - -func (p *EchoServiceEchoClientArgs) GetFirstArgument() interface{} { - return p.Req1 -} - -func (p *EchoServiceEchoClientResult) GetResult() interface{} { - return p.Success -} - -func (p *EchoServiceEchoServerArgs) GetFirstArgument() interface{} { - return p.Req1 -} - -func (p *EchoServiceEchoServerResult) GetResult() interface{} { - return p.Success -} - -func (p *EchoServiceEchoUnaryArgs) GetFirstArgument() interface{} { - return p.Req1 -} - -func (p *EchoServiceEchoUnaryResult) GetResult() interface{} { - return p.Success -} - -func (p *EchoServiceEchoPingPongArgs) GetFirstArgument() interface{} { - return p.Req1 -} - -func (p *EchoServiceEchoPingPongResult) GetResult() interface{} { - return p.Success -} - -func (p *EchoServiceEchoOnewayArgs) GetFirstArgument() interface{} { - return p.Req1 -} - -func (p *EchoServiceEchoOnewayResult) GetResult() interface{} { - return nil -} - -func (p *EchoServicePingArgs) GetFirstArgument() interface{} { - return nil -} - -func (p *EchoServicePingResult) GetResult() interface{} { - return nil -} - -func (p *PingPongOnlyServiceEchoPingPongNewArgs) GetFirstArgument() interface{} { - return p.Req1 -} - -func (p *PingPongOnlyServiceEchoPingPongNewResult) GetResult() interface{} { - return p.Success -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) GetFirstArgument() interface{} { - return p.Req1 -} - -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) GetResult() interface{} { - return p.Success -} - -func (p *StreamOnlyServiceEchoBidirectionalNewArgs) GetFirstArgument() interface{} { - return p.Req1 -} - -func (p *StreamOnlyServiceEchoBidirectionalNewResult) GetResult() interface{} { - return p.Success -} diff --git a/thrift_streaming/kitex_gen/echo/k-consts.go b/thrift_streaming/kitex_gen/echo/k-consts.go deleted file mode 100644 index cf25014..0000000 --- a/thrift_streaming/kitex_gen/echo/k-consts.go +++ /dev/null @@ -1,4 +0,0 @@ -package echo - -// KitexUnusedProtection is used to prevent 'imported and not used' error. -var KitexUnusedProtection = struct{}{} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservice/client.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/client.go deleted file mode 100644 index 0b298a3..0000000 --- a/thrift_streaming/kitex_gen/echo/pingpongonlyservice/client.go +++ /dev/null @@ -1,49 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package pingpongonlyservice - -import ( - "context" - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" -) - -// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. -type Client interface { - EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) -} - -// NewClient creates a client for the service defined in IDL. -func NewClient(destService string, opts ...client.Option) (Client, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - - options = append(options, opts...) - - kc, err := client.NewClient(serviceInfoForClient(), options...) - if err != nil { - return nil, err - } - return &kPingPongOnlyServiceClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. -func MustNewClient(destService string, opts ...client.Option) Client { - kc, err := NewClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kPingPongOnlyServiceClient struct { - *kClient -} - -func (p *kPingPongOnlyServiceClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.EchoPingPongNew(ctx, req1) -} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservice/invoker.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/invoker.go deleted file mode 100644 index da5064f..0000000 --- a/thrift_streaming/kitex_gen/echo/pingpongonlyservice/invoker.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package pingpongonlyservice - -import ( - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - server "github.com/cloudwego/kitex/server" -) - -// NewInvoker creates a server.Invoker with the given handler and options. -func NewInvoker(handler echo.PingPongOnlyService, opts ...server.Option) server.Invoker { - var options []server.Option - - options = append(options, opts...) - - s := server.NewInvoker(options...) - if err := s.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - if err := s.Init(); err != nil { - panic(err) - } - return s -} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservice/pingpongonlyservice.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/pingpongonlyservice.go deleted file mode 100644 index 0bf7178..0000000 --- a/thrift_streaming/kitex_gen/echo/pingpongonlyservice/pingpongonlyservice.go +++ /dev/null @@ -1,125 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package pingpongonlyservice - -import ( - "context" - "errors" - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - client "github.com/cloudwego/kitex/client" - kitex "github.com/cloudwego/kitex/pkg/serviceinfo" -) - -var errInvalidMessageType = errors.New("invalid message type for service method handler") - -var serviceMethods = map[string]kitex.MethodInfo{ - "EchoPingPongNew": kitex.NewMethodInfo( - echoPingPongNewHandler, - newPingPongOnlyServiceEchoPingPongNewArgs, - newPingPongOnlyServiceEchoPingPongNewResult, - false, - kitex.WithStreamingMode(kitex.StreamingNone), - ), -} - -var ( - pingPongOnlyServiceServiceInfo = NewServiceInfo() - pingPongOnlyServiceServiceInfoForClient = NewServiceInfoForClient() - pingPongOnlyServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() -) - -// for server -func serviceInfo() *kitex.ServiceInfo { - return pingPongOnlyServiceServiceInfo -} - -// for client -func serviceInfoForStreamClient() *kitex.ServiceInfo { - return pingPongOnlyServiceServiceInfoForStreamClient -} - -// for stream client -func serviceInfoForClient() *kitex.ServiceInfo { - return pingPongOnlyServiceServiceInfoForClient -} - -// NewServiceInfo creates a new ServiceInfo containing all methods -func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(false, true, true) -} - -// NewServiceInfo creates a new ServiceInfo containing non-streaming methods -func NewServiceInfoForClient() *kitex.ServiceInfo { - return newServiceInfo(false, false, true) -} -func NewServiceInfoForStreamClient() *kitex.ServiceInfo { - return newServiceInfo(true, true, false) -} - -func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { - serviceName := "PingPongOnlyService" - handlerType := (*echo.PingPongOnlyService)(nil) - methods := map[string]kitex.MethodInfo{} - for name, m := range serviceMethods { - if m.IsStreaming() && !keepStreamingMethods { - continue - } - if !m.IsStreaming() && !keepNonStreamingMethods { - continue - } - methods[name] = m - } - extra := map[string]interface{}{ - "PackageName": "echo", - } - if hasStreaming { - extra["streaming"] = hasStreaming - } - svcInfo := &kitex.ServiceInfo{ - ServiceName: serviceName, - HandlerType: handlerType, - Methods: methods, - PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.8.0", - Extra: extra, - } - return svcInfo -} - -func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) - realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) - success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) - if err != nil { - return err - } - realResult.Success = success - return nil -} -func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { - return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() -} - -func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { - return echo.NewPingPongOnlyServiceEchoPingPongNewResult() -} - -type kClient struct { - c client.Client -} - -func newServiceClient(c client.Client) *kClient { - return &kClient{ - c: c, - } -} - -func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { - var _args echo.PingPongOnlyServiceEchoPingPongNewArgs - _args.Req1 = req1 - var _result echo.PingPongOnlyServiceEchoPingPongNewResult - if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservice/server.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/server.go deleted file mode 100644 index 1c1f548..0000000 --- a/thrift_streaming/kitex_gen/echo/pingpongonlyservice/server.go +++ /dev/null @@ -1,21 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. -package pingpongonlyservice - -import ( - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - server "github.com/cloudwego/kitex/server" -) - -// NewServer creates a server.Server with the given handler and options. -func NewServer(handler echo.PingPongOnlyService, opts ...server.Option) server.Server { - var options []server.Option - - options = append(options, opts...) - options = append(options, server.WithCompatibleMiddlewareForUnary()) - - svr := server.NewServer(options...) - if err := svr.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - return svr -} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/client.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/client.go deleted file mode 100644 index 9603c81..0000000 --- a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/client.go +++ /dev/null @@ -1,99 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package pingpongonlyservicechild - -import ( - "context" - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" - "github.com/cloudwego/kitex/client/callopt/streamcall" - "github.com/cloudwego/kitex/client/streamclient" - streaming "github.com/cloudwego/kitex/pkg/streaming" - transport "github.com/cloudwego/kitex/transport" -) - -// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. -type Client interface { - EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) -} - -// StreamClient is designed to provide Interface for Streaming APIs. -type StreamClient interface { - EchoBidirectionalExtended(ctx context.Context, callOptions ...streamcall.Option) (stream PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, err error) -} - -type PingPongOnlyServiceChild_EchoBidirectionalExtendedClient interface { - streaming.Stream - Send(*echo.EchoRequest) error - Recv() (*echo.EchoResponse, error) -} - -// NewClient creates a client for the service defined in IDL. -func NewClient(destService string, opts ...client.Option) (Client, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - - options = append(options, opts...) - - kc, err := client.NewClient(serviceInfoForClient(), options...) - if err != nil { - return nil, err - } - return &kPingPongOnlyServiceChildClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. -func MustNewClient(destService string, opts ...client.Option) Client { - kc, err := NewClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kPingPongOnlyServiceChildClient struct { - *kClient -} - -func (p *kPingPongOnlyServiceChildClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.EchoPingPongNew(ctx, req1) -} - -// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - options = append(options, client.WithTransportProtocol(transport.GRPC)) - options = append(options, streamclient.GetClientOptions(opts)...) - - kc, err := client.NewClient(serviceInfoForStreamClient(), options...) - if err != nil { - return nil, err - } - return &kPingPongOnlyServiceChildStreamClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -// It panics if any error occurs. -func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { - kc, err := NewStreamClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kPingPongOnlyServiceChildStreamClient struct { - *kClient -} - -func (p *kPingPongOnlyServiceChildStreamClient) EchoBidirectionalExtended(ctx context.Context, callOptions ...streamcall.Option) (stream PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.EchoBidirectionalExtended(ctx) -} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/invoker.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/invoker.go deleted file mode 100644 index 1d57220..0000000 --- a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/invoker.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package pingpongonlyservicechild - -import ( - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - server "github.com/cloudwego/kitex/server" -) - -// NewInvoker creates a server.Invoker with the given handler and options. -func NewInvoker(handler echo.PingPongOnlyServiceChild, opts ...server.Option) server.Invoker { - var options []server.Option - - options = append(options, opts...) - - s := server.NewInvoker(options...) - if err := s.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - if err := s.Init(); err != nil { - panic(err) - } - return s -} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/pingpongonlyservicechild.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/pingpongonlyservicechild.go deleted file mode 100644 index d9fde95..0000000 --- a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/pingpongonlyservicechild.go +++ /dev/null @@ -1,190 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package pingpongonlyservicechild - -import ( - "context" - "errors" - "fmt" - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - client "github.com/cloudwego/kitex/client" - kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" -) - -var errInvalidMessageType = errors.New("invalid message type for service method handler") - -var serviceMethods = map[string]kitex.MethodInfo{ - "EchoPingPongNew": kitex.NewMethodInfo( - echoPingPongNewHandler, - newPingPongOnlyServiceEchoPingPongNewArgs, - newPingPongOnlyServiceEchoPingPongNewResult, - false, - kitex.WithStreamingMode(kitex.StreamingNone), - ), - "EchoBidirectionalExtended": kitex.NewMethodInfo( - echoBidirectionalExtendedHandler, - newPingPongOnlyServiceChildEchoBidirectionalExtendedArgs, - newPingPongOnlyServiceChildEchoBidirectionalExtendedResult, - false, - kitex.WithStreamingMode(kitex.StreamingBidirectional), - ), -} - -var ( - pingPongOnlyServiceChildServiceInfo = NewServiceInfo() - pingPongOnlyServiceChildServiceInfoForClient = NewServiceInfoForClient() - pingPongOnlyServiceChildServiceInfoForStreamClient = NewServiceInfoForStreamClient() -) - -// for server -func serviceInfo() *kitex.ServiceInfo { - return pingPongOnlyServiceChildServiceInfo -} - -// for client -func serviceInfoForStreamClient() *kitex.ServiceInfo { - return pingPongOnlyServiceChildServiceInfoForStreamClient -} - -// for stream client -func serviceInfoForClient() *kitex.ServiceInfo { - return pingPongOnlyServiceChildServiceInfoForClient -} - -// NewServiceInfo creates a new ServiceInfo containing all methods -func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(true, true, true) -} - -// NewServiceInfo creates a new ServiceInfo containing non-streaming methods -func NewServiceInfoForClient() *kitex.ServiceInfo { - return newServiceInfo(false, false, true) -} -func NewServiceInfoForStreamClient() *kitex.ServiceInfo { - return newServiceInfo(true, true, false) -} - -func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { - serviceName := "PingPongOnlyServiceChild" - handlerType := (*echo.PingPongOnlyServiceChild)(nil) - methods := map[string]kitex.MethodInfo{} - for name, m := range serviceMethods { - if m.IsStreaming() && !keepStreamingMethods { - continue - } - if !m.IsStreaming() && !keepNonStreamingMethods { - continue - } - methods[name] = m - } - extra := map[string]interface{}{ - "PackageName": "echo", - } - if hasStreaming { - extra["streaming"] = hasStreaming - } - svcInfo := &kitex.ServiceInfo{ - ServiceName: serviceName, - HandlerType: handlerType, - Methods: methods, - PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.8.0", - Extra: extra, - } - return svcInfo -} - -func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) - realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) - success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) - if err != nil { - return err - } - realResult.Success = success - return nil -} -func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { - return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() -} - -func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { - return echo.NewPingPongOnlyServiceEchoPingPongNewResult() -} - -func echoBidirectionalExtendedHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - st, ok := arg.(*streaming.Args) - if !ok { - return errors.New("PingPongOnlyServiceChild.EchoBidirectionalExtended is a thrift streaming method, please call with Kitex StreamClient") - } - stream := &pingPongOnlyServiceChildEchoBidirectionalExtendedServer{st.Stream} - return handler.(echo.PingPongOnlyServiceChild).EchoBidirectionalExtended(stream) -} - -type pingPongOnlyServiceChildEchoBidirectionalExtendedClient struct { - streaming.Stream -} - -func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedClient) Send(m *echo.EchoRequest) error { - return x.Stream.SendMsg(m) -} -func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedClient) Recv() (*echo.EchoResponse, error) { - m := new(echo.EchoResponse) - return m, x.Stream.RecvMsg(m) -} - -type pingPongOnlyServiceChildEchoBidirectionalExtendedServer struct { - streaming.Stream -} - -func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedServer) Send(m *echo.EchoResponse) error { - return x.Stream.SendMsg(m) -} - -func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedServer) Recv() (*echo.EchoRequest, error) { - m := new(echo.EchoRequest) - return m, x.Stream.RecvMsg(m) -} - -func newPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() interface{} { - return echo.NewPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() -} - -func newPingPongOnlyServiceChildEchoBidirectionalExtendedResult() interface{} { - return echo.NewPingPongOnlyServiceChildEchoBidirectionalExtendedResult() -} - -type kClient struct { - c client.Client -} - -func newServiceClient(c client.Client) *kClient { - return &kClient{ - c: c, - } -} - -func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { - var _args echo.PingPongOnlyServiceEchoPingPongNewArgs - _args.Req1 = req1 - var _result echo.PingPongOnlyServiceEchoPingPongNewResult - if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) EchoBidirectionalExtended(ctx context.Context) (PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, error) { - streamClient, ok := p.c.(client.Streaming) - if !ok { - return nil, fmt.Errorf("client not support streaming") - } - res := new(streaming.Result) - err := streamClient.Stream(ctx, "EchoBidirectionalExtended", nil, res) - if err != nil { - return nil, err - } - stream := &pingPongOnlyServiceChildEchoBidirectionalExtendedClient{res.Stream} - return stream, nil -} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/server.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/server.go deleted file mode 100644 index 3c88548..0000000 --- a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/server.go +++ /dev/null @@ -1,21 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. -package pingpongonlyservicechild - -import ( - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - server "github.com/cloudwego/kitex/server" -) - -// NewServer creates a server.Server with the given handler and options. -func NewServer(handler echo.PingPongOnlyServiceChild, opts ...server.Option) server.Server { - var options []server.Option - - options = append(options, opts...) - options = append(options, server.WithCompatibleMiddlewareForUnary()) - - svr := server.NewServer(options...) - if err := svr.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - return svr -} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/client.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/client.go deleted file mode 100644 index dcc00bc..0000000 --- a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/client.go +++ /dev/null @@ -1,99 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package pingpongonlyservicechildchild - -import ( - "context" - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" - "github.com/cloudwego/kitex/client/callopt/streamcall" - "github.com/cloudwego/kitex/client/streamclient" - streaming "github.com/cloudwego/kitex/pkg/streaming" - transport "github.com/cloudwego/kitex/transport" -) - -// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. -type Client interface { - EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) -} - -// StreamClient is designed to provide Interface for Streaming APIs. -type StreamClient interface { - EchoBidirectionalExtended(ctx context.Context, callOptions ...streamcall.Option) (stream PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, err error) -} - -type PingPongOnlyServiceChild_EchoBidirectionalExtendedClient interface { - streaming.Stream - Send(*echo.EchoRequest) error - Recv() (*echo.EchoResponse, error) -} - -// NewClient creates a client for the service defined in IDL. -func NewClient(destService string, opts ...client.Option) (Client, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - - options = append(options, opts...) - - kc, err := client.NewClient(serviceInfoForClient(), options...) - if err != nil { - return nil, err - } - return &kPingPongOnlyServiceChildChildClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. -func MustNewClient(destService string, opts ...client.Option) Client { - kc, err := NewClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kPingPongOnlyServiceChildChildClient struct { - *kClient -} - -func (p *kPingPongOnlyServiceChildChildClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.EchoPingPongNew(ctx, req1) -} - -// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - options = append(options, client.WithTransportProtocol(transport.GRPC)) - options = append(options, streamclient.GetClientOptions(opts)...) - - kc, err := client.NewClient(serviceInfoForStreamClient(), options...) - if err != nil { - return nil, err - } - return &kPingPongOnlyServiceChildChildStreamClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -// It panics if any error occurs. -func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { - kc, err := NewStreamClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kPingPongOnlyServiceChildChildStreamClient struct { - *kClient -} - -func (p *kPingPongOnlyServiceChildChildStreamClient) EchoBidirectionalExtended(ctx context.Context, callOptions ...streamcall.Option) (stream PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.EchoBidirectionalExtended(ctx) -} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/invoker.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/invoker.go deleted file mode 100644 index 50d661b..0000000 --- a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/invoker.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package pingpongonlyservicechildchild - -import ( - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - server "github.com/cloudwego/kitex/server" -) - -// NewInvoker creates a server.Invoker with the given handler and options. -func NewInvoker(handler echo.PingPongOnlyServiceChildChild, opts ...server.Option) server.Invoker { - var options []server.Option - - options = append(options, opts...) - - s := server.NewInvoker(options...) - if err := s.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - if err := s.Init(); err != nil { - panic(err) - } - return s -} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go deleted file mode 100644 index 7fe56bb..0000000 --- a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go +++ /dev/null @@ -1,190 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package pingpongonlyservicechildchild - -import ( - "context" - "errors" - "fmt" - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - client "github.com/cloudwego/kitex/client" - kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" -) - -var errInvalidMessageType = errors.New("invalid message type for service method handler") - -var serviceMethods = map[string]kitex.MethodInfo{ - "EchoPingPongNew": kitex.NewMethodInfo( - echoPingPongNewHandler, - newPingPongOnlyServiceEchoPingPongNewArgs, - newPingPongOnlyServiceEchoPingPongNewResult, - false, - kitex.WithStreamingMode(kitex.StreamingNone), - ), - "EchoBidirectionalExtended": kitex.NewMethodInfo( - echoBidirectionalExtendedHandler, - newPingPongOnlyServiceChildEchoBidirectionalExtendedArgs, - newPingPongOnlyServiceChildEchoBidirectionalExtendedResult, - false, - kitex.WithStreamingMode(kitex.StreamingBidirectional), - ), -} - -var ( - pingPongOnlyServiceChildChildServiceInfo = NewServiceInfo() - pingPongOnlyServiceChildChildServiceInfoForClient = NewServiceInfoForClient() - pingPongOnlyServiceChildChildServiceInfoForStreamClient = NewServiceInfoForStreamClient() -) - -// for server -func serviceInfo() *kitex.ServiceInfo { - return pingPongOnlyServiceChildChildServiceInfo -} - -// for client -func serviceInfoForStreamClient() *kitex.ServiceInfo { - return pingPongOnlyServiceChildChildServiceInfoForStreamClient -} - -// for stream client -func serviceInfoForClient() *kitex.ServiceInfo { - return pingPongOnlyServiceChildChildServiceInfoForClient -} - -// NewServiceInfo creates a new ServiceInfo containing all methods -func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(true, true, true) -} - -// NewServiceInfo creates a new ServiceInfo containing non-streaming methods -func NewServiceInfoForClient() *kitex.ServiceInfo { - return newServiceInfo(false, false, true) -} -func NewServiceInfoForStreamClient() *kitex.ServiceInfo { - return newServiceInfo(true, true, false) -} - -func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { - serviceName := "PingPongOnlyServiceChildChild" - handlerType := (*echo.PingPongOnlyServiceChildChild)(nil) - methods := map[string]kitex.MethodInfo{} - for name, m := range serviceMethods { - if m.IsStreaming() && !keepStreamingMethods { - continue - } - if !m.IsStreaming() && !keepNonStreamingMethods { - continue - } - methods[name] = m - } - extra := map[string]interface{}{ - "PackageName": "echo", - } - if hasStreaming { - extra["streaming"] = hasStreaming - } - svcInfo := &kitex.ServiceInfo{ - ServiceName: serviceName, - HandlerType: handlerType, - Methods: methods, - PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.8.0", - Extra: extra, - } - return svcInfo -} - -func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) - realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) - success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) - if err != nil { - return err - } - realResult.Success = success - return nil -} -func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { - return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() -} - -func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { - return echo.NewPingPongOnlyServiceEchoPingPongNewResult() -} - -func echoBidirectionalExtendedHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - st, ok := arg.(*streaming.Args) - if !ok { - return errors.New("PingPongOnlyServiceChild.EchoBidirectionalExtended is a thrift streaming method, please call with Kitex StreamClient") - } - stream := &pingPongOnlyServiceChildEchoBidirectionalExtendedServer{st.Stream} - return handler.(echo.PingPongOnlyServiceChild).EchoBidirectionalExtended(stream) -} - -type pingPongOnlyServiceChildEchoBidirectionalExtendedClient struct { - streaming.Stream -} - -func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedClient) Send(m *echo.EchoRequest) error { - return x.Stream.SendMsg(m) -} -func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedClient) Recv() (*echo.EchoResponse, error) { - m := new(echo.EchoResponse) - return m, x.Stream.RecvMsg(m) -} - -type pingPongOnlyServiceChildEchoBidirectionalExtendedServer struct { - streaming.Stream -} - -func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedServer) Send(m *echo.EchoResponse) error { - return x.Stream.SendMsg(m) -} - -func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedServer) Recv() (*echo.EchoRequest, error) { - m := new(echo.EchoRequest) - return m, x.Stream.RecvMsg(m) -} - -func newPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() interface{} { - return echo.NewPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() -} - -func newPingPongOnlyServiceChildEchoBidirectionalExtendedResult() interface{} { - return echo.NewPingPongOnlyServiceChildEchoBidirectionalExtendedResult() -} - -type kClient struct { - c client.Client -} - -func newServiceClient(c client.Client) *kClient { - return &kClient{ - c: c, - } -} - -func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { - var _args echo.PingPongOnlyServiceEchoPingPongNewArgs - _args.Req1 = req1 - var _result echo.PingPongOnlyServiceEchoPingPongNewResult - if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) EchoBidirectionalExtended(ctx context.Context) (PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, error) { - streamClient, ok := p.c.(client.Streaming) - if !ok { - return nil, fmt.Errorf("client not support streaming") - } - res := new(streaming.Result) - err := streamClient.Stream(ctx, "EchoBidirectionalExtended", nil, res) - if err != nil { - return nil, err - } - stream := &pingPongOnlyServiceChildEchoBidirectionalExtendedClient{res.Stream} - return stream, nil -} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/server.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/server.go deleted file mode 100644 index 39e1083..0000000 --- a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/server.go +++ /dev/null @@ -1,21 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. -package pingpongonlyservicechildchild - -import ( - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - server "github.com/cloudwego/kitex/server" -) - -// NewServer creates a server.Server with the given handler and options. -func NewServer(handler echo.PingPongOnlyServiceChildChild, opts ...server.Option) server.Server { - var options []server.Option - - options = append(options, opts...) - options = append(options, server.WithCompatibleMiddlewareForUnary()) - - svr := server.NewServer(options...) - if err := svr.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - return svr -} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservice/client.go b/thrift_streaming/kitex_gen/echo/streamonlyservice/client.go deleted file mode 100644 index e86aac5..0000000 --- a/thrift_streaming/kitex_gen/echo/streamonlyservice/client.go +++ /dev/null @@ -1,92 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package streamonlyservice - -import ( - "context" - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - client "github.com/cloudwego/kitex/client" - "github.com/cloudwego/kitex/client/callopt/streamcall" - "github.com/cloudwego/kitex/client/streamclient" - streaming "github.com/cloudwego/kitex/pkg/streaming" - transport "github.com/cloudwego/kitex/transport" -) - -// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. -type Client interface { -} - -// StreamClient is designed to provide Interface for Streaming APIs. -type StreamClient interface { - EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) -} - -type StreamOnlyService_EchoBidirectionalNewClient interface { - streaming.Stream - Send(*echo.EchoRequest) error - Recv() (*echo.EchoResponse, error) -} - -// NewClient creates a client for the service defined in IDL. -func NewClient(destService string, opts ...client.Option) (Client, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - - options = append(options, opts...) - - kc, err := client.NewClient(serviceInfoForClient(), options...) - if err != nil { - return nil, err - } - return &kStreamOnlyServiceClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. -func MustNewClient(destService string, opts ...client.Option) Client { - kc, err := NewClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kStreamOnlyServiceClient struct { - *kClient -} - -// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - options = append(options, client.WithTransportProtocol(transport.GRPC)) - options = append(options, streamclient.GetClientOptions(opts)...) - - kc, err := client.NewClient(serviceInfoForStreamClient(), options...) - if err != nil { - return nil, err - } - return &kStreamOnlyServiceStreamClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -// It panics if any error occurs. -func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { - kc, err := NewStreamClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kStreamOnlyServiceStreamClient struct { - *kClient -} - -func (p *kStreamOnlyServiceStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.EchoBidirectionalNew(ctx) -} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservice/invoker.go b/thrift_streaming/kitex_gen/echo/streamonlyservice/invoker.go deleted file mode 100644 index 3c8d70f..0000000 --- a/thrift_streaming/kitex_gen/echo/streamonlyservice/invoker.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package streamonlyservice - -import ( - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - server "github.com/cloudwego/kitex/server" -) - -// NewInvoker creates a server.Invoker with the given handler and options. -func NewInvoker(handler echo.StreamOnlyService, opts ...server.Option) server.Invoker { - var options []server.Option - - options = append(options, opts...) - - s := server.NewInvoker(options...) - if err := s.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - if err := s.Init(); err != nil { - panic(err) - } - return s -} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservice/server.go b/thrift_streaming/kitex_gen/echo/streamonlyservice/server.go deleted file mode 100644 index c5666b0..0000000 --- a/thrift_streaming/kitex_gen/echo/streamonlyservice/server.go +++ /dev/null @@ -1,21 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. -package streamonlyservice - -import ( - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - server "github.com/cloudwego/kitex/server" -) - -// NewServer creates a server.Server with the given handler and options. -func NewServer(handler echo.StreamOnlyService, opts ...server.Option) server.Server { - var options []server.Option - - options = append(options, opts...) - options = append(options, server.WithCompatibleMiddlewareForUnary()) - - svr := server.NewServer(options...) - if err := svr.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - return svr -} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservice/streamonlyservice.go b/thrift_streaming/kitex_gen/echo/streamonlyservice/streamonlyservice.go deleted file mode 100644 index 269fe07..0000000 --- a/thrift_streaming/kitex_gen/echo/streamonlyservice/streamonlyservice.go +++ /dev/null @@ -1,155 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package streamonlyservice - -import ( - "context" - "errors" - "fmt" - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - client "github.com/cloudwego/kitex/client" - kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" -) - -var errInvalidMessageType = errors.New("invalid message type for service method handler") - -var serviceMethods = map[string]kitex.MethodInfo{ - "EchoBidirectionalNew": kitex.NewMethodInfo( - echoBidirectionalNewHandler, - newStreamOnlyServiceEchoBidirectionalNewArgs, - newStreamOnlyServiceEchoBidirectionalNewResult, - false, - kitex.WithStreamingMode(kitex.StreamingBidirectional), - ), -} - -var ( - streamOnlyServiceServiceInfo = NewServiceInfo() - streamOnlyServiceServiceInfoForClient = NewServiceInfoForClient() - streamOnlyServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() -) - -// for server -func serviceInfo() *kitex.ServiceInfo { - return streamOnlyServiceServiceInfo -} - -// for client -func serviceInfoForStreamClient() *kitex.ServiceInfo { - return streamOnlyServiceServiceInfoForStreamClient -} - -// for stream client -func serviceInfoForClient() *kitex.ServiceInfo { - return streamOnlyServiceServiceInfoForClient -} - -// NewServiceInfo creates a new ServiceInfo containing all methods -func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(true, true, true) -} - -// NewServiceInfo creates a new ServiceInfo containing non-streaming methods -func NewServiceInfoForClient() *kitex.ServiceInfo { - return newServiceInfo(false, false, true) -} -func NewServiceInfoForStreamClient() *kitex.ServiceInfo { - return newServiceInfo(true, true, false) -} - -func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { - serviceName := "StreamOnlyService" - handlerType := (*echo.StreamOnlyService)(nil) - methods := map[string]kitex.MethodInfo{} - for name, m := range serviceMethods { - if m.IsStreaming() && !keepStreamingMethods { - continue - } - if !m.IsStreaming() && !keepNonStreamingMethods { - continue - } - methods[name] = m - } - extra := map[string]interface{}{ - "PackageName": "echo", - } - if hasStreaming { - extra["streaming"] = hasStreaming - } - svcInfo := &kitex.ServiceInfo{ - ServiceName: serviceName, - HandlerType: handlerType, - Methods: methods, - PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.8.0", - Extra: extra, - } - return svcInfo -} - -func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - st, ok := arg.(*streaming.Args) - if !ok { - return errors.New("StreamOnlyService.EchoBidirectionalNew is a thrift streaming method, please call with Kitex StreamClient") - } - stream := &streamOnlyServiceEchoBidirectionalNewServer{st.Stream} - return handler.(echo.StreamOnlyService).EchoBidirectionalNew(stream) -} - -type streamOnlyServiceEchoBidirectionalNewClient struct { - streaming.Stream -} - -func (x *streamOnlyServiceEchoBidirectionalNewClient) Send(m *echo.EchoRequest) error { - return x.Stream.SendMsg(m) -} -func (x *streamOnlyServiceEchoBidirectionalNewClient) Recv() (*echo.EchoResponse, error) { - m := new(echo.EchoResponse) - return m, x.Stream.RecvMsg(m) -} - -type streamOnlyServiceEchoBidirectionalNewServer struct { - streaming.Stream -} - -func (x *streamOnlyServiceEchoBidirectionalNewServer) Send(m *echo.EchoResponse) error { - return x.Stream.SendMsg(m) -} - -func (x *streamOnlyServiceEchoBidirectionalNewServer) Recv() (*echo.EchoRequest, error) { - m := new(echo.EchoRequest) - return m, x.Stream.RecvMsg(m) -} - -func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { - return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() -} - -func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { - return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() -} - -type kClient struct { - c client.Client -} - -func newServiceClient(c client.Client) *kClient { - return &kClient{ - c: c, - } -} - -func (p *kClient) EchoBidirectionalNew(ctx context.Context) (StreamOnlyService_EchoBidirectionalNewClient, error) { - streamClient, ok := p.c.(client.Streaming) - if !ok { - return nil, fmt.Errorf("client not support streaming") - } - res := new(streaming.Result) - err := streamClient.Stream(ctx, "EchoBidirectionalNew", nil, res) - if err != nil { - return nil, err - } - stream := &streamOnlyServiceEchoBidirectionalNewClient{res.Stream} - return stream, nil -} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechild/client.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechild/client.go deleted file mode 100644 index 257e546..0000000 --- a/thrift_streaming/kitex_gen/echo/streamonlyservicechild/client.go +++ /dev/null @@ -1,92 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package streamonlyservicechild - -import ( - "context" - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - client "github.com/cloudwego/kitex/client" - "github.com/cloudwego/kitex/client/callopt/streamcall" - "github.com/cloudwego/kitex/client/streamclient" - streaming "github.com/cloudwego/kitex/pkg/streaming" - transport "github.com/cloudwego/kitex/transport" -) - -// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. -type Client interface { -} - -// StreamClient is designed to provide Interface for Streaming APIs. -type StreamClient interface { - EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) -} - -type StreamOnlyService_EchoBidirectionalNewClient interface { - streaming.Stream - Send(*echo.EchoRequest) error - Recv() (*echo.EchoResponse, error) -} - -// NewClient creates a client for the service defined in IDL. -func NewClient(destService string, opts ...client.Option) (Client, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - - options = append(options, opts...) - - kc, err := client.NewClient(serviceInfoForClient(), options...) - if err != nil { - return nil, err - } - return &kStreamOnlyServiceChildClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. -func MustNewClient(destService string, opts ...client.Option) Client { - kc, err := NewClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kStreamOnlyServiceChildClient struct { - *kClient -} - -// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - options = append(options, client.WithTransportProtocol(transport.GRPC)) - options = append(options, streamclient.GetClientOptions(opts)...) - - kc, err := client.NewClient(serviceInfoForStreamClient(), options...) - if err != nil { - return nil, err - } - return &kStreamOnlyServiceChildStreamClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -// It panics if any error occurs. -func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { - kc, err := NewStreamClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kStreamOnlyServiceChildStreamClient struct { - *kClient -} - -func (p *kStreamOnlyServiceChildStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.EchoBidirectionalNew(ctx) -} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechild/invoker.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechild/invoker.go deleted file mode 100644 index 34a30f2..0000000 --- a/thrift_streaming/kitex_gen/echo/streamonlyservicechild/invoker.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package streamonlyservicechild - -import ( - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - server "github.com/cloudwego/kitex/server" -) - -// NewInvoker creates a server.Invoker with the given handler and options. -func NewInvoker(handler echo.StreamOnlyServiceChild, opts ...server.Option) server.Invoker { - var options []server.Option - - options = append(options, opts...) - - s := server.NewInvoker(options...) - if err := s.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - if err := s.Init(); err != nil { - panic(err) - } - return s -} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechild/server.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechild/server.go deleted file mode 100644 index c2d5088..0000000 --- a/thrift_streaming/kitex_gen/echo/streamonlyservicechild/server.go +++ /dev/null @@ -1,21 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. -package streamonlyservicechild - -import ( - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - server "github.com/cloudwego/kitex/server" -) - -// NewServer creates a server.Server with the given handler and options. -func NewServer(handler echo.StreamOnlyServiceChild, opts ...server.Option) server.Server { - var options []server.Option - - options = append(options, opts...) - options = append(options, server.WithCompatibleMiddlewareForUnary()) - - svr := server.NewServer(options...) - if err := svr.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - return svr -} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechild/streamonlyservicechild.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechild/streamonlyservicechild.go deleted file mode 100644 index 110d6a4..0000000 --- a/thrift_streaming/kitex_gen/echo/streamonlyservicechild/streamonlyservicechild.go +++ /dev/null @@ -1,155 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package streamonlyservicechild - -import ( - "context" - "errors" - "fmt" - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - client "github.com/cloudwego/kitex/client" - kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" -) - -var errInvalidMessageType = errors.New("invalid message type for service method handler") - -var serviceMethods = map[string]kitex.MethodInfo{ - "EchoBidirectionalNew": kitex.NewMethodInfo( - echoBidirectionalNewHandler, - newStreamOnlyServiceEchoBidirectionalNewArgs, - newStreamOnlyServiceEchoBidirectionalNewResult, - false, - kitex.WithStreamingMode(kitex.StreamingBidirectional), - ), -} - -var ( - streamOnlyServiceChildServiceInfo = NewServiceInfo() - streamOnlyServiceChildServiceInfoForClient = NewServiceInfoForClient() - streamOnlyServiceChildServiceInfoForStreamClient = NewServiceInfoForStreamClient() -) - -// for server -func serviceInfo() *kitex.ServiceInfo { - return streamOnlyServiceChildServiceInfo -} - -// for client -func serviceInfoForStreamClient() *kitex.ServiceInfo { - return streamOnlyServiceChildServiceInfoForStreamClient -} - -// for stream client -func serviceInfoForClient() *kitex.ServiceInfo { - return streamOnlyServiceChildServiceInfoForClient -} - -// NewServiceInfo creates a new ServiceInfo containing all methods -func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(true, true, true) -} - -// NewServiceInfo creates a new ServiceInfo containing non-streaming methods -func NewServiceInfoForClient() *kitex.ServiceInfo { - return newServiceInfo(false, false, true) -} -func NewServiceInfoForStreamClient() *kitex.ServiceInfo { - return newServiceInfo(true, true, false) -} - -func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { - serviceName := "StreamOnlyServiceChild" - handlerType := (*echo.StreamOnlyServiceChild)(nil) - methods := map[string]kitex.MethodInfo{} - for name, m := range serviceMethods { - if m.IsStreaming() && !keepStreamingMethods { - continue - } - if !m.IsStreaming() && !keepNonStreamingMethods { - continue - } - methods[name] = m - } - extra := map[string]interface{}{ - "PackageName": "echo", - } - if hasStreaming { - extra["streaming"] = hasStreaming - } - svcInfo := &kitex.ServiceInfo{ - ServiceName: serviceName, - HandlerType: handlerType, - Methods: methods, - PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.8.0", - Extra: extra, - } - return svcInfo -} - -func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - st, ok := arg.(*streaming.Args) - if !ok { - return errors.New("StreamOnlyService.EchoBidirectionalNew is a thrift streaming method, please call with Kitex StreamClient") - } - stream := &streamOnlyServiceEchoBidirectionalNewServer{st.Stream} - return handler.(echo.StreamOnlyService).EchoBidirectionalNew(stream) -} - -type streamOnlyServiceEchoBidirectionalNewClient struct { - streaming.Stream -} - -func (x *streamOnlyServiceEchoBidirectionalNewClient) Send(m *echo.EchoRequest) error { - return x.Stream.SendMsg(m) -} -func (x *streamOnlyServiceEchoBidirectionalNewClient) Recv() (*echo.EchoResponse, error) { - m := new(echo.EchoResponse) - return m, x.Stream.RecvMsg(m) -} - -type streamOnlyServiceEchoBidirectionalNewServer struct { - streaming.Stream -} - -func (x *streamOnlyServiceEchoBidirectionalNewServer) Send(m *echo.EchoResponse) error { - return x.Stream.SendMsg(m) -} - -func (x *streamOnlyServiceEchoBidirectionalNewServer) Recv() (*echo.EchoRequest, error) { - m := new(echo.EchoRequest) - return m, x.Stream.RecvMsg(m) -} - -func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { - return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() -} - -func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { - return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() -} - -type kClient struct { - c client.Client -} - -func newServiceClient(c client.Client) *kClient { - return &kClient{ - c: c, - } -} - -func (p *kClient) EchoBidirectionalNew(ctx context.Context) (StreamOnlyService_EchoBidirectionalNewClient, error) { - streamClient, ok := p.c.(client.Streaming) - if !ok { - return nil, fmt.Errorf("client not support streaming") - } - res := new(streaming.Result) - err := streamClient.Stream(ctx, "EchoBidirectionalNew", nil, res) - if err != nil { - return nil, err - } - stream := &streamOnlyServiceEchoBidirectionalNewClient{res.Stream} - return stream, nil -} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/client.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/client.go deleted file mode 100644 index 34e5462..0000000 --- a/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/client.go +++ /dev/null @@ -1,92 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package streamonlyservicechildchild - -import ( - "context" - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - client "github.com/cloudwego/kitex/client" - "github.com/cloudwego/kitex/client/callopt/streamcall" - "github.com/cloudwego/kitex/client/streamclient" - streaming "github.com/cloudwego/kitex/pkg/streaming" - transport "github.com/cloudwego/kitex/transport" -) - -// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. -type Client interface { -} - -// StreamClient is designed to provide Interface for Streaming APIs. -type StreamClient interface { - EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) -} - -type StreamOnlyService_EchoBidirectionalNewClient interface { - streaming.Stream - Send(*echo.EchoRequest) error - Recv() (*echo.EchoResponse, error) -} - -// NewClient creates a client for the service defined in IDL. -func NewClient(destService string, opts ...client.Option) (Client, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - - options = append(options, opts...) - - kc, err := client.NewClient(serviceInfoForClient(), options...) - if err != nil { - return nil, err - } - return &kStreamOnlyServiceChildChildClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. -func MustNewClient(destService string, opts ...client.Option) Client { - kc, err := NewClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kStreamOnlyServiceChildChildClient struct { - *kClient -} - -// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - options = append(options, client.WithTransportProtocol(transport.GRPC)) - options = append(options, streamclient.GetClientOptions(opts)...) - - kc, err := client.NewClient(serviceInfoForStreamClient(), options...) - if err != nil { - return nil, err - } - return &kStreamOnlyServiceChildChildStreamClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -// It panics if any error occurs. -func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { - kc, err := NewStreamClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kStreamOnlyServiceChildChildStreamClient struct { - *kClient -} - -func (p *kStreamOnlyServiceChildChildStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.EchoBidirectionalNew(ctx) -} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/invoker.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/invoker.go deleted file mode 100644 index d314e03..0000000 --- a/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/invoker.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package streamonlyservicechildchild - -import ( - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - server "github.com/cloudwego/kitex/server" -) - -// NewInvoker creates a server.Invoker with the given handler and options. -func NewInvoker(handler echo.StreamOnlyServiceChildChild, opts ...server.Option) server.Invoker { - var options []server.Option - - options = append(options, opts...) - - s := server.NewInvoker(options...) - if err := s.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - if err := s.Init(); err != nil { - panic(err) - } - return s -} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/server.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/server.go deleted file mode 100644 index 68b2d4c..0000000 --- a/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/server.go +++ /dev/null @@ -1,21 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. -package streamonlyservicechildchild - -import ( - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - server "github.com/cloudwego/kitex/server" -) - -// NewServer creates a server.Server with the given handler and options. -func NewServer(handler echo.StreamOnlyServiceChildChild, opts ...server.Option) server.Server { - var options []server.Option - - options = append(options, opts...) - options = append(options, server.WithCompatibleMiddlewareForUnary()) - - svr := server.NewServer(options...) - if err := svr.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - return svr -} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/streamonlyservicechildchild.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/streamonlyservicechildchild.go deleted file mode 100644 index e254e50..0000000 --- a/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/streamonlyservicechildchild.go +++ /dev/null @@ -1,155 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package streamonlyservicechildchild - -import ( - "context" - "errors" - "fmt" - echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" - client "github.com/cloudwego/kitex/client" - kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" -) - -var errInvalidMessageType = errors.New("invalid message type for service method handler") - -var serviceMethods = map[string]kitex.MethodInfo{ - "EchoBidirectionalNew": kitex.NewMethodInfo( - echoBidirectionalNewHandler, - newStreamOnlyServiceEchoBidirectionalNewArgs, - newStreamOnlyServiceEchoBidirectionalNewResult, - false, - kitex.WithStreamingMode(kitex.StreamingBidirectional), - ), -} - -var ( - streamOnlyServiceChildChildServiceInfo = NewServiceInfo() - streamOnlyServiceChildChildServiceInfoForClient = NewServiceInfoForClient() - streamOnlyServiceChildChildServiceInfoForStreamClient = NewServiceInfoForStreamClient() -) - -// for server -func serviceInfo() *kitex.ServiceInfo { - return streamOnlyServiceChildChildServiceInfo -} - -// for client -func serviceInfoForStreamClient() *kitex.ServiceInfo { - return streamOnlyServiceChildChildServiceInfoForStreamClient -} - -// for stream client -func serviceInfoForClient() *kitex.ServiceInfo { - return streamOnlyServiceChildChildServiceInfoForClient -} - -// NewServiceInfo creates a new ServiceInfo containing all methods -func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(true, true, true) -} - -// NewServiceInfo creates a new ServiceInfo containing non-streaming methods -func NewServiceInfoForClient() *kitex.ServiceInfo { - return newServiceInfo(false, false, true) -} -func NewServiceInfoForStreamClient() *kitex.ServiceInfo { - return newServiceInfo(true, true, false) -} - -func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { - serviceName := "StreamOnlyServiceChildChild" - handlerType := (*echo.StreamOnlyServiceChildChild)(nil) - methods := map[string]kitex.MethodInfo{} - for name, m := range serviceMethods { - if m.IsStreaming() && !keepStreamingMethods { - continue - } - if !m.IsStreaming() && !keepNonStreamingMethods { - continue - } - methods[name] = m - } - extra := map[string]interface{}{ - "PackageName": "echo", - } - if hasStreaming { - extra["streaming"] = hasStreaming - } - svcInfo := &kitex.ServiceInfo{ - ServiceName: serviceName, - HandlerType: handlerType, - Methods: methods, - PayloadCodec: kitex.Thrift, - KiteXGenVersion: "v0.8.0", - Extra: extra, - } - return svcInfo -} - -func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - st, ok := arg.(*streaming.Args) - if !ok { - return errors.New("StreamOnlyService.EchoBidirectionalNew is a thrift streaming method, please call with Kitex StreamClient") - } - stream := &streamOnlyServiceEchoBidirectionalNewServer{st.Stream} - return handler.(echo.StreamOnlyService).EchoBidirectionalNew(stream) -} - -type streamOnlyServiceEchoBidirectionalNewClient struct { - streaming.Stream -} - -func (x *streamOnlyServiceEchoBidirectionalNewClient) Send(m *echo.EchoRequest) error { - return x.Stream.SendMsg(m) -} -func (x *streamOnlyServiceEchoBidirectionalNewClient) Recv() (*echo.EchoResponse, error) { - m := new(echo.EchoResponse) - return m, x.Stream.RecvMsg(m) -} - -type streamOnlyServiceEchoBidirectionalNewServer struct { - streaming.Stream -} - -func (x *streamOnlyServiceEchoBidirectionalNewServer) Send(m *echo.EchoResponse) error { - return x.Stream.SendMsg(m) -} - -func (x *streamOnlyServiceEchoBidirectionalNewServer) Recv() (*echo.EchoRequest, error) { - m := new(echo.EchoRequest) - return m, x.Stream.RecvMsg(m) -} - -func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { - return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() -} - -func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { - return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() -} - -type kClient struct { - c client.Client -} - -func newServiceClient(c client.Client) *kClient { - return &kClient{ - c: c, - } -} - -func (p *kClient) EchoBidirectionalNew(ctx context.Context) (StreamOnlyService_EchoBidirectionalNewClient, error) { - streamClient, ok := p.c.(client.Streaming) - if !ok { - return nil, fmt.Errorf("client not support streaming") - } - res := new(streaming.Result) - err := streamClient.Stream(ctx, "EchoBidirectionalNew", nil, res) - if err != nil { - return nil, err - } - stream := &streamOnlyServiceEchoBidirectionalNewClient{res.Stream} - return stream, nil -} diff --git a/thrift_streaming/kitex_gen/grpc_pb/api.pb.fast.go b/thrift_streaming/kitex_gen/grpc_pb/api.pb.fast.go deleted file mode 100644 index 191a376..0000000 --- a/thrift_streaming/kitex_gen/grpc_pb/api.pb.fast.go +++ /dev/null @@ -1,135 +0,0 @@ -// Code generated by Fastpb v0.0.2. DO NOT EDIT. - -package grpc_pb - -import ( - fmt "fmt" - fastpb "github.com/cloudwego/fastpb" -) - -var ( - _ = fmt.Errorf - _ = fastpb.Skip -) - -func (x *Request) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_Request[number], err) -} - -func (x *Request) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.Message, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *Response) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_Response[number], err) -} - -func (x *Response) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.Message, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *Request) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - return offset -} - -func (x *Request) fastWriteField1(buf []byte) (offset int) { - if x.Message == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 1, x.GetMessage()) - return offset -} - -func (x *Response) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - return offset -} - -func (x *Response) fastWriteField1(buf []byte) (offset int) { - if x.Message == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 1, x.GetMessage()) - return offset -} - -func (x *Request) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - return n -} - -func (x *Request) sizeField1() (n int) { - if x.Message == "" { - return n - } - n += fastpb.SizeString(1, x.GetMessage()) - return n -} - -func (x *Response) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - return n -} - -func (x *Response) sizeField1() (n int) { - if x.Message == "" { - return n - } - n += fastpb.SizeString(1, x.GetMessage()) - return n -} - -var fieldIDToName_Request = map[int32]string{ - 1: "Message", -} - -var fieldIDToName_Response = map[int32]string{ - 1: "Message", -} diff --git a/thrift_streaming/kitex_gen/grpc_pb/api.pb.go b/thrift_streaming/kitex_gen/grpc_pb/api.pb.go deleted file mode 100644 index a46c9e4..0000000 --- a/thrift_streaming/kitex_gen/grpc_pb/api.pb.go +++ /dev/null @@ -1,274 +0,0 @@ -// Copyright 2023 CloudWeGo Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 -// source: idl/api.proto - -package grpc_pb - -import ( - context "context" - streaming "github.com/cloudwego/kitex/pkg/streaming" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type Request struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *Request) Reset() { - *x = Request{} - if protoimpl.UnsafeEnabled { - mi := &file_idl_api_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Request) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Request) ProtoMessage() {} - -func (x *Request) ProtoReflect() protoreflect.Message { - mi := &file_idl_api_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Request.ProtoReflect.Descriptor instead. -func (*Request) Descriptor() ([]byte, []int) { - return file_idl_api_proto_rawDescGZIP(), []int{0} -} - -func (x *Request) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -type Response struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *Response) Reset() { - *x = Response{} - if protoimpl.UnsafeEnabled { - mi := &file_idl_api_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Response) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Response) ProtoMessage() {} - -func (x *Response) ProtoReflect() protoreflect.Message { - mi := &file_idl_api_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Response.ProtoReflect.Descriptor instead. -func (*Response) Descriptor() ([]byte, []int) { - return file_idl_api_proto_rawDescGZIP(), []int{1} -} - -func (x *Response) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -var File_idl_api_proto protoreflect.FileDescriptor - -var file_idl_api_proto_rawDesc = []byte{ - 0x0a, 0x0d, 0x69, 0x64, 0x6c, 0x2f, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x07, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, 0x22, 0x23, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x24, 0x0a, - 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x32, 0xe3, 0x01, 0x0a, 0x09, 0x50, 0x42, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x31, 0x0a, 0x04, 0x45, 0x63, 0x68, 0x6f, 0x12, 0x10, 0x2e, 0x67, 0x72, 0x70, 0x63, - 0x5f, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x67, 0x72, - 0x70, 0x63, 0x5f, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x28, 0x01, 0x30, 0x01, 0x12, 0x35, 0x0a, 0x0a, 0x45, 0x63, 0x68, 0x6f, 0x43, 0x6c, 0x69, 0x65, - 0x6e, 0x74, 0x12, 0x10, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, 0x2e, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x12, 0x35, 0x0a, 0x0a, 0x45, - 0x63, 0x68, 0x6f, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x10, 0x2e, 0x67, 0x72, 0x70, 0x63, - 0x5f, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x67, 0x72, - 0x70, 0x63, 0x5f, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x30, 0x01, 0x12, 0x35, 0x0a, 0x0c, 0x45, 0x63, 0x68, 0x6f, 0x50, 0x69, 0x6e, 0x67, 0x50, 0x6f, - 0x6e, 0x67, 0x12, 0x10, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, 0x2e, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x45, 0x5a, 0x43, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x77, 0x65, 0x67, - 0x6f, 0x2f, 0x6b, 0x69, 0x74, 0x65, 0x78, 0x2d, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x74, 0x68, - 0x72, 0x69, 0x66, 0x74, 0x5f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x69, 0x6e, 0x67, 0x2f, 0x6b, - 0x69, 0x74, 0x65, 0x78, 0x5f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_idl_api_proto_rawDescOnce sync.Once - file_idl_api_proto_rawDescData = file_idl_api_proto_rawDesc -) - -func file_idl_api_proto_rawDescGZIP() []byte { - file_idl_api_proto_rawDescOnce.Do(func() { - file_idl_api_proto_rawDescData = protoimpl.X.CompressGZIP(file_idl_api_proto_rawDescData) - }) - return file_idl_api_proto_rawDescData -} - -var file_idl_api_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_idl_api_proto_goTypes = []interface{}{ - (*Request)(nil), // 0: grpc_pb.Request - (*Response)(nil), // 1: grpc_pb.Response -} -var file_idl_api_proto_depIdxs = []int32{ - 0, // 0: grpc_pb.PBService.Echo:input_type -> grpc_pb.Request - 0, // 1: grpc_pb.PBService.EchoClient:input_type -> grpc_pb.Request - 0, // 2: grpc_pb.PBService.EchoServer:input_type -> grpc_pb.Request - 0, // 3: grpc_pb.PBService.EchoPingPong:input_type -> grpc_pb.Request - 1, // 4: grpc_pb.PBService.Echo:output_type -> grpc_pb.Response - 1, // 5: grpc_pb.PBService.EchoClient:output_type -> grpc_pb.Response - 1, // 6: grpc_pb.PBService.EchoServer:output_type -> grpc_pb.Response - 1, // 7: grpc_pb.PBService.EchoPingPong:output_type -> grpc_pb.Response - 4, // [4:8] is the sub-list for method output_type - 0, // [0:4] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_idl_api_proto_init() } -func file_idl_api_proto_init() { - if File_idl_api_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_idl_api_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Request); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_idl_api_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Response); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_idl_api_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_idl_api_proto_goTypes, - DependencyIndexes: file_idl_api_proto_depIdxs, - MessageInfos: file_idl_api_proto_msgTypes, - }.Build() - File_idl_api_proto = out.File - file_idl_api_proto_rawDesc = nil - file_idl_api_proto_goTypes = nil - file_idl_api_proto_depIdxs = nil -} - -var _ context.Context - -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -type PBService interface { - Echo(stream PBService_EchoServer) (err error) - EchoClient(stream PBService_EchoClientServer) (err error) - EchoServer(req *Request, stream PBService_EchoServerServer) (err error) - EchoPingPong(ctx context.Context, req *Request) (res *Response, err error) -} - -type PBService_EchoServer interface { - streaming.Stream - Recv() (*Request, error) - Send(*Response) error -} - -type PBService_EchoClientServer interface { - streaming.Stream - Recv() (*Request, error) - SendAndClose(*Response) error -} - -type PBService_EchoServerServer interface { - streaming.Stream - Send(*Response) error -} diff --git a/thrift_streaming/kitex_gen/grpc_pb/pbservice/client.go b/thrift_streaming/kitex_gen/grpc_pb/pbservice/client.go deleted file mode 100644 index 6d93321..0000000 --- a/thrift_streaming/kitex_gen/grpc_pb/pbservice/client.go +++ /dev/null @@ -1,142 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package pbservice - -import ( - "context" - grpc_pb "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/grpc_pb" - client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" - streaming "github.com/cloudwego/kitex/pkg/streaming" - transport "github.com/cloudwego/kitex/transport" - "github.com/cloudwego/kitex/client/streamclient" - "github.com/cloudwego/kitex/client/callopt/streamcall" -) - -// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. -type Client interface { - Echo(ctx context.Context, callOptions ...callopt.Option) (stream PBService_EchoClient, err error) - EchoClient(ctx context.Context, callOptions ...callopt.Option) (stream PBService_EchoClientClient, err error) - EchoServer(ctx context.Context, Req *grpc_pb.Request, callOptions ...callopt.Option) (stream PBService_EchoServerClient, err error) - EchoPingPong(ctx context.Context, Req *grpc_pb.Request, callOptions ...callopt.Option) (r *grpc_pb.Response, err error) -} - -// StreamClient is designed to provide Interface for Streaming APIs. -type StreamClient interface { - Echo(ctx context.Context, callOptions ...streamcall.Option) (stream PBService_EchoClient, err error) - EchoClient(ctx context.Context, callOptions ...streamcall.Option) (stream PBService_EchoClientClient, err error) - EchoServer(ctx context.Context, Req *grpc_pb.Request, callOptions ...streamcall.Option) (stream PBService_EchoServerClient, err error) -} - -type PBService_EchoClient interface { - streaming.Stream - Send(*grpc_pb.Request) error - Recv() (*grpc_pb.Response, error) -} - -type PBService_EchoClientClient interface { - streaming.Stream - Send(*grpc_pb.Request) error - CloseAndRecv() (*grpc_pb.Response, error) -} - -type PBService_EchoServerClient interface { - streaming.Stream - Recv() (*grpc_pb.Response, error) -} - -// NewClient creates a client for the service defined in IDL. -func NewClient(destService string, opts ...client.Option) (Client, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - - options = append(options, client.WithTransportProtocol(transport.GRPC)) - - options = append(options, opts...) - - kc, err := client.NewClient(serviceInfo(), options...) - if err != nil { - return nil, err - } - return &kPBServiceClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. -func MustNewClient(destService string, opts ...client.Option) Client { - kc, err := NewClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kPBServiceClient struct { - *kClient -} - -func (p *kPBServiceClient) Echo(ctx context.Context, callOptions ...callopt.Option) (stream PBService_EchoClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.Echo(ctx) -} - -func (p *kPBServiceClient) EchoClient(ctx context.Context, callOptions ...callopt.Option) (stream PBService_EchoClientClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.EchoClient(ctx) -} - -func (p *kPBServiceClient) EchoServer(ctx context.Context, Req *grpc_pb.Request, callOptions ...callopt.Option) (stream PBService_EchoServerClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.EchoServer(ctx, Req) -} - -func (p *kPBServiceClient) EchoPingPong(ctx context.Context, Req *grpc_pb.Request, callOptions ...callopt.Option) (r *grpc_pb.Response, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.EchoPingPong(ctx, Req) -} - -// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - options = append(options, client.WithTransportProtocol(transport.GRPC)) - options = append(options, streamclient.GetClientOptions(opts)...) - - kc, err := client.NewClient(serviceInfoForStreamClient(), options...) - if err != nil { - return nil, err - } - return &kPBServiceStreamClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -// It panics if any error occurs. -func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { - kc, err := NewStreamClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kPBServiceStreamClient struct { - *kClient -} - -func (p *kPBServiceStreamClient) Echo(ctx context.Context, callOptions ...streamcall.Option) (stream PBService_EchoClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.Echo(ctx) -} - -func (p *kPBServiceStreamClient) EchoClient(ctx context.Context, callOptions ...streamcall.Option) (stream PBService_EchoClientClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.EchoClient(ctx) -} - -func (p *kPBServiceStreamClient) EchoServer(ctx context.Context, Req *grpc_pb.Request, callOptions ...streamcall.Option) (stream PBService_EchoServerClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.EchoServer(ctx, Req) -} diff --git a/thrift_streaming/kitex_gen/grpc_pb/pbservice/invoker.go b/thrift_streaming/kitex_gen/grpc_pb/pbservice/invoker.go deleted file mode 100644 index d35eb3f..0000000 --- a/thrift_streaming/kitex_gen/grpc_pb/pbservice/invoker.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package pbservice - -import ( - grpc_pb "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/grpc_pb" - server "github.com/cloudwego/kitex/server" -) - -// NewInvoker creates a server.Invoker with the given handler and options. -func NewInvoker(handler grpc_pb.PBService, opts ...server.Option) server.Invoker { - var options []server.Option - - options = append(options, opts...) - - s := server.NewInvoker(options...) - if err := s.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - if err := s.Init(); err != nil { - panic(err) - } - return s -} diff --git a/thrift_streaming/kitex_gen/grpc_pb/pbservice/pbservice.go b/thrift_streaming/kitex_gen/grpc_pb/pbservice/pbservice.go deleted file mode 100644 index c18e62c..0000000 --- a/thrift_streaming/kitex_gen/grpc_pb/pbservice/pbservice.go +++ /dev/null @@ -1,809 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package pbservice - -import ( - "context" - "errors" - "fmt" - grpc_pb "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/grpc_pb" - client "github.com/cloudwego/kitex/client" - kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" - proto "google.golang.org/protobuf/proto" -) - -var errInvalidMessageType = errors.New("invalid message type for service method handler") - -var serviceMethods = map[string]kitex.MethodInfo{ - "Echo": kitex.NewMethodInfo( - echoHandler, - newEchoArgs, - newEchoResult, - false, - kitex.WithStreamingMode(kitex.StreamingBidirectional), - ), - "EchoClient": kitex.NewMethodInfo( - echoClientHandler, - newEchoClientArgs, - newEchoClientResult, - false, - kitex.WithStreamingMode(kitex.StreamingClient), - ), - "EchoServer": kitex.NewMethodInfo( - echoServerHandler, - newEchoServerArgs, - newEchoServerResult, - false, - kitex.WithStreamingMode(kitex.StreamingServer), - ), - "EchoPingPong": kitex.NewMethodInfo( - echoPingPongHandler, - newEchoPingPongArgs, - newEchoPingPongResult, - false, - kitex.WithStreamingMode(kitex.StreamingUnary), - ), -} - -var ( - pBServiceServiceInfo = NewServiceInfo() - pBServiceServiceInfoForClient = NewServiceInfoForClient() - pBServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() -) - -// for server -func serviceInfo() *kitex.ServiceInfo { - return pBServiceServiceInfo -} - -// for client -func serviceInfoForStreamClient() *kitex.ServiceInfo { - return pBServiceServiceInfoForStreamClient -} - -// for stream client -func serviceInfoForClient() *kitex.ServiceInfo { - return pBServiceServiceInfoForClient -} - -// NewServiceInfo creates a new ServiceInfo containing all methods -func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(true, true, true) -} - -// NewServiceInfo creates a new ServiceInfo containing non-streaming methods -func NewServiceInfoForClient() *kitex.ServiceInfo { - return newServiceInfo(false, false, true) -} -func NewServiceInfoForStreamClient() *kitex.ServiceInfo { - return newServiceInfo(true, true, false) -} - -func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { - serviceName := "PBService" - handlerType := (*grpc_pb.PBService)(nil) - methods := map[string]kitex.MethodInfo{} - for name, m := range serviceMethods { - if m.IsStreaming() && !keepStreamingMethods { - continue - } - if !m.IsStreaming() && !keepNonStreamingMethods { - continue - } - methods[name] = m - } - extra := map[string]interface{}{ - "PackageName": "grpc_pb", - } - if hasStreaming { - extra["streaming"] = hasStreaming - } - svcInfo := &kitex.ServiceInfo{ - ServiceName: serviceName, - HandlerType: handlerType, - Methods: methods, - PayloadCodec: kitex.Protobuf, - KiteXGenVersion: "v0.8.0", - Extra: extra, - } - return svcInfo -} - -func echoHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - st := arg.(*streaming.Args).Stream - stream := &pBServiceEchoServer{st} - return handler.(grpc_pb.PBService).Echo(stream) -} - -type pBServiceEchoClient struct { - streaming.Stream -} - -func (x *pBServiceEchoClient) Send(m *grpc_pb.Request) error { - return x.Stream.SendMsg(m) -} -func (x *pBServiceEchoClient) Recv() (*grpc_pb.Response, error) { - m := new(grpc_pb.Response) - return m, x.Stream.RecvMsg(m) -} - -type pBServiceEchoServer struct { - streaming.Stream -} - -func (x *pBServiceEchoServer) Send(m *grpc_pb.Response) error { - return x.Stream.SendMsg(m) -} - -func (x *pBServiceEchoServer) Recv() (*grpc_pb.Request, error) { - m := new(grpc_pb.Request) - return m, x.Stream.RecvMsg(m) -} - -func newEchoArgs() interface{} { - return &EchoArgs{} -} - -func newEchoResult() interface{} { - return &EchoResult{} -} - -type EchoArgs struct { - Req *grpc_pb.Request -} - -func (p *EchoArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(grpc_pb.Request) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *EchoArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *EchoArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *EchoArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, nil - } - return proto.Marshal(p.Req) -} - -func (p *EchoArgs) Unmarshal(in []byte) error { - msg := new(grpc_pb.Request) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var EchoArgs_Req_DEFAULT *grpc_pb.Request - -func (p *EchoArgs) GetReq() *grpc_pb.Request { - if !p.IsSetReq() { - return EchoArgs_Req_DEFAULT - } - return p.Req -} - -func (p *EchoArgs) IsSetReq() bool { - return p.Req != nil -} - -func (p *EchoArgs) GetFirstArgument() interface{} { - return p.Req -} - -type EchoResult struct { - Success *grpc_pb.Response -} - -var EchoResult_Success_DEFAULT *grpc_pb.Response - -func (p *EchoResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(grpc_pb.Response) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *EchoResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *EchoResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *EchoResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, nil - } - return proto.Marshal(p.Success) -} - -func (p *EchoResult) Unmarshal(in []byte) error { - msg := new(grpc_pb.Response) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *EchoResult) GetSuccess() *grpc_pb.Response { - if !p.IsSetSuccess() { - return EchoResult_Success_DEFAULT - } - return p.Success -} - -func (p *EchoResult) SetSuccess(x interface{}) { - p.Success = x.(*grpc_pb.Response) -} - -func (p *EchoResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *EchoResult) GetResult() interface{} { - return p.Success -} - -func echoClientHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - st := arg.(*streaming.Args).Stream - stream := &pBServiceEchoClientServer{st} - return handler.(grpc_pb.PBService).EchoClient(stream) -} - -type pBServiceEchoClientClient struct { - streaming.Stream -} - -func (x *pBServiceEchoClientClient) Send(m *grpc_pb.Request) error { - return x.Stream.SendMsg(m) -} -func (x *pBServiceEchoClientClient) CloseAndRecv() (*grpc_pb.Response, error) { - if err := x.Stream.Close(); err != nil { - return nil, err - } - m := new(grpc_pb.Response) - return m, x.Stream.RecvMsg(m) -} - -type pBServiceEchoClientServer struct { - streaming.Stream -} - -func (x *pBServiceEchoClientServer) SendAndClose(m *grpc_pb.Response) error { - return x.Stream.SendMsg(m) -} - -func (x *pBServiceEchoClientServer) Recv() (*grpc_pb.Request, error) { - m := new(grpc_pb.Request) - return m, x.Stream.RecvMsg(m) -} - -func newEchoClientArgs() interface{} { - return &EchoClientArgs{} -} - -func newEchoClientResult() interface{} { - return &EchoClientResult{} -} - -type EchoClientArgs struct { - Req *grpc_pb.Request -} - -func (p *EchoClientArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(grpc_pb.Request) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *EchoClientArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *EchoClientArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *EchoClientArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, nil - } - return proto.Marshal(p.Req) -} - -func (p *EchoClientArgs) Unmarshal(in []byte) error { - msg := new(grpc_pb.Request) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var EchoClientArgs_Req_DEFAULT *grpc_pb.Request - -func (p *EchoClientArgs) GetReq() *grpc_pb.Request { - if !p.IsSetReq() { - return EchoClientArgs_Req_DEFAULT - } - return p.Req -} - -func (p *EchoClientArgs) IsSetReq() bool { - return p.Req != nil -} - -func (p *EchoClientArgs) GetFirstArgument() interface{} { - return p.Req -} - -type EchoClientResult struct { - Success *grpc_pb.Response -} - -var EchoClientResult_Success_DEFAULT *grpc_pb.Response - -func (p *EchoClientResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(grpc_pb.Response) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *EchoClientResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *EchoClientResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *EchoClientResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, nil - } - return proto.Marshal(p.Success) -} - -func (p *EchoClientResult) Unmarshal(in []byte) error { - msg := new(grpc_pb.Response) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *EchoClientResult) GetSuccess() *grpc_pb.Response { - if !p.IsSetSuccess() { - return EchoClientResult_Success_DEFAULT - } - return p.Success -} - -func (p *EchoClientResult) SetSuccess(x interface{}) { - p.Success = x.(*grpc_pb.Response) -} - -func (p *EchoClientResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *EchoClientResult) GetResult() interface{} { - return p.Success -} - -func echoServerHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - st := arg.(*streaming.Args).Stream - stream := &pBServiceEchoServerServer{st} - req := new(grpc_pb.Request) - if err := st.RecvMsg(req); err != nil { - return err - } - return handler.(grpc_pb.PBService).EchoServer(req, stream) -} - -type pBServiceEchoServerClient struct { - streaming.Stream -} - -func (x *pBServiceEchoServerClient) Recv() (*grpc_pb.Response, error) { - m := new(grpc_pb.Response) - return m, x.Stream.RecvMsg(m) -} - -type pBServiceEchoServerServer struct { - streaming.Stream -} - -func (x *pBServiceEchoServerServer) Send(m *grpc_pb.Response) error { - return x.Stream.SendMsg(m) -} - -func newEchoServerArgs() interface{} { - return &EchoServerArgs{} -} - -func newEchoServerResult() interface{} { - return &EchoServerResult{} -} - -type EchoServerArgs struct { - Req *grpc_pb.Request -} - -func (p *EchoServerArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(grpc_pb.Request) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *EchoServerArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *EchoServerArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *EchoServerArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, nil - } - return proto.Marshal(p.Req) -} - -func (p *EchoServerArgs) Unmarshal(in []byte) error { - msg := new(grpc_pb.Request) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var EchoServerArgs_Req_DEFAULT *grpc_pb.Request - -func (p *EchoServerArgs) GetReq() *grpc_pb.Request { - if !p.IsSetReq() { - return EchoServerArgs_Req_DEFAULT - } - return p.Req -} - -func (p *EchoServerArgs) IsSetReq() bool { - return p.Req != nil -} - -func (p *EchoServerArgs) GetFirstArgument() interface{} { - return p.Req -} - -type EchoServerResult struct { - Success *grpc_pb.Response -} - -var EchoServerResult_Success_DEFAULT *grpc_pb.Response - -func (p *EchoServerResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(grpc_pb.Response) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *EchoServerResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *EchoServerResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *EchoServerResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, nil - } - return proto.Marshal(p.Success) -} - -func (p *EchoServerResult) Unmarshal(in []byte) error { - msg := new(grpc_pb.Response) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *EchoServerResult) GetSuccess() *grpc_pb.Response { - if !p.IsSetSuccess() { - return EchoServerResult_Success_DEFAULT - } - return p.Success -} - -func (p *EchoServerResult) SetSuccess(x interface{}) { - p.Success = x.(*grpc_pb.Response) -} - -func (p *EchoServerResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *EchoServerResult) GetResult() interface{} { - return p.Success -} - -func echoPingPongHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(grpc_pb.Request) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(grpc_pb.PBService).EchoPingPong(ctx, req) - if err != nil { - return err - } - return st.SendMsg(resp) - case *EchoPingPongArgs: - success, err := handler.(grpc_pb.PBService).EchoPingPong(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*EchoPingPongResult) - realResult.Success = success - return nil - default: - return errInvalidMessageType - } -} -func newEchoPingPongArgs() interface{} { - return &EchoPingPongArgs{} -} - -func newEchoPingPongResult() interface{} { - return &EchoPingPongResult{} -} - -type EchoPingPongArgs struct { - Req *grpc_pb.Request -} - -func (p *EchoPingPongArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(grpc_pb.Request) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *EchoPingPongArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *EchoPingPongArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *EchoPingPongArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, nil - } - return proto.Marshal(p.Req) -} - -func (p *EchoPingPongArgs) Unmarshal(in []byte) error { - msg := new(grpc_pb.Request) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var EchoPingPongArgs_Req_DEFAULT *grpc_pb.Request - -func (p *EchoPingPongArgs) GetReq() *grpc_pb.Request { - if !p.IsSetReq() { - return EchoPingPongArgs_Req_DEFAULT - } - return p.Req -} - -func (p *EchoPingPongArgs) IsSetReq() bool { - return p.Req != nil -} - -func (p *EchoPingPongArgs) GetFirstArgument() interface{} { - return p.Req -} - -type EchoPingPongResult struct { - Success *grpc_pb.Response -} - -var EchoPingPongResult_Success_DEFAULT *grpc_pb.Response - -func (p *EchoPingPongResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(grpc_pb.Response) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *EchoPingPongResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *EchoPingPongResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *EchoPingPongResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, nil - } - return proto.Marshal(p.Success) -} - -func (p *EchoPingPongResult) Unmarshal(in []byte) error { - msg := new(grpc_pb.Response) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *EchoPingPongResult) GetSuccess() *grpc_pb.Response { - if !p.IsSetSuccess() { - return EchoPingPongResult_Success_DEFAULT - } - return p.Success -} - -func (p *EchoPingPongResult) SetSuccess(x interface{}) { - p.Success = x.(*grpc_pb.Response) -} - -func (p *EchoPingPongResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *EchoPingPongResult) GetResult() interface{} { - return p.Success -} - -type kClient struct { - c client.Client -} - -func newServiceClient(c client.Client) *kClient { - return &kClient{ - c: c, - } -} - -func (p *kClient) Echo(ctx context.Context) (PBService_EchoClient, error) { - streamClient, ok := p.c.(client.Streaming) - if !ok { - return nil, fmt.Errorf("client not support streaming") - } - res := new(streaming.Result) - err := streamClient.Stream(ctx, "Echo", nil, res) - if err != nil { - return nil, err - } - stream := &pBServiceEchoClient{res.Stream} - return stream, nil -} - -func (p *kClient) EchoClient(ctx context.Context) (PBService_EchoClientClient, error) { - streamClient, ok := p.c.(client.Streaming) - if !ok { - return nil, fmt.Errorf("client not support streaming") - } - res := new(streaming.Result) - err := streamClient.Stream(ctx, "EchoClient", nil, res) - if err != nil { - return nil, err - } - stream := &pBServiceEchoClientClient{res.Stream} - return stream, nil -} - -func (p *kClient) EchoServer(ctx context.Context, req *grpc_pb.Request) (PBService_EchoServerClient, error) { - streamClient, ok := p.c.(client.Streaming) - if !ok { - return nil, fmt.Errorf("client not support streaming") - } - res := new(streaming.Result) - err := streamClient.Stream(ctx, "EchoServer", nil, res) - if err != nil { - return nil, err - } - stream := &pBServiceEchoServerClient{res.Stream} - - if err := stream.Stream.SendMsg(req); err != nil { - return nil, err - } - if err := stream.Stream.Close(); err != nil { - return nil, err - } - return stream, nil -} - -func (p *kClient) EchoPingPong(ctx context.Context, Req *grpc_pb.Request) (r *grpc_pb.Response, err error) { - var _args EchoPingPongArgs - _args.Req = Req - var _result EchoPingPongResult - if err = p.c.Call(ctx, "EchoPingPong", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} diff --git a/thrift_streaming/kitex_gen/grpc_pb/pbservice/server.go b/thrift_streaming/kitex_gen/grpc_pb/pbservice/server.go deleted file mode 100644 index aa66822..0000000 --- a/thrift_streaming/kitex_gen/grpc_pb/pbservice/server.go +++ /dev/null @@ -1,20 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. -package pbservice - -import ( - grpc_pb "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/grpc_pb" - server "github.com/cloudwego/kitex/server" -) - -// NewServer creates a server.Server with the given handler and options. -func NewServer(handler grpc_pb.PBService, opts ...server.Option) server.Server { - var options []server.Option - - options = append(options, opts...) - - svr := server.NewServer(options...) - if err := svr.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - return svr -} diff --git a/thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.fast.go b/thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.fast.go deleted file mode 100644 index aca5f22..0000000 --- a/thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.fast.go +++ /dev/null @@ -1,135 +0,0 @@ -// Code generated by Fastpb v0.0.2. DO NOT EDIT. - -package kitex_pb - -import ( - fmt "fmt" - fastpb "github.com/cloudwego/fastpb" -) - -var ( - _ = fmt.Errorf - _ = fastpb.Skip -) - -func (x *Request) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_Request[number], err) -} - -func (x *Request) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.Message, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *Response) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_Response[number], err) -} - -func (x *Response) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.Message, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *Request) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - return offset -} - -func (x *Request) fastWriteField1(buf []byte) (offset int) { - if x.Message == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 1, x.GetMessage()) - return offset -} - -func (x *Response) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - return offset -} - -func (x *Response) fastWriteField1(buf []byte) (offset int) { - if x.Message == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 1, x.GetMessage()) - return offset -} - -func (x *Request) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - return n -} - -func (x *Request) sizeField1() (n int) { - if x.Message == "" { - return n - } - n += fastpb.SizeString(1, x.GetMessage()) - return n -} - -func (x *Response) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - return n -} - -func (x *Response) sizeField1() (n int) { - if x.Message == "" { - return n - } - n += fastpb.SizeString(1, x.GetMessage()) - return n -} - -var fieldIDToName_Request = map[int32]string{ - 1: "Message", -} - -var fieldIDToName_Response = map[int32]string{ - 1: "Message", -} diff --git a/thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.go b/thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.go deleted file mode 100644 index 12e1add..0000000 --- a/thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.go +++ /dev/null @@ -1,238 +0,0 @@ -// Copyright 2023 CloudWeGo Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 -// source: idl/api_no_stream.proto - -package kitex_pb - -import ( - context "context" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type Request struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *Request) Reset() { - *x = Request{} - if protoimpl.UnsafeEnabled { - mi := &file_idl_api_no_stream_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Request) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Request) ProtoMessage() {} - -func (x *Request) ProtoReflect() protoreflect.Message { - mi := &file_idl_api_no_stream_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Request.ProtoReflect.Descriptor instead. -func (*Request) Descriptor() ([]byte, []int) { - return file_idl_api_no_stream_proto_rawDescGZIP(), []int{0} -} - -func (x *Request) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -type Response struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *Response) Reset() { - *x = Response{} - if protoimpl.UnsafeEnabled { - mi := &file_idl_api_no_stream_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Response) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Response) ProtoMessage() {} - -func (x *Response) ProtoReflect() protoreflect.Message { - mi := &file_idl_api_no_stream_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Response.ProtoReflect.Descriptor instead. -func (*Response) Descriptor() ([]byte, []int) { - return file_idl_api_no_stream_proto_rawDescGZIP(), []int{1} -} - -func (x *Response) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -var File_idl_api_no_stream_proto protoreflect.FileDescriptor - -var file_idl_api_no_stream_proto_rawDesc = []byte{ - 0x0a, 0x17, 0x69, 0x64, 0x6c, 0x2f, 0x61, 0x70, 0x69, 0x5f, 0x6e, 0x6f, 0x5f, 0x73, 0x74, 0x72, - 0x65, 0x61, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x6b, 0x69, 0x74, 0x65, 0x78, - 0x5f, 0x70, 0x62, 0x22, 0x23, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, - 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x24, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x44, - 0x0a, 0x09, 0x50, 0x42, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x37, 0x0a, 0x0c, 0x45, - 0x63, 0x68, 0x6f, 0x50, 0x69, 0x6e, 0x67, 0x50, 0x6f, 0x6e, 0x67, 0x12, 0x11, 0x2e, 0x6b, 0x69, - 0x74, 0x65, 0x78, 0x5f, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, - 0x2e, 0x6b, 0x69, 0x74, 0x65, 0x78, 0x5f, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x42, 0x46, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x77, 0x65, 0x67, 0x6f, 0x2f, 0x6b, 0x69, 0x74, - 0x65, 0x78, 0x2d, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x74, 0x68, 0x72, 0x69, 0x66, 0x74, 0x5f, - 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x69, 0x6e, 0x67, 0x2f, 0x6b, 0x69, 0x74, 0x65, 0x78, 0x5f, - 0x67, 0x65, 0x6e, 0x2f, 0x6b, 0x69, 0x74, 0x65, 0x78, 0x5f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_idl_api_no_stream_proto_rawDescOnce sync.Once - file_idl_api_no_stream_proto_rawDescData = file_idl_api_no_stream_proto_rawDesc -) - -func file_idl_api_no_stream_proto_rawDescGZIP() []byte { - file_idl_api_no_stream_proto_rawDescOnce.Do(func() { - file_idl_api_no_stream_proto_rawDescData = protoimpl.X.CompressGZIP(file_idl_api_no_stream_proto_rawDescData) - }) - return file_idl_api_no_stream_proto_rawDescData -} - -var file_idl_api_no_stream_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_idl_api_no_stream_proto_goTypes = []interface{}{ - (*Request)(nil), // 0: kitex_pb.Request - (*Response)(nil), // 1: kitex_pb.Response -} -var file_idl_api_no_stream_proto_depIdxs = []int32{ - 0, // 0: kitex_pb.PBService.EchoPingPong:input_type -> kitex_pb.Request - 1, // 1: kitex_pb.PBService.EchoPingPong:output_type -> kitex_pb.Response - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_idl_api_no_stream_proto_init() } -func file_idl_api_no_stream_proto_init() { - if File_idl_api_no_stream_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_idl_api_no_stream_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Request); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_idl_api_no_stream_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Response); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_idl_api_no_stream_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_idl_api_no_stream_proto_goTypes, - DependencyIndexes: file_idl_api_no_stream_proto_depIdxs, - MessageInfos: file_idl_api_no_stream_proto_msgTypes, - }.Build() - File_idl_api_no_stream_proto = out.File - file_idl_api_no_stream_proto_rawDesc = nil - file_idl_api_no_stream_proto_goTypes = nil - file_idl_api_no_stream_proto_depIdxs = nil -} - -var _ context.Context - -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -type PBService interface { - EchoPingPong(ctx context.Context, req *Request) (res *Response, err error) -} diff --git a/thrift_streaming/kitex_gen/kitex_pb/pbservice/client.go b/thrift_streaming/kitex_gen/kitex_pb/pbservice/client.go deleted file mode 100644 index f3f3ce9..0000000 --- a/thrift_streaming/kitex_gen/kitex_pb/pbservice/client.go +++ /dev/null @@ -1,49 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package pbservice - -import ( - "context" - kitex_pb "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/kitex_pb" - client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" -) - -// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. -type Client interface { - EchoPingPong(ctx context.Context, Req *kitex_pb.Request, callOptions ...callopt.Option) (r *kitex_pb.Response, err error) -} - -// NewClient creates a client for the service defined in IDL. -func NewClient(destService string, opts ...client.Option) (Client, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - - options = append(options, opts...) - - kc, err := client.NewClient(serviceInfo(), options...) - if err != nil { - return nil, err - } - return &kPBServiceClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. -func MustNewClient(destService string, opts ...client.Option) Client { - kc, err := NewClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kPBServiceClient struct { - *kClient -} - -func (p *kPBServiceClient) EchoPingPong(ctx context.Context, Req *kitex_pb.Request, callOptions ...callopt.Option) (r *kitex_pb.Response, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.EchoPingPong(ctx, Req) -} diff --git a/thrift_streaming/kitex_gen/kitex_pb/pbservice/invoker.go b/thrift_streaming/kitex_gen/kitex_pb/pbservice/invoker.go deleted file mode 100644 index 159bb61..0000000 --- a/thrift_streaming/kitex_gen/kitex_pb/pbservice/invoker.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package pbservice - -import ( - kitex_pb "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/kitex_pb" - server "github.com/cloudwego/kitex/server" -) - -// NewInvoker creates a server.Invoker with the given handler and options. -func NewInvoker(handler kitex_pb.PBService, opts ...server.Option) server.Invoker { - var options []server.Option - - options = append(options, opts...) - - s := server.NewInvoker(options...) - if err := s.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - if err := s.Init(); err != nil { - panic(err) - } - return s -} diff --git a/thrift_streaming/kitex_gen/kitex_pb/pbservice/pbservice.go b/thrift_streaming/kitex_gen/kitex_pb/pbservice/pbservice.go deleted file mode 100644 index 618851e..0000000 --- a/thrift_streaming/kitex_gen/kitex_pb/pbservice/pbservice.go +++ /dev/null @@ -1,262 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. - -package pbservice - -import ( - "context" - "errors" - kitex_pb "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/kitex_pb" - client "github.com/cloudwego/kitex/client" - kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" - proto "google.golang.org/protobuf/proto" -) - -var errInvalidMessageType = errors.New("invalid message type for service method handler") - -var serviceMethods = map[string]kitex.MethodInfo{ - "EchoPingPong": kitex.NewMethodInfo( - echoPingPongHandler, - newEchoPingPongArgs, - newEchoPingPongResult, - false, - kitex.WithStreamingMode(kitex.StreamingUnary), - ), -} - -var ( - pBServiceServiceInfo = NewServiceInfo() - pBServiceServiceInfoForClient = NewServiceInfoForClient() - pBServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() -) - -// for server -func serviceInfo() *kitex.ServiceInfo { - return pBServiceServiceInfo -} - -// for client -func serviceInfoForStreamClient() *kitex.ServiceInfo { - return pBServiceServiceInfoForStreamClient -} - -// for stream client -func serviceInfoForClient() *kitex.ServiceInfo { - return pBServiceServiceInfoForClient -} - -// NewServiceInfo creates a new ServiceInfo containing all methods -func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(false, true, true) -} - -// NewServiceInfo creates a new ServiceInfo containing non-streaming methods -func NewServiceInfoForClient() *kitex.ServiceInfo { - return newServiceInfo(false, false, true) -} -func NewServiceInfoForStreamClient() *kitex.ServiceInfo { - return newServiceInfo(true, true, false) -} - -func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { - serviceName := "PBService" - handlerType := (*kitex_pb.PBService)(nil) - methods := map[string]kitex.MethodInfo{} - for name, m := range serviceMethods { - if m.IsStreaming() && !keepStreamingMethods { - continue - } - if !m.IsStreaming() && !keepNonStreamingMethods { - continue - } - methods[name] = m - } - extra := map[string]interface{}{ - "PackageName": "kitex_pb", - } - if hasStreaming { - extra["streaming"] = hasStreaming - } - svcInfo := &kitex.ServiceInfo{ - ServiceName: serviceName, - HandlerType: handlerType, - Methods: methods, - PayloadCodec: kitex.Protobuf, - KiteXGenVersion: "v0.8.0", - Extra: extra, - } - return svcInfo -} - -func echoPingPongHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(kitex_pb.Request) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(kitex_pb.PBService).EchoPingPong(ctx, req) - if err != nil { - return err - } - return st.SendMsg(resp) - case *EchoPingPongArgs: - success, err := handler.(kitex_pb.PBService).EchoPingPong(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*EchoPingPongResult) - realResult.Success = success - return nil - default: - return errInvalidMessageType - } -} -func newEchoPingPongArgs() interface{} { - return &EchoPingPongArgs{} -} - -func newEchoPingPongResult() interface{} { - return &EchoPingPongResult{} -} - -type EchoPingPongArgs struct { - Req *kitex_pb.Request -} - -func (p *EchoPingPongArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(kitex_pb.Request) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *EchoPingPongArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *EchoPingPongArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *EchoPingPongArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, nil - } - return proto.Marshal(p.Req) -} - -func (p *EchoPingPongArgs) Unmarshal(in []byte) error { - msg := new(kitex_pb.Request) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var EchoPingPongArgs_Req_DEFAULT *kitex_pb.Request - -func (p *EchoPingPongArgs) GetReq() *kitex_pb.Request { - if !p.IsSetReq() { - return EchoPingPongArgs_Req_DEFAULT - } - return p.Req -} - -func (p *EchoPingPongArgs) IsSetReq() bool { - return p.Req != nil -} - -func (p *EchoPingPongArgs) GetFirstArgument() interface{} { - return p.Req -} - -type EchoPingPongResult struct { - Success *kitex_pb.Response -} - -var EchoPingPongResult_Success_DEFAULT *kitex_pb.Response - -func (p *EchoPingPongResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(kitex_pb.Response) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *EchoPingPongResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *EchoPingPongResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *EchoPingPongResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, nil - } - return proto.Marshal(p.Success) -} - -func (p *EchoPingPongResult) Unmarshal(in []byte) error { - msg := new(kitex_pb.Response) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *EchoPingPongResult) GetSuccess() *kitex_pb.Response { - if !p.IsSetSuccess() { - return EchoPingPongResult_Success_DEFAULT - } - return p.Success -} - -func (p *EchoPingPongResult) SetSuccess(x interface{}) { - p.Success = x.(*kitex_pb.Response) -} - -func (p *EchoPingPongResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *EchoPingPongResult) GetResult() interface{} { - return p.Success -} - -type kClient struct { - c client.Client -} - -func newServiceClient(c client.Client) *kClient { - return &kClient{ - c: c, - } -} - -func (p *kClient) EchoPingPong(ctx context.Context, Req *kitex_pb.Request) (r *kitex_pb.Response, err error) { - var _args EchoPingPongArgs - _args.Req = Req - var _result EchoPingPongResult - if err = p.c.Call(ctx, "EchoPingPong", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} diff --git a/thrift_streaming/kitex_gen/kitex_pb/pbservice/server.go b/thrift_streaming/kitex_gen/kitex_pb/pbservice/server.go deleted file mode 100644 index 5bf8bae..0000000 --- a/thrift_streaming/kitex_gen/kitex_pb/pbservice/server.go +++ /dev/null @@ -1,20 +0,0 @@ -// Code generated by Kitex v0.8.0. DO NOT EDIT. -package pbservice - -import ( - kitex_pb "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/kitex_pb" - server "github.com/cloudwego/kitex/server" -) - -// NewServer creates a server.Server with the given handler and options. -func NewServer(handler kitex_pb.PBService, opts ...server.Option) server.Server { - var options []server.Option - - options = append(options, opts...) - - svr := server.NewServer(options...) - if err := svr.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - return svr -} diff --git a/thrift_streaming/kitex_gen_slim/combine/b/client.go b/thrift_streaming/kitex_gen_slim/combine/b/client.go index 14535a0..eda7a6a 100644 --- a/thrift_streaming/kitex_gen_slim/combine/b/client.go +++ b/thrift_streaming/kitex_gen_slim/combine/b/client.go @@ -6,6 +6,7 @@ import ( "context" combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/combine" client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" "github.com/cloudwego/kitex/client/callopt/streamcall" "github.com/cloudwego/kitex/client/streamclient" streaming "github.com/cloudwego/kitex/pkg/streaming" diff --git a/thrift_streaming/kitex_gen_slim/combine/combineservice/client.go b/thrift_streaming/kitex_gen_slim/combine/combineservice/client.go index e4d3722..26a15be 100644 --- a/thrift_streaming/kitex_gen_slim/combine/combineservice/client.go +++ b/thrift_streaming/kitex_gen_slim/combine/combineservice/client.go @@ -7,10 +7,6 @@ import ( combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/combine" client "github.com/cloudwego/kitex/client" callopt "github.com/cloudwego/kitex/client/callopt" - "github.com/cloudwego/kitex/client/callopt/streamcall" - "github.com/cloudwego/kitex/client/streamclient" - streaming "github.com/cloudwego/kitex/pkg/streaming" - transport "github.com/cloudwego/kitex/transport" ) // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. @@ -18,11 +14,6 @@ type Client interface { Foo(ctx context.Context, req *combine.Req, callOptions ...callopt.Option) (r *combine.Rsp, err error) } -// StreamClient is designed to provide Interface for Streaming APIs. -type StreamClient interface { - Bar(ctx context.Context, callOptions ...streamcall.Option) (stream B_BarClient, err error) -} - type B_BarClient interface { streaming.Stream Send(*combine.Req) error @@ -62,38 +53,3 @@ func (p *kCombineServiceClient) Foo(ctx context.Context, req *combine.Req, callO ctx = client.NewCtxWithCallOptions(ctx, callOptions) return p.kClient.Foo(ctx, req) } - -// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - options = append(options, client.WithTransportProtocol(transport.GRPC)) - options = append(options, streamclient.GetClientOptions(opts)...) - - kc, err := client.NewClient(serviceInfoForStreamClient(), options...) - if err != nil { - return nil, err - } - return &kCombineServiceStreamClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -// It panics if any error occurs. -func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { - kc, err := NewStreamClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kCombineServiceStreamClient struct { - *kClient -} - -func (p *kCombineServiceStreamClient) Bar(ctx context.Context, callOptions ...streamcall.Option) (stream B_BarClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.Bar(ctx) -} diff --git a/thrift_streaming/kitex_gen_slim/combine/combineservice/combineservice.go b/thrift_streaming/kitex_gen_slim/combine/combineservice/combineservice.go index 42222e0..fbe6eb9 100644 --- a/thrift_streaming/kitex_gen_slim/combine/combineservice/combineservice.go +++ b/thrift_streaming/kitex_gen_slim/combine/combineservice/combineservice.go @@ -59,7 +59,7 @@ func serviceInfoForClient() *kitex.ServiceInfo { // NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(true, true, true) + return newServiceInfo(false, true, true) } // NewServiceInfo creates a new ServiceInfo containing non-streaming methods diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/b/b.go b/thrift_streaming/kitex_gen_slim/combine_extend/b/b.go index a06b21d..f12fba6 100644 --- a/thrift_streaming/kitex_gen_slim/combine_extend/b/b.go +++ b/thrift_streaming/kitex_gen_slim/combine_extend/b/b.go @@ -48,7 +48,7 @@ func serviceInfoForClient() *kitex.ServiceInfo { // NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(true, true, true) + return newServiceInfo(false, true, true) } // NewServiceInfo creates a new ServiceInfo containing non-streaming methods diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/b/client.go b/thrift_streaming/kitex_gen_slim/combine_extend/b/client.go index 4ebfd2f..2892924 100644 --- a/thrift_streaming/kitex_gen_slim/combine_extend/b/client.go +++ b/thrift_streaming/kitex_gen_slim/combine_extend/b/client.go @@ -6,21 +6,13 @@ import ( "context" echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" client "github.com/cloudwego/kitex/client" - "github.com/cloudwego/kitex/client/callopt/streamcall" - "github.com/cloudwego/kitex/client/streamclient" - streaming "github.com/cloudwego/kitex/pkg/streaming" - transport "github.com/cloudwego/kitex/transport" + callopt "github.com/cloudwego/kitex/client/callopt" ) // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. type Client interface { } -// StreamClient is designed to provide Interface for Streaming APIs. -type StreamClient interface { - EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) -} - type StreamOnlyService_EchoBidirectionalNewClient interface { streaming.Stream Send(*echo.EchoRequest) error @@ -55,38 +47,3 @@ func MustNewClient(destService string, opts ...client.Option) Client { type kBClient struct { *kClient } - -// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - options = append(options, client.WithTransportProtocol(transport.GRPC)) - options = append(options, streamclient.GetClientOptions(opts)...) - - kc, err := client.NewClient(serviceInfoForStreamClient(), options...) - if err != nil { - return nil, err - } - return &kBStreamClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -// It panics if any error occurs. -func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { - kc, err := NewStreamClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kBStreamClient struct { - *kClient -} - -func (p *kBStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.EchoBidirectionalNew(ctx) -} diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/client.go b/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/client.go index c297e43..1b4be59 100644 --- a/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/client.go +++ b/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/client.go @@ -7,10 +7,6 @@ import ( echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" client "github.com/cloudwego/kitex/client" callopt "github.com/cloudwego/kitex/client/callopt" - "github.com/cloudwego/kitex/client/callopt/streamcall" - "github.com/cloudwego/kitex/client/streamclient" - streaming "github.com/cloudwego/kitex/pkg/streaming" - transport "github.com/cloudwego/kitex/transport" ) // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. @@ -18,11 +14,6 @@ type Client interface { EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) } -// StreamClient is designed to provide Interface for Streaming APIs. -type StreamClient interface { - EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) -} - type StreamOnlyService_EchoBidirectionalNewClient interface { streaming.Stream Send(*echo.EchoRequest) error @@ -62,38 +53,3 @@ func (p *kCombineServiceClient) EchoPingPongNew(ctx context.Context, req1 *echo. ctx = client.NewCtxWithCallOptions(ctx, callOptions) return p.kClient.EchoPingPongNew(ctx, req1) } - -// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - options = append(options, client.WithTransportProtocol(transport.GRPC)) - options = append(options, streamclient.GetClientOptions(opts)...) - - kc, err := client.NewClient(serviceInfoForStreamClient(), options...) - if err != nil { - return nil, err - } - return &kCombineServiceStreamClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -// It panics if any error occurs. -func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { - kc, err := NewStreamClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kCombineServiceStreamClient struct { - *kClient -} - -func (p *kCombineServiceStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.EchoBidirectionalNew(ctx) -} diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/combineservice.go b/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/combineservice.go index 9a1ef94..e95b6ad 100644 --- a/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/combineservice.go +++ b/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/combineservice.go @@ -60,7 +60,7 @@ func serviceInfoForClient() *kitex.ServiceInfo { // NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(true, true, true) + return newServiceInfo(false, true, true) } // NewServiceInfo creates a new ServiceInfo containing non-streaming methods diff --git a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/client.go b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/client.go index 95c27e7..e1ad4c7 100644 --- a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/client.go +++ b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/client.go @@ -7,10 +7,6 @@ import ( echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" client "github.com/cloudwego/kitex/client" callopt "github.com/cloudwego/kitex/client/callopt" - "github.com/cloudwego/kitex/client/callopt/streamcall" - "github.com/cloudwego/kitex/client/streamclient" - streaming "github.com/cloudwego/kitex/pkg/streaming" - transport "github.com/cloudwego/kitex/transport" ) // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. @@ -18,11 +14,6 @@ type Client interface { EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) } -// StreamClient is designed to provide Interface for Streaming APIs. -type StreamClient interface { - EchoBidirectionalExtended(ctx context.Context, callOptions ...streamcall.Option) (stream PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, err error) -} - type PingPongOnlyServiceChild_EchoBidirectionalExtendedClient interface { streaming.Stream Send(*echo.EchoRequest) error @@ -62,38 +53,3 @@ func (p *kPingPongOnlyServiceChildChildClient) EchoPingPongNew(ctx context.Conte ctx = client.NewCtxWithCallOptions(ctx, callOptions) return p.kClient.EchoPingPongNew(ctx, req1) } - -// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - options = append(options, client.WithTransportProtocol(transport.GRPC)) - options = append(options, streamclient.GetClientOptions(opts)...) - - kc, err := client.NewClient(serviceInfoForStreamClient(), options...) - if err != nil { - return nil, err - } - return &kPingPongOnlyServiceChildChildStreamClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -// It panics if any error occurs. -func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { - kc, err := NewStreamClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kPingPongOnlyServiceChildChildStreamClient struct { - *kClient -} - -func (p *kPingPongOnlyServiceChildChildStreamClient) EchoBidirectionalExtended(ctx context.Context, callOptions ...streamcall.Option) (stream PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.EchoBidirectionalExtended(ctx) -} diff --git a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go index 927e9f3..6c40880 100644 --- a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go +++ b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go @@ -54,7 +54,7 @@ func serviceInfoForClient() *kitex.ServiceInfo { // NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(true, true, true) + return newServiceInfo(false, true, true) } // NewServiceInfo creates a new ServiceInfo containing non-streaming methods diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/client.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/client.go index 5f46814..0da7823 100644 --- a/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/client.go +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/client.go @@ -6,6 +6,7 @@ import ( "context" echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" "github.com/cloudwego/kitex/client/callopt/streamcall" "github.com/cloudwego/kitex/client/streamclient" streaming "github.com/cloudwego/kitex/pkg/streaming" diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/client.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/client.go index 6264905..7eb0f10 100644 --- a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/client.go +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/client.go @@ -6,21 +6,13 @@ import ( "context" echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" client "github.com/cloudwego/kitex/client" - "github.com/cloudwego/kitex/client/callopt/streamcall" - "github.com/cloudwego/kitex/client/streamclient" - streaming "github.com/cloudwego/kitex/pkg/streaming" - transport "github.com/cloudwego/kitex/transport" + callopt "github.com/cloudwego/kitex/client/callopt" ) // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. type Client interface { } -// StreamClient is designed to provide Interface for Streaming APIs. -type StreamClient interface { - EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) -} - type StreamOnlyService_EchoBidirectionalNewClient interface { streaming.Stream Send(*echo.EchoRequest) error @@ -55,38 +47,3 @@ func MustNewClient(destService string, opts ...client.Option) Client { type kStreamOnlyServiceChildClient struct { *kClient } - -// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - options = append(options, client.WithTransportProtocol(transport.GRPC)) - options = append(options, streamclient.GetClientOptions(opts)...) - - kc, err := client.NewClient(serviceInfoForStreamClient(), options...) - if err != nil { - return nil, err - } - return &kStreamOnlyServiceChildStreamClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -// It panics if any error occurs. -func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { - kc, err := NewStreamClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kStreamOnlyServiceChildStreamClient struct { - *kClient -} - -func (p *kStreamOnlyServiceChildStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.EchoBidirectionalNew(ctx) -} diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/streamonlyservicechild.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/streamonlyservicechild.go index ef1d65e..dfdec1d 100644 --- a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/streamonlyservicechild.go +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/streamonlyservicechild.go @@ -47,7 +47,7 @@ func serviceInfoForClient() *kitex.ServiceInfo { // NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(true, true, true) + return newServiceInfo(false, true, true) } // NewServiceInfo creates a new ServiceInfo containing non-streaming methods diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/client.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/client.go index bfd6bbc..e0567ba 100644 --- a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/client.go +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/client.go @@ -6,21 +6,13 @@ import ( "context" echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" client "github.com/cloudwego/kitex/client" - "github.com/cloudwego/kitex/client/callopt/streamcall" - "github.com/cloudwego/kitex/client/streamclient" - streaming "github.com/cloudwego/kitex/pkg/streaming" - transport "github.com/cloudwego/kitex/transport" + callopt "github.com/cloudwego/kitex/client/callopt" ) // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. type Client interface { } -// StreamClient is designed to provide Interface for Streaming APIs. -type StreamClient interface { - EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) -} - type StreamOnlyService_EchoBidirectionalNewClient interface { streaming.Stream Send(*echo.EchoRequest) error @@ -55,38 +47,3 @@ func MustNewClient(destService string, opts ...client.Option) Client { type kStreamOnlyServiceChildChildClient struct { *kClient } - -// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - options = append(options, client.WithTransportProtocol(transport.GRPC)) - options = append(options, streamclient.GetClientOptions(opts)...) - - kc, err := client.NewClient(serviceInfoForStreamClient(), options...) - if err != nil { - return nil, err - } - return &kStreamOnlyServiceChildChildStreamClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. -// It panics if any error occurs. -func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { - kc, err := NewStreamClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kStreamOnlyServiceChildChildStreamClient struct { - *kClient -} - -func (p *kStreamOnlyServiceChildChildStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { - ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) - return p.kClient.EchoBidirectionalNew(ctx) -} diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/streamonlyservicechildchild.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/streamonlyservicechildchild.go index fffaaa8..0b9939a 100644 --- a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/streamonlyservicechildchild.go +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/streamonlyservicechildchild.go @@ -47,7 +47,7 @@ func serviceInfoForClient() *kitex.ServiceInfo { // NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(true, true, true) + return newServiceInfo(false, true, true) } // NewServiceInfo creates a new ServiceInfo containing non-streaming methods diff --git a/thrift_streaming/main_test.go b/thrift_streaming/main_test.go index 5c5e7c0..17ce09b 100644 --- a/thrift_streaming/main_test.go +++ b/thrift_streaming/main_test.go @@ -21,6 +21,7 @@ import ( "testing" "time" + "github.com/cloudwego/kitex-tests/common" "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine/combineservice" "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo/echoservice" @@ -30,7 +31,6 @@ import ( kitexpbservice "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/kitex_pb/pbservice" cross_echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" cross_echoservice "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo/echoservice" - "github.com/cloudwego/kitex/pkg/klog" "github.com/cloudwego/kitex/server" ) @@ -42,16 +42,6 @@ func WithServerAddr(hostPort string) server.Option { return server.WithServiceAddr(addr) } -func WaitServer(hostPort string) { - for begin := time.Now(); time.Since(begin) < time.Second; { - if _, err := net.Dial("tcp", hostPort); err == nil { - klog.Infof("server %s is up", hostPort) - return - } - time.Sleep(time.Millisecond * 10) - } -} - func RunThriftServer(handler echo.EchoService, addr string, opts ...server.Option) server.Server { opts = append(opts, WithServerAddr(addr)) opts = append(opts, server.WithExitWaitTime(time.Millisecond*10)) @@ -61,7 +51,7 @@ func RunThriftServer(handler echo.EchoService, addr string, opts ...server.Optio panic(err) } }() - WaitServer(addr) + common.WaitServer(addr) return svr } @@ -74,7 +64,7 @@ func RunCombineThriftServer(handler combineservice.CombineService, addr string, panic(err) } }() - WaitServer(addr) + common.WaitServer(addr) return svr } @@ -87,7 +77,7 @@ func RunThriftCrossServer(handler cross_echo.EchoService, addr string, opts ...s panic(err) } }() - WaitServer(addr) + common.WaitServer(addr) return svr } @@ -100,7 +90,7 @@ func RunGRPCPBServer(handler grpc_pb.PBService, addr string, opts ...server.Opti panic(err) } }() - WaitServer(addr) + common.WaitServer(addr) return svr } @@ -113,7 +103,7 @@ func RunKitexPBServer(handler kitex_pb.PBService, addr string, opts ...server.Op panic(err) } }() - WaitServer(addr) + common.WaitServer(addr) return svr } @@ -149,11 +139,11 @@ func TestMain(m *testing.M) { go thriftCrossSvr.Stop() go combineServer.Stop() }() - WaitServer(thriftAddr) - WaitServer(crossAddr) - WaitServer(grpcAddr) - WaitServer(pbAddr) - WaitServer(slimAddr) - WaitServer(combineAddr) + common.WaitServer(thriftAddr) + common.WaitServer(crossAddr) + common.WaitServer(grpcAddr) + common.WaitServer(pbAddr) + common.WaitServer(slimAddr) + common.WaitServer(combineAddr) m.Run() } diff --git a/thrift_streaming/thrift_slim_amd64_test.go b/thrift_streaming/thrift_slim_amd64_test.go index 9f85a8f..866be66 100644 --- a/thrift_streaming/thrift_slim_amd64_test.go +++ b/thrift_streaming/thrift_slim_amd64_test.go @@ -35,6 +35,7 @@ import ( "github.com/cloudwego/kitex/server" "github.com/cloudwego/kitex/transport" + "github.com/cloudwego/kitex-tests/common" "github.com/cloudwego/kitex-tests/pkg/test" "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo/echoservice" @@ -52,7 +53,7 @@ func RunSlimThriftServer(handler echo.EchoService, addr string, opts ...server.O panic(err) } }() - WaitServer(addr) + common.WaitServer(addr) return svr } diff --git a/thrift_streaming/thrift_slim_others_test.go b/thrift_streaming/thrift_slim_others_test.go index 9fe18c6..7ff9247 100644 --- a/thrift_streaming/thrift_slim_others_test.go +++ b/thrift_streaming/thrift_slim_others_test.go @@ -1,5 +1,5 @@ -//go:build !amd64 && windows && !go1.16 && go1.22 && disablefrugal -// +build !amd64,windows,!go1.16,go1.22,disablefrugal +//go:build !amd64 || windows || !go1.16 || go1.22 || disablefrugal +// +build !amd64 windows !go1.16 go1.22 disablefrugal // Copyright 2023 CloudWeGo Authors // From c4d0ed71a3b49c81e2836fc0cccb13b260f5db76 Mon Sep 17 00:00:00 2001 From: Felix021 Date: Thu, 18 Jan 2024 11:49:41 +0800 Subject: [PATCH 6/7] test: streaming support including dot-separated thrift (#54) --- thrift_streaming/generate.sh | 4 +- thrift_streaming/idl/a.b.c.thrift | 23 + thrift_streaming/idl/api.thrift | 10 + thrift_streaming/kitex_gen/a/b/c/a.b.c.go | 333 + thrift_streaming/kitex_gen/a/b/c/k-a.b.c.go | 284 + thrift_streaming/kitex_gen/a/b/c/k-consts.go | 4 + thrift_streaming/kitex_gen/combine/a/a.go | 125 + .../kitex_gen/combine/a/client.go | 49 + .../kitex_gen/combine/a/invoker.go | 24 + .../kitex_gen/combine/a/server.go | 21 + thrift_streaming/kitex_gen/combine/b/b.go | 155 + .../kitex_gen/combine/b/client.go | 92 + .../kitex_gen/combine/b/invoker.go | 24 + .../kitex_gen/combine/b/server.go | 21 + thrift_streaming/kitex_gen/combine/combine.go | 1251 ++++ .../combine/combineservice/client.go | 99 + .../combine/combineservice/combineservice.go | 197 + .../combine/combineservice/invoker.go | 23 + .../combine/combineservice/server.go | 20 + .../kitex_gen/combine/k-combine.go | 832 +++ .../kitex_gen/combine/k-consts.go | 4 + .../kitex_gen/combine_extend/a/a.go | 126 + .../kitex_gen/combine_extend/a/client.go | 49 + .../kitex_gen/combine_extend/a/invoker.go | 24 + .../kitex_gen/combine_extend/a/server.go | 21 + .../kitex_gen/combine_extend/b/b.go | 156 + .../kitex_gen/combine_extend/b/client.go | 92 + .../kitex_gen/combine_extend/b/invoker.go | 24 + .../kitex_gen/combine_extend/b/server.go | 21 + .../combine_extend/combine_extend.go | 78 + .../combine_extend/combineservice/client.go | 99 + .../combineservice/combineservice.go | 198 + .../combine_extend/combineservice/invoker.go | 23 + .../combine_extend/combineservice/server.go | 20 + .../combine_extend/k-combine_extend.go | 27 + .../kitex_gen/combine_extend/k-consts.go | 4 + .../kitex_gen/echo/abcservice/abcservice.go | 362 + .../kitex_gen/echo/abcservice/client.go | 128 + .../kitex_gen/echo/abcservice/invoker.go | 24 + .../kitex_gen/echo/abcservice/server.go | 21 + thrift_streaming/kitex_gen/echo/api.go | 6506 +++++++++++++++++ .../kitex_gen/echo/echoservice/client.go | 140 + .../kitex_gen/echo/echoservice/echoservice.go | 440 ++ .../kitex_gen/echo/echoservice/invoker.go | 24 + .../kitex_gen/echo/echoservice/server.go | 21 + thrift_streaming/kitex_gen/echo/k-api.go | 4404 +++++++++++ thrift_streaming/kitex_gen/echo/k-consts.go | 4 + .../echo/pingpongonlyservice/client.go | 49 + .../echo/pingpongonlyservice/invoker.go | 24 + .../pingpongonlyservice.go | 125 + .../echo/pingpongonlyservice/server.go | 21 + .../echo/pingpongonlyservicechild/client.go | 99 + .../echo/pingpongonlyservicechild/invoker.go | 24 + .../pingpongonlyservicechild.go | 190 + .../echo/pingpongonlyservicechild/server.go | 21 + .../pingpongonlyservicechildchild/client.go | 99 + .../pingpongonlyservicechildchild/invoker.go | 24 + .../pingpongonlyservicechildchild.go | 190 + .../pingpongonlyservicechildchild/server.go | 21 + .../echo/streamonlyservice/client.go | 92 + .../echo/streamonlyservice/invoker.go | 24 + .../echo/streamonlyservice/server.go | 21 + .../streamonlyservice/streamonlyservice.go | 155 + .../echo/streamonlyservicechild/client.go | 92 + .../echo/streamonlyservicechild/invoker.go | 24 + .../echo/streamonlyservicechild/server.go | 21 + .../streamonlyservicechild.go | 155 + .../streamonlyservicechildchild/client.go | 92 + .../streamonlyservicechildchild/invoker.go | 24 + .../streamonlyservicechildchild/server.go | 21 + .../streamonlyservicechildchild.go | 155 + .../kitex_gen/grpc_pb/api.pb.fast.go | 135 + thrift_streaming/kitex_gen/grpc_pb/api.pb.go | 274 + .../kitex_gen/grpc_pb/pbservice/client.go | 142 + .../kitex_gen/grpc_pb/pbservice/invoker.go | 24 + .../kitex_gen/grpc_pb/pbservice/pbservice.go | 809 ++ .../kitex_gen/grpc_pb/pbservice/server.go | 20 + .../kitex_pb/api_no_stream.pb.fast.go | 135 + .../kitex_gen/kitex_pb/api_no_stream.pb.go | 238 + .../kitex_gen/kitex_pb/pbservice/client.go | 49 + .../kitex_gen/kitex_pb/pbservice/invoker.go | 24 + .../kitex_gen/kitex_pb/pbservice/pbservice.go | 262 + .../kitex_gen/kitex_pb/pbservice/server.go | 20 + .../kitex_gen_cross/a/b/c/a.b.c.go | 333 + .../kitex_gen_cross/a/b/c/k-a.b.c.go | 284 + .../kitex_gen_cross/a/b/c/k-consts.go | 4 + .../echo/abcservice/abcservice.go | 77 + .../kitex_gen_cross/echo/abcservice/client.go | 49 + .../echo/abcservice/invoker.go | 24 + .../kitex_gen_cross/echo/abcservice/server.go | 20 + thrift_streaming/kitex_gen_cross/echo/api.go | 537 +- .../kitex_gen_cross/echo/k-api.go | 314 + thrift_streaming/kitex_gen_old/a/b/c/a.b.c.go | 333 + .../kitex_gen_old/a/b/c/k-a.b.c.go | 284 + .../kitex_gen_old/a/b/c/k-consts.go | 4 + .../echo/abcservice/abcservice.go | 193 + .../kitex_gen_old/echo/abcservice/client.go | 73 + .../kitex_gen_old/echo/abcservice/invoker.go | 24 + .../kitex_gen_old/echo/abcservice/server.go | 20 + thrift_streaming/kitex_gen_old/echo/api.go | 2135 ++++++ thrift_streaming/kitex_gen_old/echo/k-api.go | 1468 +++- .../kitex_gen_slim/a/b/c/a.b.c.go | 59 + .../kitex_gen_slim/a/b/c/k-a.b.c.go | 21 + .../kitex_gen_slim/a/b/c/k-consts.go | 4 + .../kitex_gen_slim/combine/b/client.go | 1 - .../kitex_gen_slim/combine/combine.go | 2 +- .../combine/combineservice/client.go | 44 + .../combine/combineservice/combineservice.go | 2 +- .../kitex_gen_slim/combine_extend/b/b.go | 2 +- .../kitex_gen_slim/combine_extend/b/client.go | 45 +- .../combine_extend/combine_extend.go | 2 +- .../combine_extend/combineservice/client.go | 44 + .../combineservice/combineservice.go | 2 +- .../echo/abcservice/abcservice.go | 362 + .../kitex_gen_slim/echo/abcservice/client.go | 128 + .../kitex_gen_slim/echo/abcservice/invoker.go | 24 + .../kitex_gen_slim/echo/abcservice/server.go | 21 + thrift_streaming/kitex_gen_slim/echo/api.go | 35 +- thrift_streaming/kitex_gen_slim/echo/k-api.go | 400 + .../pingpongonlyservicechildchild/client.go | 44 + .../pingpongonlyservicechildchild.go | 2 +- .../echo/streamonlyservice/client.go | 1 - .../echo/streamonlyservicechild/client.go | 45 +- .../streamonlyservicechild.go | 2 +- .../streamonlyservicechildchild/client.go | 45 +- .../streamonlyservicechildchild.go | 2 +- thrift_streaming/main_test.go | 24 +- thrift_streaming/thrift_test.go | 99 + 128 files changed, 28097 insertions(+), 67 deletions(-) create mode 100644 thrift_streaming/idl/a.b.c.thrift create mode 100644 thrift_streaming/kitex_gen/a/b/c/a.b.c.go create mode 100644 thrift_streaming/kitex_gen/a/b/c/k-a.b.c.go create mode 100644 thrift_streaming/kitex_gen/a/b/c/k-consts.go create mode 100644 thrift_streaming/kitex_gen/combine/a/a.go create mode 100644 thrift_streaming/kitex_gen/combine/a/client.go create mode 100644 thrift_streaming/kitex_gen/combine/a/invoker.go create mode 100644 thrift_streaming/kitex_gen/combine/a/server.go create mode 100644 thrift_streaming/kitex_gen/combine/b/b.go create mode 100644 thrift_streaming/kitex_gen/combine/b/client.go create mode 100644 thrift_streaming/kitex_gen/combine/b/invoker.go create mode 100644 thrift_streaming/kitex_gen/combine/b/server.go create mode 100644 thrift_streaming/kitex_gen/combine/combine.go create mode 100644 thrift_streaming/kitex_gen/combine/combineservice/client.go create mode 100644 thrift_streaming/kitex_gen/combine/combineservice/combineservice.go create mode 100644 thrift_streaming/kitex_gen/combine/combineservice/invoker.go create mode 100644 thrift_streaming/kitex_gen/combine/combineservice/server.go create mode 100644 thrift_streaming/kitex_gen/combine/k-combine.go create mode 100644 thrift_streaming/kitex_gen/combine/k-consts.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/a/a.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/a/client.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/a/invoker.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/a/server.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/b/b.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/b/client.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/b/invoker.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/b/server.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/combine_extend.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/combineservice/client.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/combineservice/combineservice.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/combineservice/invoker.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/combineservice/server.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/k-combine_extend.go create mode 100644 thrift_streaming/kitex_gen/combine_extend/k-consts.go create mode 100644 thrift_streaming/kitex_gen/echo/abcservice/abcservice.go create mode 100644 thrift_streaming/kitex_gen/echo/abcservice/client.go create mode 100644 thrift_streaming/kitex_gen/echo/abcservice/invoker.go create mode 100644 thrift_streaming/kitex_gen/echo/abcservice/server.go create mode 100644 thrift_streaming/kitex_gen/echo/api.go create mode 100644 thrift_streaming/kitex_gen/echo/echoservice/client.go create mode 100644 thrift_streaming/kitex_gen/echo/echoservice/echoservice.go create mode 100644 thrift_streaming/kitex_gen/echo/echoservice/invoker.go create mode 100644 thrift_streaming/kitex_gen/echo/echoservice/server.go create mode 100644 thrift_streaming/kitex_gen/echo/k-api.go create mode 100644 thrift_streaming/kitex_gen/echo/k-consts.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservice/client.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservice/invoker.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservice/pingpongonlyservice.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservice/server.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/client.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/invoker.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/pingpongonlyservicechild.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/server.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/client.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/invoker.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go create mode 100644 thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/server.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservice/client.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservice/invoker.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservice/server.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservice/streamonlyservice.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechild/client.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechild/invoker.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechild/server.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechild/streamonlyservicechild.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/client.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/invoker.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/server.go create mode 100644 thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/streamonlyservicechildchild.go create mode 100644 thrift_streaming/kitex_gen/grpc_pb/api.pb.fast.go create mode 100644 thrift_streaming/kitex_gen/grpc_pb/api.pb.go create mode 100644 thrift_streaming/kitex_gen/grpc_pb/pbservice/client.go create mode 100644 thrift_streaming/kitex_gen/grpc_pb/pbservice/invoker.go create mode 100644 thrift_streaming/kitex_gen/grpc_pb/pbservice/pbservice.go create mode 100644 thrift_streaming/kitex_gen/grpc_pb/pbservice/server.go create mode 100644 thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.fast.go create mode 100644 thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.go create mode 100644 thrift_streaming/kitex_gen/kitex_pb/pbservice/client.go create mode 100644 thrift_streaming/kitex_gen/kitex_pb/pbservice/invoker.go create mode 100644 thrift_streaming/kitex_gen/kitex_pb/pbservice/pbservice.go create mode 100644 thrift_streaming/kitex_gen/kitex_pb/pbservice/server.go create mode 100644 thrift_streaming/kitex_gen_cross/a/b/c/a.b.c.go create mode 100644 thrift_streaming/kitex_gen_cross/a/b/c/k-a.b.c.go create mode 100644 thrift_streaming/kitex_gen_cross/a/b/c/k-consts.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/abcservice/abcservice.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/abcservice/client.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/abcservice/invoker.go create mode 100644 thrift_streaming/kitex_gen_cross/echo/abcservice/server.go create mode 100644 thrift_streaming/kitex_gen_old/a/b/c/a.b.c.go create mode 100644 thrift_streaming/kitex_gen_old/a/b/c/k-a.b.c.go create mode 100644 thrift_streaming/kitex_gen_old/a/b/c/k-consts.go create mode 100644 thrift_streaming/kitex_gen_old/echo/abcservice/abcservice.go create mode 100644 thrift_streaming/kitex_gen_old/echo/abcservice/client.go create mode 100644 thrift_streaming/kitex_gen_old/echo/abcservice/invoker.go create mode 100644 thrift_streaming/kitex_gen_old/echo/abcservice/server.go create mode 100644 thrift_streaming/kitex_gen_slim/a/b/c/a.b.c.go create mode 100644 thrift_streaming/kitex_gen_slim/a/b/c/k-a.b.c.go create mode 100644 thrift_streaming/kitex_gen_slim/a/b/c/k-consts.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/abcservice/abcservice.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/abcservice/client.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/abcservice/invoker.go create mode 100644 thrift_streaming/kitex_gen_slim/echo/abcservice/server.go diff --git a/thrift_streaming/generate.sh b/thrift_streaming/generate.sh index 427bcdc..9f9e484 100755 --- a/thrift_streaming/generate.sh +++ b/thrift_streaming/generate.sh @@ -73,7 +73,9 @@ function generate_new() { else GOBIN=$dir go install github.com/cloudwego/kitex/tool/cmd/kitex@develop fi - GOBIN=$dir go install github.com/cloudwego/thriftgo@latest + if [ ! -f "$dir/thriftgo" ]; then + GOBIN=$dir go install github.com/cloudwego/thriftgo@latest + fi if [ ! -f "$dir/kitex" -o ! -f "$dir/thriftgo" ]; then echo "[new] Unable to install kitex or thriftgo to $dir, please check before continue." diff --git a/thrift_streaming/idl/a.b.c.thrift b/thrift_streaming/idl/a.b.c.thrift new file mode 100644 index 0000000..f032808 --- /dev/null +++ b/thrift_streaming/idl/a.b.c.thrift @@ -0,0 +1,23 @@ +// Copyright 2024 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace go a.b.c + +struct Request { + 1: string message, +} + +struct Response { + 1: string message, +} \ No newline at end of file diff --git a/thrift_streaming/idl/api.thrift b/thrift_streaming/idl/api.thrift index 47959d7..874740c 100644 --- a/thrift_streaming/idl/api.thrift +++ b/thrift_streaming/idl/api.thrift @@ -14,6 +14,8 @@ namespace go echo +include "a.b.c.thrift" + struct EchoRequest { 1: required string message, } @@ -63,3 +65,11 @@ service StreamOnlyServiceChild extends StreamOnlyService {} // should also be a streaming service service StreamOnlyServiceChildChild extends StreamOnlyServiceChild {} + +service ABCService { + a.b.c.Response Echo(1: a.b.c.Request req1, 2: a.b.c.Request req2), + a.b.c.Response EchoBidirectional(1: a.b.c.Request req1) (streaming.mode="bidirectional"), + a.b.c.Response EchoServer(1: a.b.c.Request req1) (streaming.mode="server"), + a.b.c.Response EchoClient(1: a.b.c.Request req1) (streaming.mode="client"), + a.b.c.Response EchoUnary(1: a.b.c.Request req1) (streaming.mode="unary"), +} \ No newline at end of file diff --git a/thrift_streaming/kitex_gen/a/b/c/a.b.c.go b/thrift_streaming/kitex_gen/a/b/c/a.b.c.go new file mode 100644 index 0000000..ea7a08e --- /dev/null +++ b/thrift_streaming/kitex_gen/a/b/c/a.b.c.go @@ -0,0 +1,333 @@ +// Code generated by thriftgo (0.3.6). DO NOT EDIT. + +package c + +import ( + "fmt" + "github.com/apache/thrift/lib/go/thrift" + "strings" +) + +type Request struct { + Message string `thrift:"message,1" frugal:"1,default,string" json:"message"` +} + +func NewRequest() *Request { + return &Request{} +} + +func (p *Request) InitDefault() { + *p = Request{} +} + +func (p *Request) GetMessage() (v string) { + return p.Message +} +func (p *Request) SetMessage(val string) { + p.Message = val +} + +var fieldIDToName_Request = map[int16]string{ + 1: "message", +} + +func (p *Request) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Request[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *Request) ReadField1(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadString(); err != nil { + return err + } else { + p.Message = v + } + return nil +} + +func (p *Request) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Request"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *Request) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Message); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *Request) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Request(%+v)", *p) + +} + +func (p *Request) DeepEqual(ano *Request) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Message) { + return false + } + return true +} + +func (p *Request) Field1DeepEqual(src string) bool { + + if strings.Compare(p.Message, src) != 0 { + return false + } + return true +} + +type Response struct { + Message string `thrift:"message,1" frugal:"1,default,string" json:"message"` +} + +func NewResponse() *Response { + return &Response{} +} + +func (p *Response) InitDefault() { + *p = Response{} +} + +func (p *Response) GetMessage() (v string) { + return p.Message +} +func (p *Response) SetMessage(val string) { + p.Message = val +} + +var fieldIDToName_Response = map[int16]string{ + 1: "message", +} + +func (p *Response) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Response[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *Response) ReadField1(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadString(); err != nil { + return err + } else { + p.Message = v + } + return nil +} + +func (p *Response) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Response"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *Response) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Message); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *Response) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Response(%+v)", *p) + +} + +func (p *Response) DeepEqual(ano *Response) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Message) { + return false + } + return true +} + +func (p *Response) Field1DeepEqual(src string) bool { + + if strings.Compare(p.Message, src) != 0 { + return false + } + return true +} diff --git a/thrift_streaming/kitex_gen/a/b/c/k-a.b.c.go b/thrift_streaming/kitex_gen/a/b/c/k-a.b.c.go new file mode 100644 index 0000000..b66b2ca --- /dev/null +++ b/thrift_streaming/kitex_gen/a/b/c/k-a.b.c.go @@ -0,0 +1,284 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package c + +import ( + "bytes" + "fmt" + "reflect" + "strings" + + "github.com/apache/thrift/lib/go/thrift" + + "github.com/cloudwego/kitex/pkg/protocol/bthrift" +) + +// unused protection +var ( + _ = fmt.Formatter(nil) + _ = (*bytes.Buffer)(nil) + _ = (*strings.Builder)(nil) + _ = reflect.Type(nil) + _ = thrift.TProtocol(nil) + _ = bthrift.BinaryWriter(nil) +) + +func (p *Request) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Request[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *Request) FastReadField1(buf []byte) (int, error) { + offset := 0 + + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.Message = v + + } + return offset, nil +} + +// for compatibility +func (p *Request) FastWrite(buf []byte) int { + return 0 +} + +func (p *Request) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Request") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *Request) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Request") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *Request) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) + + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Request) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) + l += bthrift.Binary.StringLengthNocopy(p.Message) + + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Response) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Response[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *Response) FastReadField1(buf []byte) (int, error) { + offset := 0 + + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.Message = v + + } + return offset, nil +} + +// for compatibility +func (p *Response) FastWrite(buf []byte) int { + return 0 +} + +func (p *Response) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Response") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *Response) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Response") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *Response) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) + + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Response) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) + l += bthrift.Binary.StringLengthNocopy(p.Message) + + l += bthrift.Binary.FieldEndLength() + return l +} diff --git a/thrift_streaming/kitex_gen/a/b/c/k-consts.go b/thrift_streaming/kitex_gen/a/b/c/k-consts.go new file mode 100644 index 0000000..2fdbc7e --- /dev/null +++ b/thrift_streaming/kitex_gen/a/b/c/k-consts.go @@ -0,0 +1,4 @@ +package c + +// KitexUnusedProtection is used to prevent 'imported and not used' error. +var KitexUnusedProtection = struct{}{} diff --git a/thrift_streaming/kitex_gen/combine/a/a.go b/thrift_streaming/kitex_gen/combine/a/a.go new file mode 100644 index 0000000..aac12d5 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/a/a.go @@ -0,0 +1,125 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package a + +import ( + "context" + "errors" + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "Foo": kitex.NewMethodInfo( + fooHandler, + newAFooArgs, + newAFooResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), +} + +var ( + aServiceInfo = NewServiceInfo() + aServiceInfoForClient = NewServiceInfoForClient() + aServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return aServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return aServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return aServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "A" + handlerType := (*combine.A)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "combine", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func fooHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*combine.AFooArgs) + realResult := result.(*combine.AFooResult) + success, err := handler.(combine.A).Foo(ctx, realArg.Req) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newAFooArgs() interface{} { + return combine.NewAFooArgs() +} + +func newAFooResult() interface{} { + return combine.NewAFooResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) Foo(ctx context.Context, req *combine.Req) (r *combine.Rsp, err error) { + var _args combine.AFooArgs + _args.Req = req + var _result combine.AFooResult + if err = p.c.Call(ctx, "Foo", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen/combine/a/client.go b/thrift_streaming/kitex_gen/combine/a/client.go new file mode 100644 index 0000000..dd7a1c2 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/a/client.go @@ -0,0 +1,49 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package a + +import ( + "context" + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + Foo(ctx context.Context, req *combine.Req, callOptions ...callopt.Option) (r *combine.Rsp, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kAClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kAClient struct { + *kClient +} + +func (p *kAClient) Foo(ctx context.Context, req *combine.Req, callOptions ...callopt.Option) (r *combine.Rsp, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.Foo(ctx, req) +} diff --git a/thrift_streaming/kitex_gen/combine/a/invoker.go b/thrift_streaming/kitex_gen/combine/a/invoker.go new file mode 100644 index 0000000..72c632c --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/a/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package a + +import ( + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler combine.A, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/combine/a/server.go b/thrift_streaming/kitex_gen/combine/a/server.go new file mode 100644 index 0000000..6b6a2d7 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/a/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package a + +import ( + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler combine.A, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/combine/b/b.go b/thrift_streaming/kitex_gen/combine/b/b.go new file mode 100644 index 0000000..75ea7e1 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/b/b.go @@ -0,0 +1,155 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package b + +import ( + "context" + "errors" + "fmt" + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "Bar": kitex.NewMethodInfo( + barHandler, + newBBarArgs, + newBBarResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + bServiceInfo = NewServiceInfo() + bServiceInfoForClient = NewServiceInfoForClient() + bServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return bServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return bServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return bServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "B" + handlerType := (*combine.B)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "combine", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func barHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("B.Bar is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &bBarServer{st.Stream} + return handler.(combine.B).Bar(stream) +} + +type bBarClient struct { + streaming.Stream +} + +func (x *bBarClient) Send(m *combine.Req) error { + return x.Stream.SendMsg(m) +} +func (x *bBarClient) Recv() (*combine.Rsp, error) { + m := new(combine.Rsp) + return m, x.Stream.RecvMsg(m) +} + +type bBarServer struct { + streaming.Stream +} + +func (x *bBarServer) Send(m *combine.Rsp) error { + return x.Stream.SendMsg(m) +} + +func (x *bBarServer) Recv() (*combine.Req, error) { + m := new(combine.Req) + return m, x.Stream.RecvMsg(m) +} + +func newBBarArgs() interface{} { + return combine.NewBBarArgs() +} + +func newBBarResult() interface{} { + return combine.NewBBarResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) Bar(ctx context.Context) (B_BarClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "Bar", nil, res) + if err != nil { + return nil, err + } + stream := &bBarClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen/combine/b/client.go b/thrift_streaming/kitex_gen/combine/b/client.go new file mode 100644 index 0000000..828cecf --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/b/client.go @@ -0,0 +1,92 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package b + +import ( + "context" + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + client "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + Bar(ctx context.Context, callOptions ...streamcall.Option) (stream B_BarClient, err error) +} + +type B_BarClient interface { + streaming.Stream + Send(*combine.Req) error + Recv() (*combine.Rsp, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kBClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kBClient struct { + *kClient +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kBStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kBStreamClient struct { + *kClient +} + +func (p *kBStreamClient) Bar(ctx context.Context, callOptions ...streamcall.Option) (stream B_BarClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.Bar(ctx) +} diff --git a/thrift_streaming/kitex_gen/combine/b/invoker.go b/thrift_streaming/kitex_gen/combine/b/invoker.go new file mode 100644 index 0000000..2a1760f --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/b/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package b + +import ( + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler combine.B, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/combine/b/server.go b/thrift_streaming/kitex_gen/combine/b/server.go new file mode 100644 index 0000000..0987a70 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/b/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package b + +import ( + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler combine.B, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/combine/combine.go b/thrift_streaming/kitex_gen/combine/combine.go new file mode 100644 index 0000000..e9d9a0c --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/combine.go @@ -0,0 +1,1251 @@ +// Code generated by thriftgo (0.3.6). DO NOT EDIT. + +package combine + +import ( + "context" + "fmt" + "github.com/apache/thrift/lib/go/thrift" + "github.com/cloudwego/kitex/pkg/streaming" + "strings" +) + +type Req struct { + Message string `thrift:"message,1,required" frugal:"1,required,string" json:"message"` +} + +func NewReq() *Req { + return &Req{} +} + +func (p *Req) InitDefault() { + *p = Req{} +} + +func (p *Req) GetMessage() (v string) { + return p.Message +} +func (p *Req) SetMessage(val string) { + p.Message = val +} + +var fieldIDToName_Req = map[int16]string{ + 1: "message", +} + +func (p *Req) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + var issetMessage bool = false + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + issetMessage = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + if !issetMessage { + fieldId = 1 + goto RequiredFieldNotSetError + } + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Req[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +RequiredFieldNotSetError: + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_Req[fieldId])) +} + +func (p *Req) ReadField1(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadString(); err != nil { + return err + } else { + p.Message = v + } + return nil +} + +func (p *Req) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Req"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *Req) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Message); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *Req) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Req(%+v)", *p) + +} + +func (p *Req) DeepEqual(ano *Req) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Message) { + return false + } + return true +} + +func (p *Req) Field1DeepEqual(src string) bool { + + if strings.Compare(p.Message, src) != 0 { + return false + } + return true +} + +type Rsp struct { + Message string `thrift:"message,1,required" frugal:"1,required,string" json:"message"` +} + +func NewRsp() *Rsp { + return &Rsp{} +} + +func (p *Rsp) InitDefault() { + *p = Rsp{} +} + +func (p *Rsp) GetMessage() (v string) { + return p.Message +} +func (p *Rsp) SetMessage(val string) { + p.Message = val +} + +var fieldIDToName_Rsp = map[int16]string{ + 1: "message", +} + +func (p *Rsp) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + var issetMessage bool = false + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + issetMessage = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + if !issetMessage { + fieldId = 1 + goto RequiredFieldNotSetError + } + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Rsp[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +RequiredFieldNotSetError: + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_Rsp[fieldId])) +} + +func (p *Rsp) ReadField1(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadString(); err != nil { + return err + } else { + p.Message = v + } + return nil +} + +func (p *Rsp) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Rsp"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *Rsp) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Message); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *Rsp) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Rsp(%+v)", *p) + +} + +func (p *Rsp) DeepEqual(ano *Rsp) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Message) { + return false + } + return true +} + +func (p *Rsp) Field1DeepEqual(src string) bool { + + if strings.Compare(p.Message, src) != 0 { + return false + } + return true +} + +type A interface { + Foo(ctx context.Context, req *Req) (r *Rsp, err error) +} + +type AClient struct { + c thrift.TClient +} + +func NewAClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *AClient { + return &AClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewAClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *AClient { + return &AClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewAClient(c thrift.TClient) *AClient { + return &AClient{ + c: c, + } +} + +func (p *AClient) Client_() thrift.TClient { + return p.c +} + +func (p *AClient) Foo(ctx context.Context, req *Req) (r *Rsp, err error) { + var _args AFooArgs + _args.Req = req + var _result AFooResult + if err = p.Client_().Call(ctx, "Foo", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +type B interface { + Bar(stream B_BarServer) (err error) +} + +type BClient struct { + c thrift.TClient +} + +func NewBClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *BClient { + return &BClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewBClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *BClient { + return &BClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewBClient(c thrift.TClient) *BClient { + return &BClient{ + c: c, + } +} + +func (p *BClient) Client_() thrift.TClient { + return p.c +} + +func (p *BClient) Bar(stream B_BarServer) (err error) { + panic("streaming method B.Bar(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") +} + +type B_BarServer interface { + streaming.Stream + + Recv() (*Req, error) + + Send(*Rsp) error +} + +type AProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler A +} + +func (p *AProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *AProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *AProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewAProcessor(handler A) *AProcessor { + self := &AProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self.AddToProcessorMap("Foo", &aProcessorFoo{handler: handler}) + return self +} +func (p *AProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} + +type aProcessorFoo struct { + handler A +} + +func (p *aProcessorFoo) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AFooArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("Foo", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := AFooResult{} + var retval *Rsp + if retval, err2 = p.handler.Foo(ctx, args.Req); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Foo: "+err2.Error()) + oprot.WriteMessageBegin("Foo", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("Foo", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type AFooArgs struct { + Req *Req `thrift:"req,1" frugal:"1,default,Req" json:"req"` +} + +func NewAFooArgs() *AFooArgs { + return &AFooArgs{} +} + +func (p *AFooArgs) InitDefault() { + *p = AFooArgs{} +} + +var AFooArgs_Req_DEFAULT *Req + +func (p *AFooArgs) GetReq() (v *Req) { + if !p.IsSetReq() { + return AFooArgs_Req_DEFAULT + } + return p.Req +} +func (p *AFooArgs) SetReq(val *Req) { + p.Req = val +} + +var fieldIDToName_AFooArgs = map[int16]string{ + 1: "req", +} + +func (p *AFooArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *AFooArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_AFooArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *AFooArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req = NewReq() + if err := p.Req.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *AFooArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Foo_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *AFooArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *AFooArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AFooArgs(%+v)", *p) + +} + +func (p *AFooArgs) DeepEqual(ano *AFooArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req) { + return false + } + return true +} + +func (p *AFooArgs) Field1DeepEqual(src *Req) bool { + + if !p.Req.DeepEqual(src) { + return false + } + return true +} + +type AFooResult struct { + Success *Rsp `thrift:"success,0,optional" frugal:"0,optional,Rsp" json:"success,omitempty"` +} + +func NewAFooResult() *AFooResult { + return &AFooResult{} +} + +func (p *AFooResult) InitDefault() { + *p = AFooResult{} +} + +var AFooResult_Success_DEFAULT *Rsp + +func (p *AFooResult) GetSuccess() (v *Rsp) { + if !p.IsSetSuccess() { + return AFooResult_Success_DEFAULT + } + return p.Success +} +func (p *AFooResult) SetSuccess(x interface{}) { + p.Success = x.(*Rsp) +} + +var fieldIDToName_AFooResult = map[int16]string{ + 0: "success", +} + +func (p *AFooResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AFooResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_AFooResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *AFooResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = NewRsp() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *AFooResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Foo_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *AFooResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *AFooResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AFooResult(%+v)", *p) + +} + +func (p *AFooResult) DeepEqual(ano *AFooResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *AFooResult) Field0DeepEqual(src *Rsp) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type BProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler B +} + +func (p *BProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *BProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *BProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewBProcessor(handler B) *BProcessor { + self := &BProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self.AddToProcessorMap("Bar", &bProcessorBar{handler: handler}) + return self +} +func (p *BProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} + +type bProcessorBar struct { + handler B +} + +func (p *bProcessorBar) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + panic("streaming method B.Bar(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") +} + +type BBarArgs struct { + Req *Req `thrift:"req,1" frugal:"1,default,Req" json:"req"` +} + +func NewBBarArgs() *BBarArgs { + return &BBarArgs{} +} + +func (p *BBarArgs) InitDefault() { + *p = BBarArgs{} +} + +var BBarArgs_Req_DEFAULT *Req + +func (p *BBarArgs) GetReq() (v *Req) { + if !p.IsSetReq() { + return BBarArgs_Req_DEFAULT + } + return p.Req +} +func (p *BBarArgs) SetReq(val *Req) { + p.Req = val +} + +var fieldIDToName_BBarArgs = map[int16]string{ + 1: "req", +} + +func (p *BBarArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *BBarArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BBarArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BBarArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req = NewReq() + if err := p.Req.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *BBarArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Bar_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *BBarArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *BBarArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("BBarArgs(%+v)", *p) + +} + +func (p *BBarArgs) DeepEqual(ano *BBarArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req) { + return false + } + return true +} + +func (p *BBarArgs) Field1DeepEqual(src *Req) bool { + + if !p.Req.DeepEqual(src) { + return false + } + return true +} + +type BBarResult struct { + Success *Rsp `thrift:"success,0,optional" frugal:"0,optional,Rsp" json:"success,omitempty"` +} + +func NewBBarResult() *BBarResult { + return &BBarResult{} +} + +func (p *BBarResult) InitDefault() { + *p = BBarResult{} +} + +var BBarResult_Success_DEFAULT *Rsp + +func (p *BBarResult) GetSuccess() (v *Rsp) { + if !p.IsSetSuccess() { + return BBarResult_Success_DEFAULT + } + return p.Success +} +func (p *BBarResult) SetSuccess(x interface{}) { + p.Success = x.(*Rsp) +} + +var fieldIDToName_BBarResult = map[int16]string{ + 0: "success", +} + +func (p *BBarResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *BBarResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BBarResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BBarResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = NewRsp() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *BBarResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Bar_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *BBarResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *BBarResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("BBarResult(%+v)", *p) + +} + +func (p *BBarResult) DeepEqual(ano *BBarResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *BBarResult) Field0DeepEqual(src *Rsp) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} diff --git a/thrift_streaming/kitex_gen/combine/combineservice/client.go b/thrift_streaming/kitex_gen/combine/combineservice/client.go new file mode 100644 index 0000000..701ff12 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/combineservice/client.go @@ -0,0 +1,99 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combineservice + +import ( + "context" + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + Foo(ctx context.Context, req *combine.Req, callOptions ...callopt.Option) (r *combine.Rsp, err error) +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + Bar(ctx context.Context, callOptions ...streamcall.Option) (stream B_BarClient, err error) +} + +type B_BarClient interface { + streaming.Stream + Send(*combine.Req) error + Recv() (*combine.Rsp, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kCombineServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kCombineServiceClient struct { + *kClient +} + +func (p *kCombineServiceClient) Foo(ctx context.Context, req *combine.Req, callOptions ...callopt.Option) (r *combine.Rsp, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.Foo(ctx, req) +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kCombineServiceStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kCombineServiceStreamClient struct { + *kClient +} + +func (p *kCombineServiceStreamClient) Bar(ctx context.Context, callOptions ...streamcall.Option) (stream B_BarClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.Bar(ctx) +} diff --git a/thrift_streaming/kitex_gen/combine/combineservice/combineservice.go b/thrift_streaming/kitex_gen/combine/combineservice/combineservice.go new file mode 100644 index 0000000..d6a31b5 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/combineservice/combineservice.go @@ -0,0 +1,197 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combineservice + +import ( + "context" + "errors" + "fmt" + combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +type CombineService interface { + combine.A + combine.B +} + +var serviceMethods = map[string]kitex.MethodInfo{ + "Foo": kitex.NewMethodInfo( + fooHandler, + newAFooArgs, + newAFooResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "Bar": kitex.NewMethodInfo( + barHandler, + newBBarArgs, + newBBarResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + combineServiceServiceInfo = NewServiceInfo() + combineServiceServiceInfoForClient = NewServiceInfoForClient() + combineServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return combineServiceServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return combineServiceServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return combineServiceServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "CombineService" + handlerType := (*CombineService)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "combine", + } + extra["combine_service"] = true + extra["combined_service_list"] = []string{"A", "B"} + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func fooHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*combine.AFooArgs) + realResult := result.(*combine.AFooResult) + success, err := handler.(combine.A).Foo(ctx, realArg.Req) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newAFooArgs() interface{} { + return combine.NewAFooArgs() +} + +func newAFooResult() interface{} { + return combine.NewAFooResult() +} + +func barHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("B.Bar is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &bBarServer{st.Stream} + return handler.(combine.B).Bar(stream) +} + +type bBarClient struct { + streaming.Stream +} + +func (x *bBarClient) Send(m *combine.Req) error { + return x.Stream.SendMsg(m) +} +func (x *bBarClient) Recv() (*combine.Rsp, error) { + m := new(combine.Rsp) + return m, x.Stream.RecvMsg(m) +} + +type bBarServer struct { + streaming.Stream +} + +func (x *bBarServer) Send(m *combine.Rsp) error { + return x.Stream.SendMsg(m) +} + +func (x *bBarServer) Recv() (*combine.Req, error) { + m := new(combine.Req) + return m, x.Stream.RecvMsg(m) +} + +func newBBarArgs() interface{} { + return combine.NewBBarArgs() +} + +func newBBarResult() interface{} { + return combine.NewBBarResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) Foo(ctx context.Context, req *combine.Req) (r *combine.Rsp, err error) { + var _args combine.AFooArgs + _args.Req = req + var _result combine.AFooResult + if err = p.c.Call(ctx, "Foo", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) Bar(ctx context.Context) (B_BarClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "Bar", nil, res) + if err != nil { + return nil, err + } + stream := &bBarClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen/combine/combineservice/invoker.go b/thrift_streaming/kitex_gen/combine/combineservice/invoker.go new file mode 100644 index 0000000..5605702 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/combineservice/invoker.go @@ -0,0 +1,23 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combineservice + +import ( + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler CombineService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/combine/combineservice/server.go b/thrift_streaming/kitex_gen/combine/combineservice/server.go new file mode 100644 index 0000000..39f663b --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/combineservice/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package combineservice + +import ( + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler CombineService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/combine/k-combine.go b/thrift_streaming/kitex_gen/combine/k-combine.go new file mode 100644 index 0000000..eca2fed --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/k-combine.go @@ -0,0 +1,832 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combine + +import ( + "bytes" + "fmt" + "reflect" + "strings" + + "github.com/apache/thrift/lib/go/thrift" + + "github.com/cloudwego/kitex/pkg/protocol/bthrift" +) + +// unused protection +var ( + _ = fmt.Formatter(nil) + _ = (*bytes.Buffer)(nil) + _ = (*strings.Builder)(nil) + _ = reflect.Type(nil) + _ = thrift.TProtocol(nil) + _ = bthrift.BinaryWriter(nil) +) + +func (p *Req) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + var issetMessage bool = false + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + issetMessage = true + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + if !issetMessage { + fieldId = 1 + goto RequiredFieldNotSetError + } + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Req[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +RequiredFieldNotSetError: + return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_Req[fieldId])) +} + +func (p *Req) FastReadField1(buf []byte) (int, error) { + offset := 0 + + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.Message = v + + } + return offset, nil +} + +// for compatibility +func (p *Req) FastWrite(buf []byte) int { + return 0 +} + +func (p *Req) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Req") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *Req) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Req") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *Req) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) + + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Req) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) + l += bthrift.Binary.StringLengthNocopy(p.Message) + + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Rsp) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + var issetMessage bool = false + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + issetMessage = true + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + if !issetMessage { + fieldId = 1 + goto RequiredFieldNotSetError + } + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Rsp[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +RequiredFieldNotSetError: + return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_Rsp[fieldId])) +} + +func (p *Rsp) FastReadField1(buf []byte) (int, error) { + offset := 0 + + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.Message = v + + } + return offset, nil +} + +// for compatibility +func (p *Rsp) FastWrite(buf []byte) int { + return 0 +} + +func (p *Rsp) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Rsp") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *Rsp) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Rsp") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *Rsp) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) + + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Rsp) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) + l += bthrift.Binary.StringLengthNocopy(p.Message) + + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *AFooArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_AFooArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *AFooArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewReq() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req = tmp + return offset, nil +} + +// for compatibility +func (p *AFooArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *AFooArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Foo_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *AFooArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Foo_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *AFooArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *AFooArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += p.Req.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *AFooResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_AFooResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *AFooResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := NewRsp() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *AFooResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *AFooResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Foo_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *AFooResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Foo_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *AFooResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *AFooResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *BBarArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BBarArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BBarArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewReq() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req = tmp + return offset, nil +} + +// for compatibility +func (p *BBarArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *BBarArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Bar_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *BBarArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Bar_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *BBarArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req", thrift.STRUCT, 1) + offset += p.Req.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *BBarArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req", thrift.STRUCT, 1) + l += p.Req.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *BBarResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_BBarResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *BBarResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := NewRsp() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *BBarResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *BBarResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Bar_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *BBarResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Bar_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *BBarResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *BBarResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *AFooArgs) GetFirstArgument() interface{} { + return p.Req +} + +func (p *AFooResult) GetResult() interface{} { + return p.Success +} + +func (p *BBarArgs) GetFirstArgument() interface{} { + return p.Req +} + +func (p *BBarResult) GetResult() interface{} { + return p.Success +} diff --git a/thrift_streaming/kitex_gen/combine/k-consts.go b/thrift_streaming/kitex_gen/combine/k-consts.go new file mode 100644 index 0000000..653b83e --- /dev/null +++ b/thrift_streaming/kitex_gen/combine/k-consts.go @@ -0,0 +1,4 @@ +package combine + +// KitexUnusedProtection is used to prevent 'imported and not used' error. +var KitexUnusedProtection = struct{}{} diff --git a/thrift_streaming/kitex_gen/combine_extend/a/a.go b/thrift_streaming/kitex_gen/combine_extend/a/a.go new file mode 100644 index 0000000..fc84980 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/a/a.go @@ -0,0 +1,126 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package a + +import ( + "context" + "errors" + combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine_extend" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoPingPongNew": kitex.NewMethodInfo( + echoPingPongNewHandler, + newPingPongOnlyServiceEchoPingPongNewArgs, + newPingPongOnlyServiceEchoPingPongNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), +} + +var ( + aServiceInfo = NewServiceInfo() + aServiceInfoForClient = NewServiceInfoForClient() + aServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return aServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return aServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return aServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "A" + handlerType := (*combine_extend.A)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "combine_extend", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() +} + +func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongNewArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceEchoPingPongNewResult + if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen/combine_extend/a/client.go b/thrift_streaming/kitex_gen/combine_extend/a/client.go new file mode 100644 index 0000000..5b397f3 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/a/client.go @@ -0,0 +1,49 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package a + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kAClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kAClient struct { + *kClient +} + +func (p *kAClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPongNew(ctx, req1) +} diff --git a/thrift_streaming/kitex_gen/combine_extend/a/invoker.go b/thrift_streaming/kitex_gen/combine_extend/a/invoker.go new file mode 100644 index 0000000..18adccc --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/a/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package a + +import ( + combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine_extend" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler combine_extend.A, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/combine_extend/a/server.go b/thrift_streaming/kitex_gen/combine_extend/a/server.go new file mode 100644 index 0000000..fcfeef1 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/a/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package a + +import ( + combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine_extend" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler combine_extend.A, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/combine_extend/b/b.go b/thrift_streaming/kitex_gen/combine_extend/b/b.go new file mode 100644 index 0000000..3d7980f --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/b/b.go @@ -0,0 +1,156 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package b + +import ( + "context" + "errors" + "fmt" + combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine_extend" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoBidirectionalNew": kitex.NewMethodInfo( + echoBidirectionalNewHandler, + newStreamOnlyServiceEchoBidirectionalNewArgs, + newStreamOnlyServiceEchoBidirectionalNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + bServiceInfo = NewServiceInfo() + bServiceInfoForClient = NewServiceInfoForClient() + bServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return bServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return bServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return bServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "B" + handlerType := (*combine_extend.B)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "combine_extend", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("StreamOnlyService.EchoBidirectionalNew is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &streamOnlyServiceEchoBidirectionalNewServer{st.Stream} + return handler.(echo.StreamOnlyService).EchoBidirectionalNew(stream) +} + +type streamOnlyServiceEchoBidirectionalNewClient struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *streamOnlyServiceEchoBidirectionalNewClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type streamOnlyServiceEchoBidirectionalNewServer struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() +} + +func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoBidirectionalNew(ctx context.Context) (StreamOnlyService_EchoBidirectionalNewClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectionalNew", nil, res) + if err != nil { + return nil, err + } + stream := &streamOnlyServiceEchoBidirectionalNewClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen/combine_extend/b/client.go b/thrift_streaming/kitex_gen/combine_extend/b/client.go new file mode 100644 index 0000000..645ae56 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/b/client.go @@ -0,0 +1,92 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package b + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) +} + +type StreamOnlyService_EchoBidirectionalNewClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kBClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kBClient struct { + *kClient +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kBStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kBStreamClient struct { + *kClient +} + +func (p *kBStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalNew(ctx) +} diff --git a/thrift_streaming/kitex_gen/combine_extend/b/invoker.go b/thrift_streaming/kitex_gen/combine_extend/b/invoker.go new file mode 100644 index 0000000..3fbd965 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/b/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package b + +import ( + combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine_extend" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler combine_extend.B, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/combine_extend/b/server.go b/thrift_streaming/kitex_gen/combine_extend/b/server.go new file mode 100644 index 0000000..54ea26b --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/b/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package b + +import ( + combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine_extend" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler combine_extend.B, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/combine_extend/combine_extend.go b/thrift_streaming/kitex_gen/combine_extend/combine_extend.go new file mode 100644 index 0000000..1777e28 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/combine_extend.go @@ -0,0 +1,78 @@ +// Code generated by thriftgo (0.3.6). DO NOT EDIT. + +package combine_extend + +import ( + "github.com/apache/thrift/lib/go/thrift" + "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" +) + +type A interface { + echo.PingPongOnlyService +} + +type AClient struct { + *echo.PingPongOnlyServiceClient +} + +func NewAClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *AClient { + return &AClient{ + PingPongOnlyServiceClient: echo.NewPingPongOnlyServiceClientFactory(t, f), + } +} + +func NewAClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *AClient { + return &AClient{ + PingPongOnlyServiceClient: echo.NewPingPongOnlyServiceClientProtocol(t, iprot, oprot), + } +} + +func NewAClient(c thrift.TClient) *AClient { + return &AClient{ + PingPongOnlyServiceClient: echo.NewPingPongOnlyServiceClient(c), + } +} + +type B interface { + echo.StreamOnlyServiceChildChild +} + +type BClient struct { + *echo.StreamOnlyServiceChildChildClient +} + +func NewBClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *BClient { + return &BClient{ + StreamOnlyServiceChildChildClient: echo.NewStreamOnlyServiceChildChildClientFactory(t, f), + } +} + +func NewBClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *BClient { + return &BClient{ + StreamOnlyServiceChildChildClient: echo.NewStreamOnlyServiceChildChildClientProtocol(t, iprot, oprot), + } +} + +func NewBClient(c thrift.TClient) *BClient { + return &BClient{ + StreamOnlyServiceChildChildClient: echo.NewStreamOnlyServiceChildChildClient(c), + } +} + +type AProcessor struct { + *echo.PingPongOnlyServiceProcessor +} + +func NewAProcessor(handler A) *AProcessor { + self := &AProcessor{echo.NewPingPongOnlyServiceProcessor(handler)} + return self +} + +type BProcessor struct { + *echo.StreamOnlyServiceChildChildProcessor +} + +func NewBProcessor(handler B) *BProcessor { + self := &BProcessor{echo.NewStreamOnlyServiceChildChildProcessor(handler)} + return self +} diff --git a/thrift_streaming/kitex_gen/combine_extend/combineservice/client.go b/thrift_streaming/kitex_gen/combine_extend/combineservice/client.go new file mode 100644 index 0000000..6d71e8d --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/combineservice/client.go @@ -0,0 +1,99 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combineservice + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) +} + +type StreamOnlyService_EchoBidirectionalNewClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kCombineServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kCombineServiceClient struct { + *kClient +} + +func (p *kCombineServiceClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPongNew(ctx, req1) +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kCombineServiceStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kCombineServiceStreamClient struct { + *kClient +} + +func (p *kCombineServiceStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalNew(ctx) +} diff --git a/thrift_streaming/kitex_gen/combine_extend/combineservice/combineservice.go b/thrift_streaming/kitex_gen/combine_extend/combineservice/combineservice.go new file mode 100644 index 0000000..12b5f62 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/combineservice/combineservice.go @@ -0,0 +1,198 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combineservice + +import ( + "context" + "errors" + "fmt" + combine_extend "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine_extend" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +type CombineService interface { + combine_extend.A + combine_extend.B +} + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoPingPongNew": kitex.NewMethodInfo( + echoPingPongNewHandler, + newPingPongOnlyServiceEchoPingPongNewArgs, + newPingPongOnlyServiceEchoPingPongNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "EchoBidirectionalNew": kitex.NewMethodInfo( + echoBidirectionalNewHandler, + newStreamOnlyServiceEchoBidirectionalNewArgs, + newStreamOnlyServiceEchoBidirectionalNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + combineServiceServiceInfo = NewServiceInfo() + combineServiceServiceInfoForClient = NewServiceInfoForClient() + combineServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return combineServiceServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return combineServiceServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return combineServiceServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "CombineService" + handlerType := (*CombineService)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "combine_extend", + } + extra["combine_service"] = true + extra["combined_service_list"] = []string{"A", "B"} + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() +} + +func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewResult() +} + +func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("StreamOnlyService.EchoBidirectionalNew is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &streamOnlyServiceEchoBidirectionalNewServer{st.Stream} + return handler.(echo.StreamOnlyService).EchoBidirectionalNew(stream) +} + +type streamOnlyServiceEchoBidirectionalNewClient struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *streamOnlyServiceEchoBidirectionalNewClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type streamOnlyServiceEchoBidirectionalNewServer struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() +} + +func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongNewArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceEchoPingPongNewResult + if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) EchoBidirectionalNew(ctx context.Context) (StreamOnlyService_EchoBidirectionalNewClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectionalNew", nil, res) + if err != nil { + return nil, err + } + stream := &streamOnlyServiceEchoBidirectionalNewClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen/combine_extend/combineservice/invoker.go b/thrift_streaming/kitex_gen/combine_extend/combineservice/invoker.go new file mode 100644 index 0000000..5605702 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/combineservice/invoker.go @@ -0,0 +1,23 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combineservice + +import ( + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler CombineService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/combine_extend/combineservice/server.go b/thrift_streaming/kitex_gen/combine_extend/combineservice/server.go new file mode 100644 index 0000000..39f663b --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/combineservice/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package combineservice + +import ( + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler CombineService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/combine_extend/k-combine_extend.go b/thrift_streaming/kitex_gen/combine_extend/k-combine_extend.go new file mode 100644 index 0000000..0eabf31 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/k-combine_extend.go @@ -0,0 +1,27 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package combine_extend + +import ( + "bytes" + "fmt" + "reflect" + "strings" + + "github.com/apache/thrift/lib/go/thrift" + + "github.com/cloudwego/kitex/pkg/protocol/bthrift" + + "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" +) + +// unused protection +var ( + _ = fmt.Formatter(nil) + _ = (*bytes.Buffer)(nil) + _ = (*strings.Builder)(nil) + _ = reflect.Type(nil) + _ = thrift.TProtocol(nil) + _ = bthrift.BinaryWriter(nil) + _ = echo.KitexUnusedProtection +) diff --git a/thrift_streaming/kitex_gen/combine_extend/k-consts.go b/thrift_streaming/kitex_gen/combine_extend/k-consts.go new file mode 100644 index 0000000..8e5ff02 --- /dev/null +++ b/thrift_streaming/kitex_gen/combine_extend/k-consts.go @@ -0,0 +1,4 @@ +package combine_extend + +// KitexUnusedProtection is used to prevent 'imported and not used' error. +var KitexUnusedProtection = struct{}{} diff --git a/thrift_streaming/kitex_gen/echo/abcservice/abcservice.go b/thrift_streaming/kitex_gen/echo/abcservice/abcservice.go new file mode 100644 index 0000000..55cb62f --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/abcservice/abcservice.go @@ -0,0 +1,362 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package abcservice + +import ( + "context" + "errors" + "fmt" + c "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/a/b/c" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "Echo": kitex.NewMethodInfo( + echoHandler, + newABCServiceEchoArgs, + newABCServiceEchoResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "EchoBidirectional": kitex.NewMethodInfo( + echoBidirectionalHandler, + newABCServiceEchoBidirectionalArgs, + newABCServiceEchoBidirectionalResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), + "EchoServer": kitex.NewMethodInfo( + echoServerHandler, + newABCServiceEchoServerArgs, + newABCServiceEchoServerResult, + false, + kitex.WithStreamingMode(kitex.StreamingServer), + ), + "EchoClient": kitex.NewMethodInfo( + echoClientHandler, + newABCServiceEchoClientArgs, + newABCServiceEchoClientResult, + false, + kitex.WithStreamingMode(kitex.StreamingClient), + ), + "EchoUnary": kitex.NewMethodInfo( + echoUnaryHandler, + newABCServiceEchoUnaryArgs, + newABCServiceEchoUnaryResult, + false, + kitex.WithStreamingMode(kitex.StreamingUnary), + ), +} + +var ( + aBCServiceServiceInfo = NewServiceInfo() + aBCServiceServiceInfoForClient = NewServiceInfoForClient() + aBCServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return aBCServiceServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return aBCServiceServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return aBCServiceServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "ABCService" + handlerType := (*echo.ABCService)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "echo", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.ABCServiceEchoArgs) + realResult := result.(*echo.ABCServiceEchoResult) + success, err := handler.(echo.ABCService).Echo(ctx, realArg.Req1, realArg.Req2) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newABCServiceEchoArgs() interface{} { + return echo.NewABCServiceEchoArgs() +} + +func newABCServiceEchoResult() interface{} { + return echo.NewABCServiceEchoResult() +} + +func echoBidirectionalHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("ABCService.EchoBidirectional is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &aBCServiceEchoBidirectionalServer{st.Stream} + return handler.(echo.ABCService).EchoBidirectional(stream) +} + +type aBCServiceEchoBidirectionalClient struct { + streaming.Stream +} + +func (x *aBCServiceEchoBidirectionalClient) Send(m *c.Request) error { + return x.Stream.SendMsg(m) +} +func (x *aBCServiceEchoBidirectionalClient) Recv() (*c.Response, error) { + m := new(c.Response) + return m, x.Stream.RecvMsg(m) +} + +type aBCServiceEchoBidirectionalServer struct { + streaming.Stream +} + +func (x *aBCServiceEchoBidirectionalServer) Send(m *c.Response) error { + return x.Stream.SendMsg(m) +} + +func (x *aBCServiceEchoBidirectionalServer) Recv() (*c.Request, error) { + m := new(c.Request) + return m, x.Stream.RecvMsg(m) +} + +func newABCServiceEchoBidirectionalArgs() interface{} { + return echo.NewABCServiceEchoBidirectionalArgs() +} + +func newABCServiceEchoBidirectionalResult() interface{} { + return echo.NewABCServiceEchoBidirectionalResult() +} + +func echoServerHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("ABCService.EchoServer is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &aBCServiceEchoServerServer{st.Stream} + req := new(c.Request) + if err := st.Stream.RecvMsg(req); err != nil { + return err + } + return handler.(echo.ABCService).EchoServer(req, stream) +} + +type aBCServiceEchoServerClient struct { + streaming.Stream +} + +func (x *aBCServiceEchoServerClient) Recv() (*c.Response, error) { + m := new(c.Response) + return m, x.Stream.RecvMsg(m) +} + +type aBCServiceEchoServerServer struct { + streaming.Stream +} + +func (x *aBCServiceEchoServerServer) Send(m *c.Response) error { + return x.Stream.SendMsg(m) +} + +func newABCServiceEchoServerArgs() interface{} { + return echo.NewABCServiceEchoServerArgs() +} + +func newABCServiceEchoServerResult() interface{} { + return echo.NewABCServiceEchoServerResult() +} + +func echoClientHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("ABCService.EchoClient is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &aBCServiceEchoClientServer{st.Stream} + return handler.(echo.ABCService).EchoClient(stream) +} + +type aBCServiceEchoClientClient struct { + streaming.Stream +} + +func (x *aBCServiceEchoClientClient) Send(m *c.Request) error { + return x.Stream.SendMsg(m) +} +func (x *aBCServiceEchoClientClient) CloseAndRecv() (*c.Response, error) { + if err := x.Stream.Close(); err != nil { + return nil, err + } + m := new(c.Response) + return m, x.Stream.RecvMsg(m) +} + +type aBCServiceEchoClientServer struct { + streaming.Stream +} + +func (x *aBCServiceEchoClientServer) SendAndClose(m *c.Response) error { + return x.Stream.SendMsg(m) +} + +func (x *aBCServiceEchoClientServer) Recv() (*c.Request, error) { + m := new(c.Request) + return m, x.Stream.RecvMsg(m) +} + +func newABCServiceEchoClientArgs() interface{} { + return echo.NewABCServiceEchoClientArgs() +} + +func newABCServiceEchoClientResult() interface{} { + return echo.NewABCServiceEchoClientResult() +} + +func echoUnaryHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + if streaming.GetStream(ctx) == nil { + return errors.New("ABCService.EchoUnary is a thrift streaming unary method, please call with Kitex StreamClient or remove the annotation streaming.mode") + } + realArg := arg.(*echo.ABCServiceEchoUnaryArgs) + realResult := result.(*echo.ABCServiceEchoUnaryResult) + success, err := handler.(echo.ABCService).EchoUnary(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newABCServiceEchoUnaryArgs() interface{} { + return echo.NewABCServiceEchoUnaryArgs() +} + +func newABCServiceEchoUnaryResult() interface{} { + return echo.NewABCServiceEchoUnaryResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) Echo(ctx context.Context, req1 *c.Request, req2 *c.Request) (r *c.Response, err error) { + var _args echo.ABCServiceEchoArgs + _args.Req1 = req1 + _args.Req2 = req2 + var _result echo.ABCServiceEchoResult + if err = p.c.Call(ctx, "Echo", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) EchoBidirectional(ctx context.Context) (ABCService_EchoBidirectionalClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectional", nil, res) + if err != nil { + return nil, err + } + stream := &aBCServiceEchoBidirectionalClient{res.Stream} + return stream, nil +} + +func (p *kClient) EchoServer(ctx context.Context, req1 *c.Request) (ABCService_EchoServerClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoServer", nil, res) + if err != nil { + return nil, err + } + stream := &aBCServiceEchoServerClient{res.Stream} + + if err := stream.Stream.SendMsg(req1); err != nil { + return nil, err + } + if err := stream.Stream.Close(); err != nil { + return nil, err + } + return stream, nil +} + +func (p *kClient) EchoClient(ctx context.Context) (ABCService_EchoClientClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoClient", nil, res) + if err != nil { + return nil, err + } + stream := &aBCServiceEchoClientClient{res.Stream} + return stream, nil +} + +func (p *kClient) EchoUnary(ctx context.Context, req1 *c.Request) (r *c.Response, err error) { + var _args echo.ABCServiceEchoUnaryArgs + _args.Req1 = req1 + var _result echo.ABCServiceEchoUnaryResult + if err = p.c.Call(ctx, "EchoUnary", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen/echo/abcservice/client.go b/thrift_streaming/kitex_gen/echo/abcservice/client.go new file mode 100644 index 0000000..3da61ec --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/abcservice/client.go @@ -0,0 +1,128 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package abcservice + +import ( + "context" + c "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/a/b/c" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + Echo(ctx context.Context, req1 *c.Request, req2 *c.Request, callOptions ...callopt.Option) (r *c.Response, err error) +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectional(ctx context.Context, callOptions ...streamcall.Option) (stream ABCService_EchoBidirectionalClient, err error) + EchoServer(ctx context.Context, req1 *c.Request, callOptions ...streamcall.Option) (stream ABCService_EchoServerClient, err error) + EchoClient(ctx context.Context, callOptions ...streamcall.Option) (stream ABCService_EchoClientClient, err error) + EchoUnary(ctx context.Context, req1 *c.Request, callOptions ...streamcall.Option) (r *c.Response, err error) +} + +type ABCService_EchoBidirectionalClient interface { + streaming.Stream + Send(*c.Request) error + Recv() (*c.Response, error) +} + +type ABCService_EchoServerClient interface { + streaming.Stream + Recv() (*c.Response, error) +} + +type ABCService_EchoClientClient interface { + streaming.Stream + Send(*c.Request) error + CloseAndRecv() (*c.Response, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kABCServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kABCServiceClient struct { + *kClient +} + +func (p *kABCServiceClient) Echo(ctx context.Context, req1 *c.Request, req2 *c.Request, callOptions ...callopt.Option) (r *c.Response, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.Echo(ctx, req1, req2) +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kABCServiceStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kABCServiceStreamClient struct { + *kClient +} + +func (p *kABCServiceStreamClient) EchoBidirectional(ctx context.Context, callOptions ...streamcall.Option) (stream ABCService_EchoBidirectionalClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectional(ctx) +} + +func (p *kABCServiceStreamClient) EchoServer(ctx context.Context, req1 *c.Request, callOptions ...streamcall.Option) (stream ABCService_EchoServerClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoServer(ctx, req1) +} + +func (p *kABCServiceStreamClient) EchoClient(ctx context.Context, callOptions ...streamcall.Option) (stream ABCService_EchoClientClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoClient(ctx) +} + +func (p *kABCServiceStreamClient) EchoUnary(ctx context.Context, req1 *c.Request, callOptions ...streamcall.Option) (r *c.Response, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoUnary(ctx, req1) +} diff --git a/thrift_streaming/kitex_gen/echo/abcservice/invoker.go b/thrift_streaming/kitex_gen/echo/abcservice/invoker.go new file mode 100644 index 0000000..4ab3988 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/abcservice/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package abcservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.ABCService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/echo/abcservice/server.go b/thrift_streaming/kitex_gen/echo/abcservice/server.go new file mode 100644 index 0000000..1121964 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/abcservice/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package abcservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.ABCService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/echo/api.go b/thrift_streaming/kitex_gen/echo/api.go new file mode 100644 index 0000000..a91da53 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/api.go @@ -0,0 +1,6506 @@ +// Code generated by thriftgo (0.3.6). DO NOT EDIT. + +package echo + +import ( + "context" + "fmt" + "github.com/apache/thrift/lib/go/thrift" + "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/a/b/c" + "github.com/cloudwego/kitex/pkg/streaming" + "strings" +) + +type EchoRequest struct { + Message string `thrift:"message,1,required" frugal:"1,required,string" json:"message"` +} + +func NewEchoRequest() *EchoRequest { + return &EchoRequest{} +} + +func (p *EchoRequest) InitDefault() { + *p = EchoRequest{} +} + +func (p *EchoRequest) GetMessage() (v string) { + return p.Message +} +func (p *EchoRequest) SetMessage(val string) { + p.Message = val +} + +var fieldIDToName_EchoRequest = map[int16]string{ + 1: "message", +} + +func (p *EchoRequest) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + var issetMessage bool = false + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + issetMessage = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + if !issetMessage { + fieldId = 1 + goto RequiredFieldNotSetError + } + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoRequest[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +RequiredFieldNotSetError: + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_EchoRequest[fieldId])) +} + +func (p *EchoRequest) ReadField1(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadString(); err != nil { + return err + } else { + p.Message = v + } + return nil +} + +func (p *EchoRequest) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoRequest"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *EchoRequest) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Message); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *EchoRequest) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("EchoRequest(%+v)", *p) + +} + +func (p *EchoRequest) DeepEqual(ano *EchoRequest) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Message) { + return false + } + return true +} + +func (p *EchoRequest) Field1DeepEqual(src string) bool { + + if strings.Compare(p.Message, src) != 0 { + return false + } + return true +} + +type EchoResponse struct { + Message string `thrift:"message,1,required" frugal:"1,required,string" json:"message"` +} + +func NewEchoResponse() *EchoResponse { + return &EchoResponse{} +} + +func (p *EchoResponse) InitDefault() { + *p = EchoResponse{} +} + +func (p *EchoResponse) GetMessage() (v string) { + return p.Message +} +func (p *EchoResponse) SetMessage(val string) { + p.Message = val +} + +var fieldIDToName_EchoResponse = map[int16]string{ + 1: "message", +} + +func (p *EchoResponse) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + var issetMessage bool = false + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + issetMessage = true + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + if !issetMessage { + fieldId = 1 + goto RequiredFieldNotSetError + } + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoResponse[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +RequiredFieldNotSetError: + return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_EchoResponse[fieldId])) +} + +func (p *EchoResponse) ReadField1(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadString(); err != nil { + return err + } else { + p.Message = v + } + return nil +} + +func (p *EchoResponse) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoResponse"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *EchoResponse) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Message); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *EchoResponse) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("EchoResponse(%+v)", *p) + +} + +func (p *EchoResponse) DeepEqual(ano *EchoResponse) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Message) { + return false + } + return true +} + +func (p *EchoResponse) Field1DeepEqual(src string) bool { + + if strings.Compare(p.Message, src) != 0 { + return false + } + return true +} + +type EchoException struct { + Message string `thrift:"message,1" frugal:"1,default,string" json:"message"` +} + +func NewEchoException() *EchoException { + return &EchoException{} +} + +func (p *EchoException) InitDefault() { + *p = EchoException{} +} + +func (p *EchoException) GetMessage() (v string) { + return p.Message +} +func (p *EchoException) SetMessage(val string) { + p.Message = val +} + +var fieldIDToName_EchoException = map[int16]string{ + 1: "message", +} + +func (p *EchoException) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoException[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoException) ReadField1(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadString(); err != nil { + return err + } else { + p.Message = v + } + return nil +} + +func (p *EchoException) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoException"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *EchoException) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Message); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *EchoException) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("EchoException(%+v)", *p) + +} +func (p *EchoException) Error() string { + return p.String() +} + +func (p *EchoException) DeepEqual(ano *EchoException) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Message) { + return false + } + return true +} + +func (p *EchoException) Field1DeepEqual(src string) bool { + + if strings.Compare(p.Message, src) != 0 { + return false + } + return true +} + +type EchoService interface { + EchoBidirectional(stream EchoService_EchoBidirectionalServer) (err error) + + EchoClient(stream EchoService_EchoClientServer) (err error) + + EchoServer(req *EchoRequest, stream EchoService_EchoServerServer) (err error) + + EchoUnary(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) + + EchoPingPong(ctx context.Context, req1 *EchoRequest, req2 *EchoRequest) (r *EchoResponse, err error) + + EchoOneway(ctx context.Context, req1 *EchoRequest) (err error) + + Ping(ctx context.Context) (err error) +} + +type EchoServiceClient struct { + c thrift.TClient +} + +func NewEchoServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *EchoServiceClient { + return &EchoServiceClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewEchoServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *EchoServiceClient { + return &EchoServiceClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewEchoServiceClient(c thrift.TClient) *EchoServiceClient { + return &EchoServiceClient{ + c: c, + } +} + +func (p *EchoServiceClient) Client_() thrift.TClient { + return p.c +} + +func (p *EchoServiceClient) EchoBidirectional(stream EchoService_EchoBidirectionalServer) (err error) { + panic("streaming method EchoService.EchoBidirectional(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") +} + +type EchoService_EchoBidirectionalServer interface { + streaming.Stream + + Recv() (*EchoRequest, error) + + Send(*EchoResponse) error +} + +func (p *EchoServiceClient) EchoClient(stream EchoService_EchoClientServer) (err error) { + panic("streaming method EchoService.EchoClient(mode = client) not available, please use Kitex Thrift Streaming Client.") +} + +type EchoService_EchoClientServer interface { + streaming.Stream + + Recv() (*EchoRequest, error) + + SendAndClose(*EchoResponse) error +} + +func (p *EchoServiceClient) EchoServer(req *EchoRequest, stream EchoService_EchoServerServer) (err error) { + panic("streaming method EchoService.EchoServer(mode = server) not available, please use Kitex Thrift Streaming Client.") +} + +type EchoService_EchoServerServer interface { + streaming.Stream + + Send(*EchoResponse) error +} + +func (p *EchoServiceClient) EchoUnary(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) { + panic("streaming method EchoService.EchoUnary(mode = unary) not available, please use Kitex Thrift Streaming Client.") +} +func (p *EchoServiceClient) EchoPingPong(ctx context.Context, req1 *EchoRequest, req2 *EchoRequest) (r *EchoResponse, err error) { + var _args EchoServiceEchoPingPongArgs + _args.Req1 = req1 + _args.Req2 = req2 + var _result EchoServiceEchoPingPongResult + if err = p.Client_().Call(ctx, "EchoPingPong", &_args, &_result); err != nil { + return + } + switch { + case _result.E != nil: + return r, _result.E + } + return _result.GetSuccess(), nil +} +func (p *EchoServiceClient) EchoOneway(ctx context.Context, req1 *EchoRequest) (err error) { + var _args EchoServiceEchoOnewayArgs + _args.Req1 = req1 + var _result EchoServiceEchoOnewayResult + if err = p.Client_().Call(ctx, "EchoOneway", &_args, &_result); err != nil { + return + } + return nil +} +func (p *EchoServiceClient) Ping(ctx context.Context) (err error) { + var _args EchoServicePingArgs + var _result EchoServicePingResult + if err = p.Client_().Call(ctx, "Ping", &_args, &_result); err != nil { + return + } + return nil +} + +type PingPongOnlyService interface { + EchoPingPongNew(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) +} + +type PingPongOnlyServiceClient struct { + c thrift.TClient +} + +func NewPingPongOnlyServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *PingPongOnlyServiceClient { + return &PingPongOnlyServiceClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewPingPongOnlyServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *PingPongOnlyServiceClient { + return &PingPongOnlyServiceClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewPingPongOnlyServiceClient(c thrift.TClient) *PingPongOnlyServiceClient { + return &PingPongOnlyServiceClient{ + c: c, + } +} + +func (p *PingPongOnlyServiceClient) Client_() thrift.TClient { + return p.c +} + +func (p *PingPongOnlyServiceClient) EchoPingPongNew(ctx context.Context, req1 *EchoRequest) (r *EchoResponse, err error) { + var _args PingPongOnlyServiceEchoPingPongNewArgs + _args.Req1 = req1 + var _result PingPongOnlyServiceEchoPingPongNewResult + if err = p.Client_().Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +type PingPongOnlyServiceChild interface { + PingPongOnlyService + + EchoBidirectionalExtended(stream PingPongOnlyServiceChild_EchoBidirectionalExtendedServer) (err error) +} + +type PingPongOnlyServiceChildClient struct { + *PingPongOnlyServiceClient +} + +func NewPingPongOnlyServiceChildClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *PingPongOnlyServiceChildClient { + return &PingPongOnlyServiceChildClient{ + PingPongOnlyServiceClient: NewPingPongOnlyServiceClientFactory(t, f), + } +} + +func NewPingPongOnlyServiceChildClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *PingPongOnlyServiceChildClient { + return &PingPongOnlyServiceChildClient{ + PingPongOnlyServiceClient: NewPingPongOnlyServiceClientProtocol(t, iprot, oprot), + } +} + +func NewPingPongOnlyServiceChildClient(c thrift.TClient) *PingPongOnlyServiceChildClient { + return &PingPongOnlyServiceChildClient{ + PingPongOnlyServiceClient: NewPingPongOnlyServiceClient(c), + } +} + +func (p *PingPongOnlyServiceChildClient) EchoBidirectionalExtended(stream PingPongOnlyServiceChild_EchoBidirectionalExtendedServer) (err error) { + panic("streaming method PingPongOnlyServiceChild.EchoBidirectionalExtended(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") +} + +type PingPongOnlyServiceChild_EchoBidirectionalExtendedServer interface { + streaming.Stream + + Recv() (*EchoRequest, error) + + Send(*EchoResponse) error +} + +type PingPongOnlyServiceChildChild interface { + PingPongOnlyServiceChild +} + +type PingPongOnlyServiceChildChildClient struct { + *PingPongOnlyServiceChildClient +} + +func NewPingPongOnlyServiceChildChildClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *PingPongOnlyServiceChildChildClient { + return &PingPongOnlyServiceChildChildClient{ + PingPongOnlyServiceChildClient: NewPingPongOnlyServiceChildClientFactory(t, f), + } +} + +func NewPingPongOnlyServiceChildChildClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *PingPongOnlyServiceChildChildClient { + return &PingPongOnlyServiceChildChildClient{ + PingPongOnlyServiceChildClient: NewPingPongOnlyServiceChildClientProtocol(t, iprot, oprot), + } +} + +func NewPingPongOnlyServiceChildChildClient(c thrift.TClient) *PingPongOnlyServiceChildChildClient { + return &PingPongOnlyServiceChildChildClient{ + PingPongOnlyServiceChildClient: NewPingPongOnlyServiceChildClient(c), + } +} + +type StreamOnlyService interface { + EchoBidirectionalNew(stream StreamOnlyService_EchoBidirectionalNewServer) (err error) +} + +type StreamOnlyServiceClient struct { + c thrift.TClient +} + +func NewStreamOnlyServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *StreamOnlyServiceClient { + return &StreamOnlyServiceClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewStreamOnlyServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *StreamOnlyServiceClient { + return &StreamOnlyServiceClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewStreamOnlyServiceClient(c thrift.TClient) *StreamOnlyServiceClient { + return &StreamOnlyServiceClient{ + c: c, + } +} + +func (p *StreamOnlyServiceClient) Client_() thrift.TClient { + return p.c +} + +func (p *StreamOnlyServiceClient) EchoBidirectionalNew(stream StreamOnlyService_EchoBidirectionalNewServer) (err error) { + panic("streaming method StreamOnlyService.EchoBidirectionalNew(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") +} + +type StreamOnlyService_EchoBidirectionalNewServer interface { + streaming.Stream + + Recv() (*EchoRequest, error) + + Send(*EchoResponse) error +} + +type StreamOnlyServiceChild interface { + StreamOnlyService +} + +type StreamOnlyServiceChildClient struct { + *StreamOnlyServiceClient +} + +func NewStreamOnlyServiceChildClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *StreamOnlyServiceChildClient { + return &StreamOnlyServiceChildClient{ + StreamOnlyServiceClient: NewStreamOnlyServiceClientFactory(t, f), + } +} + +func NewStreamOnlyServiceChildClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *StreamOnlyServiceChildClient { + return &StreamOnlyServiceChildClient{ + StreamOnlyServiceClient: NewStreamOnlyServiceClientProtocol(t, iprot, oprot), + } +} + +func NewStreamOnlyServiceChildClient(c thrift.TClient) *StreamOnlyServiceChildClient { + return &StreamOnlyServiceChildClient{ + StreamOnlyServiceClient: NewStreamOnlyServiceClient(c), + } +} + +type StreamOnlyServiceChildChild interface { + StreamOnlyServiceChild +} + +type StreamOnlyServiceChildChildClient struct { + *StreamOnlyServiceChildClient +} + +func NewStreamOnlyServiceChildChildClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *StreamOnlyServiceChildChildClient { + return &StreamOnlyServiceChildChildClient{ + StreamOnlyServiceChildClient: NewStreamOnlyServiceChildClientFactory(t, f), + } +} + +func NewStreamOnlyServiceChildChildClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *StreamOnlyServiceChildChildClient { + return &StreamOnlyServiceChildChildClient{ + StreamOnlyServiceChildClient: NewStreamOnlyServiceChildClientProtocol(t, iprot, oprot), + } +} + +func NewStreamOnlyServiceChildChildClient(c thrift.TClient) *StreamOnlyServiceChildChildClient { + return &StreamOnlyServiceChildChildClient{ + StreamOnlyServiceChildClient: NewStreamOnlyServiceChildClient(c), + } +} + +type ABCService interface { + Echo(ctx context.Context, req1 *c.Request, req2 *c.Request) (r *c.Response, err error) + + EchoBidirectional(stream ABCService_EchoBidirectionalServer) (err error) + + EchoServer(req *c.Request, stream ABCService_EchoServerServer) (err error) + + EchoClient(stream ABCService_EchoClientServer) (err error) + + EchoUnary(ctx context.Context, req1 *c.Request) (r *c.Response, err error) +} + +type ABCServiceClient struct { + c thrift.TClient +} + +func NewABCServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ABCServiceClient { + return &ABCServiceClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewABCServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *ABCServiceClient { + return &ABCServiceClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewABCServiceClient(c thrift.TClient) *ABCServiceClient { + return &ABCServiceClient{ + c: c, + } +} + +func (p *ABCServiceClient) Client_() thrift.TClient { + return p.c +} + +func (p *ABCServiceClient) Echo(ctx context.Context, req1 *c.Request, req2 *c.Request) (r *c.Response, err error) { + var _args ABCServiceEchoArgs + _args.Req1 = req1 + _args.Req2 = req2 + var _result ABCServiceEchoResult + if err = p.Client_().Call(ctx, "Echo", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} +func (p *ABCServiceClient) EchoBidirectional(stream ABCService_EchoBidirectionalServer) (err error) { + panic("streaming method ABCService.EchoBidirectional(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") +} + +type ABCService_EchoBidirectionalServer interface { + streaming.Stream + + Recv() (*c.Request, error) + + Send(*c.Response) error +} + +func (p *ABCServiceClient) EchoServer(req *c.Request, stream ABCService_EchoServerServer) (err error) { + panic("streaming method ABCService.EchoServer(mode = server) not available, please use Kitex Thrift Streaming Client.") +} + +type ABCService_EchoServerServer interface { + streaming.Stream + + Send(*c.Response) error +} + +func (p *ABCServiceClient) EchoClient(stream ABCService_EchoClientServer) (err error) { + panic("streaming method ABCService.EchoClient(mode = client) not available, please use Kitex Thrift Streaming Client.") +} + +type ABCService_EchoClientServer interface { + streaming.Stream + + Recv() (*c.Request, error) + + SendAndClose(*c.Response) error +} + +func (p *ABCServiceClient) EchoUnary(ctx context.Context, req1 *c.Request) (r *c.Response, err error) { + panic("streaming method ABCService.EchoUnary(mode = unary) not available, please use Kitex Thrift Streaming Client.") +} + +type EchoServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler EchoService +} + +func (p *EchoServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *EchoServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *EchoServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewEchoServiceProcessor(handler EchoService) *EchoServiceProcessor { + self := &EchoServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self.AddToProcessorMap("EchoBidirectional", &echoServiceProcessorEchoBidirectional{handler: handler}) + self.AddToProcessorMap("EchoClient", &echoServiceProcessorEchoClient{handler: handler}) + self.AddToProcessorMap("EchoServer", &echoServiceProcessorEchoServer{handler: handler}) + self.AddToProcessorMap("EchoUnary", &echoServiceProcessorEchoUnary{handler: handler}) + self.AddToProcessorMap("EchoPingPong", &echoServiceProcessorEchoPingPong{handler: handler}) + self.AddToProcessorMap("EchoOneway", &echoServiceProcessorEchoOneway{handler: handler}) + self.AddToProcessorMap("Ping", &echoServiceProcessorPing{handler: handler}) + return self +} +func (p *EchoServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} + +type echoServiceProcessorEchoBidirectional struct { + handler EchoService +} + +func (p *echoServiceProcessorEchoBidirectional) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + panic("streaming method EchoService.EchoBidirectional(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") +} + +type echoServiceProcessorEchoClient struct { + handler EchoService +} + +func (p *echoServiceProcessorEchoClient) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + panic("streaming method EchoService.EchoClient(mode = client) not available, please use Kitex Thrift Streaming Client.") +} + +type echoServiceProcessorEchoServer struct { + handler EchoService +} + +func (p *echoServiceProcessorEchoServer) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + panic("streaming method EchoService.EchoServer(mode = server) not available, please use Kitex Thrift Streaming Client.") +} + +type echoServiceProcessorEchoUnary struct { + handler EchoService +} + +func (p *echoServiceProcessorEchoUnary) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + panic("streaming method EchoService.EchoUnary(mode = unary) not available, please use Kitex Thrift Streaming Client.") +} + +type echoServiceProcessorEchoPingPong struct { + handler EchoService +} + +func (p *echoServiceProcessorEchoPingPong) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := EchoServiceEchoPingPongArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("EchoPingPong", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := EchoServiceEchoPingPongResult{} + var retval *EchoResponse + if retval, err2 = p.handler.EchoPingPong(ctx, args.Req1, args.Req2); err2 != nil { + switch v := err2.(type) { + case *EchoException: + result.E = v + default: + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoPingPong: "+err2.Error()) + oprot.WriteMessageBegin("EchoPingPong", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("EchoPingPong", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type echoServiceProcessorEchoOneway struct { + handler EchoService +} + +func (p *echoServiceProcessorEchoOneway) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := EchoServiceEchoOnewayArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("EchoOneway", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := EchoServiceEchoOnewayResult{} + if err2 = p.handler.EchoOneway(ctx, args.Req1); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoOneway: "+err2.Error()) + oprot.WriteMessageBegin("EchoOneway", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } + if err2 = oprot.WriteMessageBegin("EchoOneway", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type echoServiceProcessorPing struct { + handler EchoService +} + +func (p *echoServiceProcessorPing) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := EchoServicePingArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("Ping", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := EchoServicePingResult{} + if err2 = p.handler.Ping(ctx); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Ping: "+err2.Error()) + oprot.WriteMessageBegin("Ping", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } + if err2 = oprot.WriteMessageBegin("Ping", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type EchoServiceEchoBidirectionalArgs struct { + Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` +} + +func NewEchoServiceEchoBidirectionalArgs() *EchoServiceEchoBidirectionalArgs { + return &EchoServiceEchoBidirectionalArgs{} +} + +func (p *EchoServiceEchoBidirectionalArgs) InitDefault() { + *p = EchoServiceEchoBidirectionalArgs{} +} + +var EchoServiceEchoBidirectionalArgs_Req1_DEFAULT *EchoRequest + +func (p *EchoServiceEchoBidirectionalArgs) GetReq1() (v *EchoRequest) { + if !p.IsSetReq1() { + return EchoServiceEchoBidirectionalArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *EchoServiceEchoBidirectionalArgs) SetReq1(val *EchoRequest) { + p.Req1 = val +} + +var fieldIDToName_EchoServiceEchoBidirectionalArgs = map[int16]string{ + 1: "req1", +} + +func (p *EchoServiceEchoBidirectionalArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *EchoServiceEchoBidirectionalArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoBidirectionalArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoBidirectionalArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = NewEchoRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *EchoServiceEchoBidirectionalArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoBidirectional_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *EchoServiceEchoBidirectionalArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *EchoServiceEchoBidirectionalArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("EchoServiceEchoBidirectionalArgs(%+v)", *p) + +} + +func (p *EchoServiceEchoBidirectionalArgs) DeepEqual(ano *EchoServiceEchoBidirectionalArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *EchoServiceEchoBidirectionalArgs) Field1DeepEqual(src *EchoRequest) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type EchoServiceEchoBidirectionalResult struct { + Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` +} + +func NewEchoServiceEchoBidirectionalResult() *EchoServiceEchoBidirectionalResult { + return &EchoServiceEchoBidirectionalResult{} +} + +func (p *EchoServiceEchoBidirectionalResult) InitDefault() { + *p = EchoServiceEchoBidirectionalResult{} +} + +var EchoServiceEchoBidirectionalResult_Success_DEFAULT *EchoResponse + +func (p *EchoServiceEchoBidirectionalResult) GetSuccess() (v *EchoResponse) { + if !p.IsSetSuccess() { + return EchoServiceEchoBidirectionalResult_Success_DEFAULT + } + return p.Success +} +func (p *EchoServiceEchoBidirectionalResult) SetSuccess(x interface{}) { + p.Success = x.(*EchoResponse) +} + +var fieldIDToName_EchoServiceEchoBidirectionalResult = map[int16]string{ + 0: "success", +} + +func (p *EchoServiceEchoBidirectionalResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *EchoServiceEchoBidirectionalResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoBidirectionalResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoBidirectionalResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = NewEchoResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *EchoServiceEchoBidirectionalResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoBidirectional_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *EchoServiceEchoBidirectionalResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *EchoServiceEchoBidirectionalResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("EchoServiceEchoBidirectionalResult(%+v)", *p) + +} + +func (p *EchoServiceEchoBidirectionalResult) DeepEqual(ano *EchoServiceEchoBidirectionalResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *EchoServiceEchoBidirectionalResult) Field0DeepEqual(src *EchoResponse) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type EchoServiceEchoClientArgs struct { + Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` +} + +func NewEchoServiceEchoClientArgs() *EchoServiceEchoClientArgs { + return &EchoServiceEchoClientArgs{} +} + +func (p *EchoServiceEchoClientArgs) InitDefault() { + *p = EchoServiceEchoClientArgs{} +} + +var EchoServiceEchoClientArgs_Req1_DEFAULT *EchoRequest + +func (p *EchoServiceEchoClientArgs) GetReq1() (v *EchoRequest) { + if !p.IsSetReq1() { + return EchoServiceEchoClientArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *EchoServiceEchoClientArgs) SetReq1(val *EchoRequest) { + p.Req1 = val +} + +var fieldIDToName_EchoServiceEchoClientArgs = map[int16]string{ + 1: "req1", +} + +func (p *EchoServiceEchoClientArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *EchoServiceEchoClientArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoClientArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoClientArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = NewEchoRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *EchoServiceEchoClientArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoClient_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *EchoServiceEchoClientArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *EchoServiceEchoClientArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("EchoServiceEchoClientArgs(%+v)", *p) + +} + +func (p *EchoServiceEchoClientArgs) DeepEqual(ano *EchoServiceEchoClientArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *EchoServiceEchoClientArgs) Field1DeepEqual(src *EchoRequest) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type EchoServiceEchoClientResult struct { + Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` +} + +func NewEchoServiceEchoClientResult() *EchoServiceEchoClientResult { + return &EchoServiceEchoClientResult{} +} + +func (p *EchoServiceEchoClientResult) InitDefault() { + *p = EchoServiceEchoClientResult{} +} + +var EchoServiceEchoClientResult_Success_DEFAULT *EchoResponse + +func (p *EchoServiceEchoClientResult) GetSuccess() (v *EchoResponse) { + if !p.IsSetSuccess() { + return EchoServiceEchoClientResult_Success_DEFAULT + } + return p.Success +} +func (p *EchoServiceEchoClientResult) SetSuccess(x interface{}) { + p.Success = x.(*EchoResponse) +} + +var fieldIDToName_EchoServiceEchoClientResult = map[int16]string{ + 0: "success", +} + +func (p *EchoServiceEchoClientResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *EchoServiceEchoClientResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoClientResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoClientResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = NewEchoResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *EchoServiceEchoClientResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoClient_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *EchoServiceEchoClientResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *EchoServiceEchoClientResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("EchoServiceEchoClientResult(%+v)", *p) + +} + +func (p *EchoServiceEchoClientResult) DeepEqual(ano *EchoServiceEchoClientResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *EchoServiceEchoClientResult) Field0DeepEqual(src *EchoResponse) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type EchoServiceEchoServerArgs struct { + Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` +} + +func NewEchoServiceEchoServerArgs() *EchoServiceEchoServerArgs { + return &EchoServiceEchoServerArgs{} +} + +func (p *EchoServiceEchoServerArgs) InitDefault() { + *p = EchoServiceEchoServerArgs{} +} + +var EchoServiceEchoServerArgs_Req1_DEFAULT *EchoRequest + +func (p *EchoServiceEchoServerArgs) GetReq1() (v *EchoRequest) { + if !p.IsSetReq1() { + return EchoServiceEchoServerArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *EchoServiceEchoServerArgs) SetReq1(val *EchoRequest) { + p.Req1 = val +} + +var fieldIDToName_EchoServiceEchoServerArgs = map[int16]string{ + 1: "req1", +} + +func (p *EchoServiceEchoServerArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *EchoServiceEchoServerArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoServerArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoServerArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = NewEchoRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *EchoServiceEchoServerArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoServer_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *EchoServiceEchoServerArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *EchoServiceEchoServerArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("EchoServiceEchoServerArgs(%+v)", *p) + +} + +func (p *EchoServiceEchoServerArgs) DeepEqual(ano *EchoServiceEchoServerArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *EchoServiceEchoServerArgs) Field1DeepEqual(src *EchoRequest) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type EchoServiceEchoServerResult struct { + Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` +} + +func NewEchoServiceEchoServerResult() *EchoServiceEchoServerResult { + return &EchoServiceEchoServerResult{} +} + +func (p *EchoServiceEchoServerResult) InitDefault() { + *p = EchoServiceEchoServerResult{} +} + +var EchoServiceEchoServerResult_Success_DEFAULT *EchoResponse + +func (p *EchoServiceEchoServerResult) GetSuccess() (v *EchoResponse) { + if !p.IsSetSuccess() { + return EchoServiceEchoServerResult_Success_DEFAULT + } + return p.Success +} +func (p *EchoServiceEchoServerResult) SetSuccess(x interface{}) { + p.Success = x.(*EchoResponse) +} + +var fieldIDToName_EchoServiceEchoServerResult = map[int16]string{ + 0: "success", +} + +func (p *EchoServiceEchoServerResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *EchoServiceEchoServerResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoServerResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoServerResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = NewEchoResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *EchoServiceEchoServerResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoServer_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *EchoServiceEchoServerResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *EchoServiceEchoServerResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("EchoServiceEchoServerResult(%+v)", *p) + +} + +func (p *EchoServiceEchoServerResult) DeepEqual(ano *EchoServiceEchoServerResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *EchoServiceEchoServerResult) Field0DeepEqual(src *EchoResponse) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type EchoServiceEchoUnaryArgs struct { + Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` +} + +func NewEchoServiceEchoUnaryArgs() *EchoServiceEchoUnaryArgs { + return &EchoServiceEchoUnaryArgs{} +} + +func (p *EchoServiceEchoUnaryArgs) InitDefault() { + *p = EchoServiceEchoUnaryArgs{} +} + +var EchoServiceEchoUnaryArgs_Req1_DEFAULT *EchoRequest + +func (p *EchoServiceEchoUnaryArgs) GetReq1() (v *EchoRequest) { + if !p.IsSetReq1() { + return EchoServiceEchoUnaryArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *EchoServiceEchoUnaryArgs) SetReq1(val *EchoRequest) { + p.Req1 = val +} + +var fieldIDToName_EchoServiceEchoUnaryArgs = map[int16]string{ + 1: "req1", +} + +func (p *EchoServiceEchoUnaryArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *EchoServiceEchoUnaryArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoUnaryArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoUnaryArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = NewEchoRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *EchoServiceEchoUnaryArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoUnary_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *EchoServiceEchoUnaryArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *EchoServiceEchoUnaryArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("EchoServiceEchoUnaryArgs(%+v)", *p) + +} + +func (p *EchoServiceEchoUnaryArgs) DeepEqual(ano *EchoServiceEchoUnaryArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *EchoServiceEchoUnaryArgs) Field1DeepEqual(src *EchoRequest) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type EchoServiceEchoUnaryResult struct { + Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` +} + +func NewEchoServiceEchoUnaryResult() *EchoServiceEchoUnaryResult { + return &EchoServiceEchoUnaryResult{} +} + +func (p *EchoServiceEchoUnaryResult) InitDefault() { + *p = EchoServiceEchoUnaryResult{} +} + +var EchoServiceEchoUnaryResult_Success_DEFAULT *EchoResponse + +func (p *EchoServiceEchoUnaryResult) GetSuccess() (v *EchoResponse) { + if !p.IsSetSuccess() { + return EchoServiceEchoUnaryResult_Success_DEFAULT + } + return p.Success +} +func (p *EchoServiceEchoUnaryResult) SetSuccess(x interface{}) { + p.Success = x.(*EchoResponse) +} + +var fieldIDToName_EchoServiceEchoUnaryResult = map[int16]string{ + 0: "success", +} + +func (p *EchoServiceEchoUnaryResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *EchoServiceEchoUnaryResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoUnaryResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoUnaryResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = NewEchoResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *EchoServiceEchoUnaryResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoUnary_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *EchoServiceEchoUnaryResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *EchoServiceEchoUnaryResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("EchoServiceEchoUnaryResult(%+v)", *p) + +} + +func (p *EchoServiceEchoUnaryResult) DeepEqual(ano *EchoServiceEchoUnaryResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *EchoServiceEchoUnaryResult) Field0DeepEqual(src *EchoResponse) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type EchoServiceEchoPingPongArgs struct { + Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` + Req2 *EchoRequest `thrift:"req2,2" frugal:"2,default,EchoRequest" json:"req2"` +} + +func NewEchoServiceEchoPingPongArgs() *EchoServiceEchoPingPongArgs { + return &EchoServiceEchoPingPongArgs{} +} + +func (p *EchoServiceEchoPingPongArgs) InitDefault() { + *p = EchoServiceEchoPingPongArgs{} +} + +var EchoServiceEchoPingPongArgs_Req1_DEFAULT *EchoRequest + +func (p *EchoServiceEchoPingPongArgs) GetReq1() (v *EchoRequest) { + if !p.IsSetReq1() { + return EchoServiceEchoPingPongArgs_Req1_DEFAULT + } + return p.Req1 +} + +var EchoServiceEchoPingPongArgs_Req2_DEFAULT *EchoRequest + +func (p *EchoServiceEchoPingPongArgs) GetReq2() (v *EchoRequest) { + if !p.IsSetReq2() { + return EchoServiceEchoPingPongArgs_Req2_DEFAULT + } + return p.Req2 +} +func (p *EchoServiceEchoPingPongArgs) SetReq1(val *EchoRequest) { + p.Req1 = val +} +func (p *EchoServiceEchoPingPongArgs) SetReq2(val *EchoRequest) { + p.Req2 = val +} + +var fieldIDToName_EchoServiceEchoPingPongArgs = map[int16]string{ + 1: "req1", + 2: "req2", +} + +func (p *EchoServiceEchoPingPongArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *EchoServiceEchoPingPongArgs) IsSetReq2() bool { + return p.Req2 != nil +} + +func (p *EchoServiceEchoPingPongArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoPingPongArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoPingPongArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = NewEchoRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} +func (p *EchoServiceEchoPingPongArgs) ReadField2(iprot thrift.TProtocol) error { + p.Req2 = NewEchoRequest() + if err := p.Req2.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *EchoServiceEchoPingPongArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoPingPong_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *EchoServiceEchoPingPongArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *EchoServiceEchoPingPongArgs) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req2", thrift.STRUCT, 2); err != nil { + goto WriteFieldBeginError + } + if err := p.Req2.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} + +func (p *EchoServiceEchoPingPongArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("EchoServiceEchoPingPongArgs(%+v)", *p) + +} + +func (p *EchoServiceEchoPingPongArgs) DeepEqual(ano *EchoServiceEchoPingPongArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + if !p.Field2DeepEqual(ano.Req2) { + return false + } + return true +} + +func (p *EchoServiceEchoPingPongArgs) Field1DeepEqual(src *EchoRequest) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} +func (p *EchoServiceEchoPingPongArgs) Field2DeepEqual(src *EchoRequest) bool { + + if !p.Req2.DeepEqual(src) { + return false + } + return true +} + +type EchoServiceEchoPingPongResult struct { + Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` + E *EchoException `thrift:"e,1,optional" frugal:"1,optional,EchoException" json:"e,omitempty"` +} + +func NewEchoServiceEchoPingPongResult() *EchoServiceEchoPingPongResult { + return &EchoServiceEchoPingPongResult{} +} + +func (p *EchoServiceEchoPingPongResult) InitDefault() { + *p = EchoServiceEchoPingPongResult{} +} + +var EchoServiceEchoPingPongResult_Success_DEFAULT *EchoResponse + +func (p *EchoServiceEchoPingPongResult) GetSuccess() (v *EchoResponse) { + if !p.IsSetSuccess() { + return EchoServiceEchoPingPongResult_Success_DEFAULT + } + return p.Success +} + +var EchoServiceEchoPingPongResult_E_DEFAULT *EchoException + +func (p *EchoServiceEchoPingPongResult) GetE() (v *EchoException) { + if !p.IsSetE() { + return EchoServiceEchoPingPongResult_E_DEFAULT + } + return p.E +} +func (p *EchoServiceEchoPingPongResult) SetSuccess(x interface{}) { + p.Success = x.(*EchoResponse) +} +func (p *EchoServiceEchoPingPongResult) SetE(val *EchoException) { + p.E = val +} + +var fieldIDToName_EchoServiceEchoPingPongResult = map[int16]string{ + 0: "success", + 1: "e", +} + +func (p *EchoServiceEchoPingPongResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *EchoServiceEchoPingPongResult) IsSetE() bool { + return p.E != nil +} + +func (p *EchoServiceEchoPingPongResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoPingPongResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoPingPongResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = NewEchoResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} +func (p *EchoServiceEchoPingPongResult) ReadField1(iprot thrift.TProtocol) error { + p.E = NewEchoException() + if err := p.E.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *EchoServiceEchoPingPongResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoPingPong_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *EchoServiceEchoPingPongResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *EchoServiceEchoPingPongResult) writeField1(oprot thrift.TProtocol) (err error) { + if p.IsSetE() { + if err = oprot.WriteFieldBegin("e", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.E.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *EchoServiceEchoPingPongResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("EchoServiceEchoPingPongResult(%+v)", *p) + +} + +func (p *EchoServiceEchoPingPongResult) DeepEqual(ano *EchoServiceEchoPingPongResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + if !p.Field1DeepEqual(ano.E) { + return false + } + return true +} + +func (p *EchoServiceEchoPingPongResult) Field0DeepEqual(src *EchoResponse) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} +func (p *EchoServiceEchoPingPongResult) Field1DeepEqual(src *EchoException) bool { + + if !p.E.DeepEqual(src) { + return false + } + return true +} + +type EchoServiceEchoOnewayArgs struct { + Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` +} + +func NewEchoServiceEchoOnewayArgs() *EchoServiceEchoOnewayArgs { + return &EchoServiceEchoOnewayArgs{} +} + +func (p *EchoServiceEchoOnewayArgs) InitDefault() { + *p = EchoServiceEchoOnewayArgs{} +} + +var EchoServiceEchoOnewayArgs_Req1_DEFAULT *EchoRequest + +func (p *EchoServiceEchoOnewayArgs) GetReq1() (v *EchoRequest) { + if !p.IsSetReq1() { + return EchoServiceEchoOnewayArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *EchoServiceEchoOnewayArgs) SetReq1(val *EchoRequest) { + p.Req1 = val +} + +var fieldIDToName_EchoServiceEchoOnewayArgs = map[int16]string{ + 1: "req1", +} + +func (p *EchoServiceEchoOnewayArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *EchoServiceEchoOnewayArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoOnewayArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoOnewayArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = NewEchoRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *EchoServiceEchoOnewayArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoOneway_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *EchoServiceEchoOnewayArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *EchoServiceEchoOnewayArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("EchoServiceEchoOnewayArgs(%+v)", *p) + +} + +func (p *EchoServiceEchoOnewayArgs) DeepEqual(ano *EchoServiceEchoOnewayArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *EchoServiceEchoOnewayArgs) Field1DeepEqual(src *EchoRequest) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type EchoServiceEchoOnewayResult struct { +} + +func NewEchoServiceEchoOnewayResult() *EchoServiceEchoOnewayResult { + return &EchoServiceEchoOnewayResult{} +} + +func (p *EchoServiceEchoOnewayResult) InitDefault() { + *p = EchoServiceEchoOnewayResult{} +} + +var fieldIDToName_EchoServiceEchoOnewayResult = map[int16]string{} + +func (p *EchoServiceEchoOnewayResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldTypeError + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +SkipFieldTypeError: + return thrift.PrependError(fmt.Sprintf("%T skip field type %d error", p, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoOnewayResult) Write(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteStructBegin("EchoOneway_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *EchoServiceEchoOnewayResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("EchoServiceEchoOnewayResult(%+v)", *p) + +} + +func (p *EchoServiceEchoOnewayResult) DeepEqual(ano *EchoServiceEchoOnewayResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + return true +} + +type EchoServicePingArgs struct { +} + +func NewEchoServicePingArgs() *EchoServicePingArgs { + return &EchoServicePingArgs{} +} + +func (p *EchoServicePingArgs) InitDefault() { + *p = EchoServicePingArgs{} +} + +var fieldIDToName_EchoServicePingArgs = map[int16]string{} + +func (p *EchoServicePingArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldTypeError + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +SkipFieldTypeError: + return thrift.PrependError(fmt.Sprintf("%T skip field type %d error", p, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServicePingArgs) Write(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteStructBegin("Ping_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *EchoServicePingArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("EchoServicePingArgs(%+v)", *p) + +} + +func (p *EchoServicePingArgs) DeepEqual(ano *EchoServicePingArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + return true +} + +type EchoServicePingResult struct { +} + +func NewEchoServicePingResult() *EchoServicePingResult { + return &EchoServicePingResult{} +} + +func (p *EchoServicePingResult) InitDefault() { + *p = EchoServicePingResult{} +} + +var fieldIDToName_EchoServicePingResult = map[int16]string{} + +func (p *EchoServicePingResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldTypeError + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +SkipFieldTypeError: + return thrift.PrependError(fmt.Sprintf("%T skip field type %d error", p, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServicePingResult) Write(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteStructBegin("Ping_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *EchoServicePingResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("EchoServicePingResult(%+v)", *p) + +} + +func (p *EchoServicePingResult) DeepEqual(ano *EchoServicePingResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + return true +} + +type PingPongOnlyServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler PingPongOnlyService +} + +func (p *PingPongOnlyServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *PingPongOnlyServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *PingPongOnlyServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewPingPongOnlyServiceProcessor(handler PingPongOnlyService) *PingPongOnlyServiceProcessor { + self := &PingPongOnlyServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self.AddToProcessorMap("EchoPingPongNew", &pingPongOnlyServiceProcessorEchoPingPongNew{handler: handler}) + return self +} +func (p *PingPongOnlyServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} + +type pingPongOnlyServiceProcessorEchoPingPongNew struct { + handler PingPongOnlyService +} + +func (p *pingPongOnlyServiceProcessorEchoPingPongNew) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := PingPongOnlyServiceEchoPingPongNewArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("EchoPingPongNew", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := PingPongOnlyServiceEchoPingPongNewResult{} + var retval *EchoResponse + if retval, err2 = p.handler.EchoPingPongNew(ctx, args.Req1); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoPingPongNew: "+err2.Error()) + oprot.WriteMessageBegin("EchoPingPongNew", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("EchoPingPongNew", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type PingPongOnlyServiceEchoPingPongNewArgs struct { + Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` +} + +func NewPingPongOnlyServiceEchoPingPongNewArgs() *PingPongOnlyServiceEchoPingPongNewArgs { + return &PingPongOnlyServiceEchoPingPongNewArgs{} +} + +func (p *PingPongOnlyServiceEchoPingPongNewArgs) InitDefault() { + *p = PingPongOnlyServiceEchoPingPongNewArgs{} +} + +var PingPongOnlyServiceEchoPingPongNewArgs_Req1_DEFAULT *EchoRequest + +func (p *PingPongOnlyServiceEchoPingPongNewArgs) GetReq1() (v *EchoRequest) { + if !p.IsSetReq1() { + return PingPongOnlyServiceEchoPingPongNewArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *PingPongOnlyServiceEchoPingPongNewArgs) SetReq1(val *EchoRequest) { + p.Req1 = val +} + +var fieldIDToName_PingPongOnlyServiceEchoPingPongNewArgs = map[int16]string{ + 1: "req1", +} + +func (p *PingPongOnlyServiceEchoPingPongNewArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *PingPongOnlyServiceEchoPingPongNewArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongNewArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongNewArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = NewEchoRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *PingPongOnlyServiceEchoPingPongNewArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoPingPongNew_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongNewArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongNewArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PingPongOnlyServiceEchoPingPongNewArgs(%+v)", *p) + +} + +func (p *PingPongOnlyServiceEchoPingPongNewArgs) DeepEqual(ano *PingPongOnlyServiceEchoPingPongNewArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *PingPongOnlyServiceEchoPingPongNewArgs) Field1DeepEqual(src *EchoRequest) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type PingPongOnlyServiceEchoPingPongNewResult struct { + Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` +} + +func NewPingPongOnlyServiceEchoPingPongNewResult() *PingPongOnlyServiceEchoPingPongNewResult { + return &PingPongOnlyServiceEchoPingPongNewResult{} +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) InitDefault() { + *p = PingPongOnlyServiceEchoPingPongNewResult{} +} + +var PingPongOnlyServiceEchoPingPongNewResult_Success_DEFAULT *EchoResponse + +func (p *PingPongOnlyServiceEchoPingPongNewResult) GetSuccess() (v *EchoResponse) { + if !p.IsSetSuccess() { + return PingPongOnlyServiceEchoPingPongNewResult_Success_DEFAULT + } + return p.Success +} +func (p *PingPongOnlyServiceEchoPingPongNewResult) SetSuccess(x interface{}) { + p.Success = x.(*EchoResponse) +} + +var fieldIDToName_PingPongOnlyServiceEchoPingPongNewResult = map[int16]string{ + 0: "success", +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongNewResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = NewEchoResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoPingPongNew_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PingPongOnlyServiceEchoPingPongNewResult(%+v)", *p) + +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) DeepEqual(ano *PingPongOnlyServiceEchoPingPongNewResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) Field0DeepEqual(src *EchoResponse) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type PingPongOnlyServiceChildProcessor struct { + *PingPongOnlyServiceProcessor +} + +func NewPingPongOnlyServiceChildProcessor(handler PingPongOnlyServiceChild) *PingPongOnlyServiceChildProcessor { + self := &PingPongOnlyServiceChildProcessor{NewPingPongOnlyServiceProcessor(handler)} + self.AddToProcessorMap("EchoBidirectionalExtended", &pingPongOnlyServiceChildProcessorEchoBidirectionalExtended{handler: handler}) + return self +} + +type pingPongOnlyServiceChildProcessorEchoBidirectionalExtended struct { + handler PingPongOnlyServiceChild +} + +func (p *pingPongOnlyServiceChildProcessorEchoBidirectionalExtended) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + panic("streaming method PingPongOnlyServiceChild.EchoBidirectionalExtended(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") +} + +type PingPongOnlyServiceChildEchoBidirectionalExtendedArgs struct { + Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` +} + +func NewPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs { + return &PingPongOnlyServiceChildEchoBidirectionalExtendedArgs{} +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) InitDefault() { + *p = PingPongOnlyServiceChildEchoBidirectionalExtendedArgs{} +} + +var PingPongOnlyServiceChildEchoBidirectionalExtendedArgs_Req1_DEFAULT *EchoRequest + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) GetReq1() (v *EchoRequest) { + if !p.IsSetReq1() { + return PingPongOnlyServiceChildEchoBidirectionalExtendedArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) SetReq1(val *EchoRequest) { + p.Req1 = val +} + +var fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedArgs = map[int16]string{ + 1: "req1", +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = NewEchoRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoBidirectionalExtended_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PingPongOnlyServiceChildEchoBidirectionalExtendedArgs(%+v)", *p) + +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) DeepEqual(ano *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) Field1DeepEqual(src *EchoRequest) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type PingPongOnlyServiceChildEchoBidirectionalExtendedResult struct { + Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` +} + +func NewPingPongOnlyServiceChildEchoBidirectionalExtendedResult() *PingPongOnlyServiceChildEchoBidirectionalExtendedResult { + return &PingPongOnlyServiceChildEchoBidirectionalExtendedResult{} +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) InitDefault() { + *p = PingPongOnlyServiceChildEchoBidirectionalExtendedResult{} +} + +var PingPongOnlyServiceChildEchoBidirectionalExtendedResult_Success_DEFAULT *EchoResponse + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) GetSuccess() (v *EchoResponse) { + if !p.IsSetSuccess() { + return PingPongOnlyServiceChildEchoBidirectionalExtendedResult_Success_DEFAULT + } + return p.Success +} +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) SetSuccess(x interface{}) { + p.Success = x.(*EchoResponse) +} + +var fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedResult = map[int16]string{ + 0: "success", +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = NewEchoResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoBidirectionalExtended_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PingPongOnlyServiceChildEchoBidirectionalExtendedResult(%+v)", *p) + +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) DeepEqual(ano *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) Field0DeepEqual(src *EchoResponse) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type PingPongOnlyServiceChildChildProcessor struct { + *PingPongOnlyServiceChildProcessor +} + +func NewPingPongOnlyServiceChildChildProcessor(handler PingPongOnlyServiceChildChild) *PingPongOnlyServiceChildChildProcessor { + self := &PingPongOnlyServiceChildChildProcessor{NewPingPongOnlyServiceChildProcessor(handler)} + return self +} + +type StreamOnlyServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler StreamOnlyService +} + +func (p *StreamOnlyServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *StreamOnlyServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *StreamOnlyServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewStreamOnlyServiceProcessor(handler StreamOnlyService) *StreamOnlyServiceProcessor { + self := &StreamOnlyServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self.AddToProcessorMap("EchoBidirectionalNew", &streamOnlyServiceProcessorEchoBidirectionalNew{handler: handler}) + return self +} +func (p *StreamOnlyServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} + +type streamOnlyServiceProcessorEchoBidirectionalNew struct { + handler StreamOnlyService +} + +func (p *streamOnlyServiceProcessorEchoBidirectionalNew) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + panic("streaming method StreamOnlyService.EchoBidirectionalNew(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") +} + +type StreamOnlyServiceEchoBidirectionalNewArgs struct { + Req1 *EchoRequest `thrift:"req1,1" frugal:"1,default,EchoRequest" json:"req1"` +} + +func NewStreamOnlyServiceEchoBidirectionalNewArgs() *StreamOnlyServiceEchoBidirectionalNewArgs { + return &StreamOnlyServiceEchoBidirectionalNewArgs{} +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) InitDefault() { + *p = StreamOnlyServiceEchoBidirectionalNewArgs{} +} + +var StreamOnlyServiceEchoBidirectionalNewArgs_Req1_DEFAULT *EchoRequest + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) GetReq1() (v *EchoRequest) { + if !p.IsSetReq1() { + return StreamOnlyServiceEchoBidirectionalNewArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) SetReq1(val *EchoRequest) { + p.Req1 = val +} + +var fieldIDToName_StreamOnlyServiceEchoBidirectionalNewArgs = map[int16]string{ + 1: "req1", +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalNewArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = NewEchoRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoBidirectionalNew_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalNewArgs(%+v)", *p) + +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) DeepEqual(ano *StreamOnlyServiceEchoBidirectionalNewArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) Field1DeepEqual(src *EchoRequest) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type StreamOnlyServiceEchoBidirectionalNewResult struct { + Success *EchoResponse `thrift:"success,0,optional" frugal:"0,optional,EchoResponse" json:"success,omitempty"` +} + +func NewStreamOnlyServiceEchoBidirectionalNewResult() *StreamOnlyServiceEchoBidirectionalNewResult { + return &StreamOnlyServiceEchoBidirectionalNewResult{} +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) InitDefault() { + *p = StreamOnlyServiceEchoBidirectionalNewResult{} +} + +var StreamOnlyServiceEchoBidirectionalNewResult_Success_DEFAULT *EchoResponse + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) GetSuccess() (v *EchoResponse) { + if !p.IsSetSuccess() { + return StreamOnlyServiceEchoBidirectionalNewResult_Success_DEFAULT + } + return p.Success +} +func (p *StreamOnlyServiceEchoBidirectionalNewResult) SetSuccess(x interface{}) { + p.Success = x.(*EchoResponse) +} + +var fieldIDToName_StreamOnlyServiceEchoBidirectionalNewResult = map[int16]string{ + 0: "success", +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalNewResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = NewEchoResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoBidirectionalNew_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("StreamOnlyServiceEchoBidirectionalNewResult(%+v)", *p) + +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) DeepEqual(ano *StreamOnlyServiceEchoBidirectionalNewResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) Field0DeepEqual(src *EchoResponse) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type StreamOnlyServiceChildProcessor struct { + *StreamOnlyServiceProcessor +} + +func NewStreamOnlyServiceChildProcessor(handler StreamOnlyServiceChild) *StreamOnlyServiceChildProcessor { + self := &StreamOnlyServiceChildProcessor{NewStreamOnlyServiceProcessor(handler)} + return self +} + +type StreamOnlyServiceChildChildProcessor struct { + *StreamOnlyServiceChildProcessor +} + +func NewStreamOnlyServiceChildChildProcessor(handler StreamOnlyServiceChildChild) *StreamOnlyServiceChildChildProcessor { + self := &StreamOnlyServiceChildChildProcessor{NewStreamOnlyServiceChildProcessor(handler)} + return self +} + +type ABCServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler ABCService +} + +func (p *ABCServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *ABCServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *ABCServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewABCServiceProcessor(handler ABCService) *ABCServiceProcessor { + self := &ABCServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self.AddToProcessorMap("Echo", &aBCServiceProcessorEcho{handler: handler}) + self.AddToProcessorMap("EchoBidirectional", &aBCServiceProcessorEchoBidirectional{handler: handler}) + self.AddToProcessorMap("EchoServer", &aBCServiceProcessorEchoServer{handler: handler}) + self.AddToProcessorMap("EchoClient", &aBCServiceProcessorEchoClient{handler: handler}) + self.AddToProcessorMap("EchoUnary", &aBCServiceProcessorEchoUnary{handler: handler}) + return self +} +func (p *ABCServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} + +type aBCServiceProcessorEcho struct { + handler ABCService +} + +func (p *aBCServiceProcessorEcho) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := ABCServiceEchoArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("Echo", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := ABCServiceEchoResult{} + var retval *c.Response + if retval, err2 = p.handler.Echo(ctx, args.Req1, args.Req2); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Echo: "+err2.Error()) + oprot.WriteMessageBegin("Echo", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("Echo", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type aBCServiceProcessorEchoBidirectional struct { + handler ABCService +} + +func (p *aBCServiceProcessorEchoBidirectional) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + panic("streaming method ABCService.EchoBidirectional(mode = bidirectional) not available, please use Kitex Thrift Streaming Client.") +} + +type aBCServiceProcessorEchoServer struct { + handler ABCService +} + +func (p *aBCServiceProcessorEchoServer) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + panic("streaming method ABCService.EchoServer(mode = server) not available, please use Kitex Thrift Streaming Client.") +} + +type aBCServiceProcessorEchoClient struct { + handler ABCService +} + +func (p *aBCServiceProcessorEchoClient) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + panic("streaming method ABCService.EchoClient(mode = client) not available, please use Kitex Thrift Streaming Client.") +} + +type aBCServiceProcessorEchoUnary struct { + handler ABCService +} + +func (p *aBCServiceProcessorEchoUnary) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + panic("streaming method ABCService.EchoUnary(mode = unary) not available, please use Kitex Thrift Streaming Client.") +} + +type ABCServiceEchoArgs struct { + Req1 *c.Request `thrift:"req1,1" frugal:"1,default,c.Request" json:"req1"` + Req2 *c.Request `thrift:"req2,2" frugal:"2,default,c.Request" json:"req2"` +} + +func NewABCServiceEchoArgs() *ABCServiceEchoArgs { + return &ABCServiceEchoArgs{} +} + +func (p *ABCServiceEchoArgs) InitDefault() { + *p = ABCServiceEchoArgs{} +} + +var ABCServiceEchoArgs_Req1_DEFAULT *c.Request + +func (p *ABCServiceEchoArgs) GetReq1() (v *c.Request) { + if !p.IsSetReq1() { + return ABCServiceEchoArgs_Req1_DEFAULT + } + return p.Req1 +} + +var ABCServiceEchoArgs_Req2_DEFAULT *c.Request + +func (p *ABCServiceEchoArgs) GetReq2() (v *c.Request) { + if !p.IsSetReq2() { + return ABCServiceEchoArgs_Req2_DEFAULT + } + return p.Req2 +} +func (p *ABCServiceEchoArgs) SetReq1(val *c.Request) { + p.Req1 = val +} +func (p *ABCServiceEchoArgs) SetReq2(val *c.Request) { + p.Req2 = val +} + +var fieldIDToName_ABCServiceEchoArgs = map[int16]string{ + 1: "req1", + 2: "req2", +} + +func (p *ABCServiceEchoArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *ABCServiceEchoArgs) IsSetReq2() bool { + return p.Req2 != nil +} + +func (p *ABCServiceEchoArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = c.NewRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} +func (p *ABCServiceEchoArgs) ReadField2(iprot thrift.TProtocol) error { + p.Req2 = c.NewRequest() + if err := p.Req2.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Echo_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *ABCServiceEchoArgs) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req2", thrift.STRUCT, 2); err != nil { + goto WriteFieldBeginError + } + if err := p.Req2.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} + +func (p *ABCServiceEchoArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoArgs(%+v)", *p) + +} + +func (p *ABCServiceEchoArgs) DeepEqual(ano *ABCServiceEchoArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + if !p.Field2DeepEqual(ano.Req2) { + return false + } + return true +} + +func (p *ABCServiceEchoArgs) Field1DeepEqual(src *c.Request) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} +func (p *ABCServiceEchoArgs) Field2DeepEqual(src *c.Request) bool { + + if !p.Req2.DeepEqual(src) { + return false + } + return true +} + +type ABCServiceEchoResult struct { + Success *c.Response `thrift:"success,0,optional" frugal:"0,optional,c.Response" json:"success,omitempty"` +} + +func NewABCServiceEchoResult() *ABCServiceEchoResult { + return &ABCServiceEchoResult{} +} + +func (p *ABCServiceEchoResult) InitDefault() { + *p = ABCServiceEchoResult{} +} + +var ABCServiceEchoResult_Success_DEFAULT *c.Response + +func (p *ABCServiceEchoResult) GetSuccess() (v *c.Response) { + if !p.IsSetSuccess() { + return ABCServiceEchoResult_Success_DEFAULT + } + return p.Success +} +func (p *ABCServiceEchoResult) SetSuccess(x interface{}) { + p.Success = x.(*c.Response) +} + +var fieldIDToName_ABCServiceEchoResult = map[int16]string{ + 0: "success", +} + +func (p *ABCServiceEchoResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ABCServiceEchoResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = c.NewResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Echo_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *ABCServiceEchoResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoResult(%+v)", *p) + +} + +func (p *ABCServiceEchoResult) DeepEqual(ano *ABCServiceEchoResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *ABCServiceEchoResult) Field0DeepEqual(src *c.Response) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type ABCServiceEchoBidirectionalArgs struct { + Req1 *c.Request `thrift:"req1,1" frugal:"1,default,c.Request" json:"req1"` +} + +func NewABCServiceEchoBidirectionalArgs() *ABCServiceEchoBidirectionalArgs { + return &ABCServiceEchoBidirectionalArgs{} +} + +func (p *ABCServiceEchoBidirectionalArgs) InitDefault() { + *p = ABCServiceEchoBidirectionalArgs{} +} + +var ABCServiceEchoBidirectionalArgs_Req1_DEFAULT *c.Request + +func (p *ABCServiceEchoBidirectionalArgs) GetReq1() (v *c.Request) { + if !p.IsSetReq1() { + return ABCServiceEchoBidirectionalArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *ABCServiceEchoBidirectionalArgs) SetReq1(val *c.Request) { + p.Req1 = val +} + +var fieldIDToName_ABCServiceEchoBidirectionalArgs = map[int16]string{ + 1: "req1", +} + +func (p *ABCServiceEchoBidirectionalArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *ABCServiceEchoBidirectionalArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoBidirectionalArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoBidirectionalArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = c.NewRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoBidirectionalArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoBidirectional_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoBidirectionalArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *ABCServiceEchoBidirectionalArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoBidirectionalArgs(%+v)", *p) + +} + +func (p *ABCServiceEchoBidirectionalArgs) DeepEqual(ano *ABCServiceEchoBidirectionalArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *ABCServiceEchoBidirectionalArgs) Field1DeepEqual(src *c.Request) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type ABCServiceEchoBidirectionalResult struct { + Success *c.Response `thrift:"success,0,optional" frugal:"0,optional,c.Response" json:"success,omitempty"` +} + +func NewABCServiceEchoBidirectionalResult() *ABCServiceEchoBidirectionalResult { + return &ABCServiceEchoBidirectionalResult{} +} + +func (p *ABCServiceEchoBidirectionalResult) InitDefault() { + *p = ABCServiceEchoBidirectionalResult{} +} + +var ABCServiceEchoBidirectionalResult_Success_DEFAULT *c.Response + +func (p *ABCServiceEchoBidirectionalResult) GetSuccess() (v *c.Response) { + if !p.IsSetSuccess() { + return ABCServiceEchoBidirectionalResult_Success_DEFAULT + } + return p.Success +} +func (p *ABCServiceEchoBidirectionalResult) SetSuccess(x interface{}) { + p.Success = x.(*c.Response) +} + +var fieldIDToName_ABCServiceEchoBidirectionalResult = map[int16]string{ + 0: "success", +} + +func (p *ABCServiceEchoBidirectionalResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ABCServiceEchoBidirectionalResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoBidirectionalResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoBidirectionalResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = c.NewResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoBidirectionalResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoBidirectional_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoBidirectionalResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *ABCServiceEchoBidirectionalResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoBidirectionalResult(%+v)", *p) + +} + +func (p *ABCServiceEchoBidirectionalResult) DeepEqual(ano *ABCServiceEchoBidirectionalResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *ABCServiceEchoBidirectionalResult) Field0DeepEqual(src *c.Response) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type ABCServiceEchoServerArgs struct { + Req1 *c.Request `thrift:"req1,1" frugal:"1,default,c.Request" json:"req1"` +} + +func NewABCServiceEchoServerArgs() *ABCServiceEchoServerArgs { + return &ABCServiceEchoServerArgs{} +} + +func (p *ABCServiceEchoServerArgs) InitDefault() { + *p = ABCServiceEchoServerArgs{} +} + +var ABCServiceEchoServerArgs_Req1_DEFAULT *c.Request + +func (p *ABCServiceEchoServerArgs) GetReq1() (v *c.Request) { + if !p.IsSetReq1() { + return ABCServiceEchoServerArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *ABCServiceEchoServerArgs) SetReq1(val *c.Request) { + p.Req1 = val +} + +var fieldIDToName_ABCServiceEchoServerArgs = map[int16]string{ + 1: "req1", +} + +func (p *ABCServiceEchoServerArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *ABCServiceEchoServerArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoServerArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoServerArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = c.NewRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoServerArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoServer_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoServerArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *ABCServiceEchoServerArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoServerArgs(%+v)", *p) + +} + +func (p *ABCServiceEchoServerArgs) DeepEqual(ano *ABCServiceEchoServerArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *ABCServiceEchoServerArgs) Field1DeepEqual(src *c.Request) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type ABCServiceEchoServerResult struct { + Success *c.Response `thrift:"success,0,optional" frugal:"0,optional,c.Response" json:"success,omitempty"` +} + +func NewABCServiceEchoServerResult() *ABCServiceEchoServerResult { + return &ABCServiceEchoServerResult{} +} + +func (p *ABCServiceEchoServerResult) InitDefault() { + *p = ABCServiceEchoServerResult{} +} + +var ABCServiceEchoServerResult_Success_DEFAULT *c.Response + +func (p *ABCServiceEchoServerResult) GetSuccess() (v *c.Response) { + if !p.IsSetSuccess() { + return ABCServiceEchoServerResult_Success_DEFAULT + } + return p.Success +} +func (p *ABCServiceEchoServerResult) SetSuccess(x interface{}) { + p.Success = x.(*c.Response) +} + +var fieldIDToName_ABCServiceEchoServerResult = map[int16]string{ + 0: "success", +} + +func (p *ABCServiceEchoServerResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ABCServiceEchoServerResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoServerResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoServerResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = c.NewResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoServerResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoServer_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoServerResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *ABCServiceEchoServerResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoServerResult(%+v)", *p) + +} + +func (p *ABCServiceEchoServerResult) DeepEqual(ano *ABCServiceEchoServerResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *ABCServiceEchoServerResult) Field0DeepEqual(src *c.Response) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type ABCServiceEchoClientArgs struct { + Req1 *c.Request `thrift:"req1,1" frugal:"1,default,c.Request" json:"req1"` +} + +func NewABCServiceEchoClientArgs() *ABCServiceEchoClientArgs { + return &ABCServiceEchoClientArgs{} +} + +func (p *ABCServiceEchoClientArgs) InitDefault() { + *p = ABCServiceEchoClientArgs{} +} + +var ABCServiceEchoClientArgs_Req1_DEFAULT *c.Request + +func (p *ABCServiceEchoClientArgs) GetReq1() (v *c.Request) { + if !p.IsSetReq1() { + return ABCServiceEchoClientArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *ABCServiceEchoClientArgs) SetReq1(val *c.Request) { + p.Req1 = val +} + +var fieldIDToName_ABCServiceEchoClientArgs = map[int16]string{ + 1: "req1", +} + +func (p *ABCServiceEchoClientArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *ABCServiceEchoClientArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoClientArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoClientArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = c.NewRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoClientArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoClient_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoClientArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *ABCServiceEchoClientArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoClientArgs(%+v)", *p) + +} + +func (p *ABCServiceEchoClientArgs) DeepEqual(ano *ABCServiceEchoClientArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *ABCServiceEchoClientArgs) Field1DeepEqual(src *c.Request) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type ABCServiceEchoClientResult struct { + Success *c.Response `thrift:"success,0,optional" frugal:"0,optional,c.Response" json:"success,omitempty"` +} + +func NewABCServiceEchoClientResult() *ABCServiceEchoClientResult { + return &ABCServiceEchoClientResult{} +} + +func (p *ABCServiceEchoClientResult) InitDefault() { + *p = ABCServiceEchoClientResult{} +} + +var ABCServiceEchoClientResult_Success_DEFAULT *c.Response + +func (p *ABCServiceEchoClientResult) GetSuccess() (v *c.Response) { + if !p.IsSetSuccess() { + return ABCServiceEchoClientResult_Success_DEFAULT + } + return p.Success +} +func (p *ABCServiceEchoClientResult) SetSuccess(x interface{}) { + p.Success = x.(*c.Response) +} + +var fieldIDToName_ABCServiceEchoClientResult = map[int16]string{ + 0: "success", +} + +func (p *ABCServiceEchoClientResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ABCServiceEchoClientResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoClientResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoClientResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = c.NewResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoClientResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoClient_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoClientResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *ABCServiceEchoClientResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoClientResult(%+v)", *p) + +} + +func (p *ABCServiceEchoClientResult) DeepEqual(ano *ABCServiceEchoClientResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *ABCServiceEchoClientResult) Field0DeepEqual(src *c.Response) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type ABCServiceEchoUnaryArgs struct { + Req1 *c.Request `thrift:"req1,1" frugal:"1,default,c.Request" json:"req1"` +} + +func NewABCServiceEchoUnaryArgs() *ABCServiceEchoUnaryArgs { + return &ABCServiceEchoUnaryArgs{} +} + +func (p *ABCServiceEchoUnaryArgs) InitDefault() { + *p = ABCServiceEchoUnaryArgs{} +} + +var ABCServiceEchoUnaryArgs_Req1_DEFAULT *c.Request + +func (p *ABCServiceEchoUnaryArgs) GetReq1() (v *c.Request) { + if !p.IsSetReq1() { + return ABCServiceEchoUnaryArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *ABCServiceEchoUnaryArgs) SetReq1(val *c.Request) { + p.Req1 = val +} + +var fieldIDToName_ABCServiceEchoUnaryArgs = map[int16]string{ + 1: "req1", +} + +func (p *ABCServiceEchoUnaryArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *ABCServiceEchoUnaryArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoUnaryArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoUnaryArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = c.NewRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoUnaryArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoUnary_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoUnaryArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *ABCServiceEchoUnaryArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoUnaryArgs(%+v)", *p) + +} + +func (p *ABCServiceEchoUnaryArgs) DeepEqual(ano *ABCServiceEchoUnaryArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *ABCServiceEchoUnaryArgs) Field1DeepEqual(src *c.Request) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type ABCServiceEchoUnaryResult struct { + Success *c.Response `thrift:"success,0,optional" frugal:"0,optional,c.Response" json:"success,omitempty"` +} + +func NewABCServiceEchoUnaryResult() *ABCServiceEchoUnaryResult { + return &ABCServiceEchoUnaryResult{} +} + +func (p *ABCServiceEchoUnaryResult) InitDefault() { + *p = ABCServiceEchoUnaryResult{} +} + +var ABCServiceEchoUnaryResult_Success_DEFAULT *c.Response + +func (p *ABCServiceEchoUnaryResult) GetSuccess() (v *c.Response) { + if !p.IsSetSuccess() { + return ABCServiceEchoUnaryResult_Success_DEFAULT + } + return p.Success +} +func (p *ABCServiceEchoUnaryResult) SetSuccess(x interface{}) { + p.Success = x.(*c.Response) +} + +var fieldIDToName_ABCServiceEchoUnaryResult = map[int16]string{ + 0: "success", +} + +func (p *ABCServiceEchoUnaryResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ABCServiceEchoUnaryResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoUnaryResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoUnaryResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = c.NewResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoUnaryResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoUnary_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoUnaryResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *ABCServiceEchoUnaryResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoUnaryResult(%+v)", *p) + +} + +func (p *ABCServiceEchoUnaryResult) DeepEqual(ano *ABCServiceEchoUnaryResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *ABCServiceEchoUnaryResult) Field0DeepEqual(src *c.Response) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} diff --git a/thrift_streaming/kitex_gen/echo/echoservice/client.go b/thrift_streaming/kitex_gen/echo/echoservice/client.go new file mode 100644 index 0000000..f50d2b8 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/echoservice/client.go @@ -0,0 +1,140 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package echoservice + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, req2 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) + EchoOneway(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (err error) + Ping(ctx context.Context, callOptions ...callopt.Option) (err error) +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectional(ctx context.Context, callOptions ...streamcall.Option) (stream EchoService_EchoBidirectionalClient, err error) + EchoClient(ctx context.Context, callOptions ...streamcall.Option) (stream EchoService_EchoClientClient, err error) + EchoServer(ctx context.Context, req1 *echo.EchoRequest, callOptions ...streamcall.Option) (stream EchoService_EchoServerClient, err error) + EchoUnary(ctx context.Context, req1 *echo.EchoRequest, callOptions ...streamcall.Option) (r *echo.EchoResponse, err error) +} + +type EchoService_EchoBidirectionalClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +type EchoService_EchoClientClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + CloseAndRecv() (*echo.EchoResponse, error) +} + +type EchoService_EchoServerClient interface { + streaming.Stream + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kEchoServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kEchoServiceClient struct { + *kClient +} + +func (p *kEchoServiceClient) EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, req2 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPong(ctx, req1, req2) +} + +func (p *kEchoServiceClient) EchoOneway(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoOneway(ctx, req1) +} + +func (p *kEchoServiceClient) Ping(ctx context.Context, callOptions ...callopt.Option) (err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.Ping(ctx) +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kEchoServiceStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kEchoServiceStreamClient struct { + *kClient +} + +func (p *kEchoServiceStreamClient) EchoBidirectional(ctx context.Context, callOptions ...streamcall.Option) (stream EchoService_EchoBidirectionalClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectional(ctx) +} + +func (p *kEchoServiceStreamClient) EchoClient(ctx context.Context, callOptions ...streamcall.Option) (stream EchoService_EchoClientClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoClient(ctx) +} + +func (p *kEchoServiceStreamClient) EchoServer(ctx context.Context, req1 *echo.EchoRequest, callOptions ...streamcall.Option) (stream EchoService_EchoServerClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoServer(ctx, req1) +} + +func (p *kEchoServiceStreamClient) EchoUnary(ctx context.Context, req1 *echo.EchoRequest, callOptions ...streamcall.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoUnary(ctx, req1) +} diff --git a/thrift_streaming/kitex_gen/echo/echoservice/echoservice.go b/thrift_streaming/kitex_gen/echo/echoservice/echoservice.go new file mode 100644 index 0000000..ddd8b3e --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/echoservice/echoservice.go @@ -0,0 +1,440 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package echoservice + +import ( + "context" + "errors" + "fmt" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoBidirectional": kitex.NewMethodInfo( + echoBidirectionalHandler, + newEchoServiceEchoBidirectionalArgs, + newEchoServiceEchoBidirectionalResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), + "EchoClient": kitex.NewMethodInfo( + echoClientHandler, + newEchoServiceEchoClientArgs, + newEchoServiceEchoClientResult, + false, + kitex.WithStreamingMode(kitex.StreamingClient), + ), + "EchoServer": kitex.NewMethodInfo( + echoServerHandler, + newEchoServiceEchoServerArgs, + newEchoServiceEchoServerResult, + false, + kitex.WithStreamingMode(kitex.StreamingServer), + ), + "EchoUnary": kitex.NewMethodInfo( + echoUnaryHandler, + newEchoServiceEchoUnaryArgs, + newEchoServiceEchoUnaryResult, + false, + kitex.WithStreamingMode(kitex.StreamingUnary), + ), + "EchoPingPong": kitex.NewMethodInfo( + echoPingPongHandler, + newEchoServiceEchoPingPongArgs, + newEchoServiceEchoPingPongResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "EchoOneway": kitex.NewMethodInfo( + echoOnewayHandler, + newEchoServiceEchoOnewayArgs, + newEchoServiceEchoOnewayResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "Ping": kitex.NewMethodInfo( + pingHandler, + newEchoServicePingArgs, + newEchoServicePingResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), +} + +var ( + echoServiceServiceInfo = NewServiceInfo() + echoServiceServiceInfoForClient = NewServiceInfoForClient() + echoServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return echoServiceServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return echoServiceServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return echoServiceServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "EchoService" + handlerType := (*echo.EchoService)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "echo", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoBidirectionalHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("EchoService.EchoBidirectional is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &echoServiceEchoBidirectionalServer{st.Stream} + return handler.(echo.EchoService).EchoBidirectional(stream) +} + +type echoServiceEchoBidirectionalClient struct { + streaming.Stream +} + +func (x *echoServiceEchoBidirectionalClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *echoServiceEchoBidirectionalClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type echoServiceEchoBidirectionalServer struct { + streaming.Stream +} + +func (x *echoServiceEchoBidirectionalServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *echoServiceEchoBidirectionalServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newEchoServiceEchoBidirectionalArgs() interface{} { + return echo.NewEchoServiceEchoBidirectionalArgs() +} + +func newEchoServiceEchoBidirectionalResult() interface{} { + return echo.NewEchoServiceEchoBidirectionalResult() +} + +func echoClientHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("EchoService.EchoClient is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &echoServiceEchoClientServer{st.Stream} + return handler.(echo.EchoService).EchoClient(stream) +} + +type echoServiceEchoClientClient struct { + streaming.Stream +} + +func (x *echoServiceEchoClientClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *echoServiceEchoClientClient) CloseAndRecv() (*echo.EchoResponse, error) { + if err := x.Stream.Close(); err != nil { + return nil, err + } + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type echoServiceEchoClientServer struct { + streaming.Stream +} + +func (x *echoServiceEchoClientServer) SendAndClose(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *echoServiceEchoClientServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newEchoServiceEchoClientArgs() interface{} { + return echo.NewEchoServiceEchoClientArgs() +} + +func newEchoServiceEchoClientResult() interface{} { + return echo.NewEchoServiceEchoClientResult() +} + +func echoServerHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("EchoService.EchoServer is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &echoServiceEchoServerServer{st.Stream} + req := new(echo.EchoRequest) + if err := st.Stream.RecvMsg(req); err != nil { + return err + } + return handler.(echo.EchoService).EchoServer(req, stream) +} + +type echoServiceEchoServerClient struct { + streaming.Stream +} + +func (x *echoServiceEchoServerClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type echoServiceEchoServerServer struct { + streaming.Stream +} + +func (x *echoServiceEchoServerServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func newEchoServiceEchoServerArgs() interface{} { + return echo.NewEchoServiceEchoServerArgs() +} + +func newEchoServiceEchoServerResult() interface{} { + return echo.NewEchoServiceEchoServerResult() +} + +func echoUnaryHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + if streaming.GetStream(ctx) == nil { + return errors.New("EchoService.EchoUnary is a thrift streaming unary method, please call with Kitex StreamClient or remove the annotation streaming.mode") + } + realArg := arg.(*echo.EchoServiceEchoUnaryArgs) + realResult := result.(*echo.EchoServiceEchoUnaryResult) + success, err := handler.(echo.EchoService).EchoUnary(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newEchoServiceEchoUnaryArgs() interface{} { + return echo.NewEchoServiceEchoUnaryArgs() +} + +func newEchoServiceEchoUnaryResult() interface{} { + return echo.NewEchoServiceEchoUnaryResult() +} + +func echoPingPongHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.EchoServiceEchoPingPongArgs) + realResult := result.(*echo.EchoServiceEchoPingPongResult) + success, err := handler.(echo.EchoService).EchoPingPong(ctx, realArg.Req1, realArg.Req2) + if err != nil { + switch v := err.(type) { + case *echo.EchoException: + realResult.E = v + default: + return err + } + } else { + realResult.Success = success + } + return nil +} +func newEchoServiceEchoPingPongArgs() interface{} { + return echo.NewEchoServiceEchoPingPongArgs() +} + +func newEchoServiceEchoPingPongResult() interface{} { + return echo.NewEchoServiceEchoPingPongResult() +} + +func echoOnewayHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.EchoServiceEchoOnewayArgs) + + err := handler.(echo.EchoService).EchoOneway(ctx, realArg.Req1) + if err != nil { + return err + } + + return nil +} +func newEchoServiceEchoOnewayArgs() interface{} { + return echo.NewEchoServiceEchoOnewayArgs() +} + +func newEchoServiceEchoOnewayResult() interface{} { + return echo.NewEchoServiceEchoOnewayResult() +} + +func pingHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + _ = arg.(*echo.EchoServicePingArgs) + + err := handler.(echo.EchoService).Ping(ctx) + if err != nil { + return err + } + + return nil +} +func newEchoServicePingArgs() interface{} { + return echo.NewEchoServicePingArgs() +} + +func newEchoServicePingResult() interface{} { + return echo.NewEchoServicePingResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoBidirectional(ctx context.Context) (EchoService_EchoBidirectionalClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectional", nil, res) + if err != nil { + return nil, err + } + stream := &echoServiceEchoBidirectionalClient{res.Stream} + return stream, nil +} + +func (p *kClient) EchoClient(ctx context.Context) (EchoService_EchoClientClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoClient", nil, res) + if err != nil { + return nil, err + } + stream := &echoServiceEchoClientClient{res.Stream} + return stream, nil +} + +func (p *kClient) EchoServer(ctx context.Context, req1 *echo.EchoRequest) (EchoService_EchoServerClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoServer", nil, res) + if err != nil { + return nil, err + } + stream := &echoServiceEchoServerClient{res.Stream} + + if err := stream.Stream.SendMsg(req1); err != nil { + return nil, err + } + if err := stream.Stream.Close(); err != nil { + return nil, err + } + return stream, nil +} + +func (p *kClient) EchoUnary(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.EchoServiceEchoUnaryArgs + _args.Req1 = req1 + var _result echo.EchoServiceEchoUnaryResult + if err = p.c.Call(ctx, "EchoUnary", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) EchoPingPong(ctx context.Context, req1 *echo.EchoRequest, req2 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.EchoServiceEchoPingPongArgs + _args.Req1 = req1 + _args.Req2 = req2 + var _result echo.EchoServiceEchoPingPongResult + if err = p.c.Call(ctx, "EchoPingPong", &_args, &_result); err != nil { + return + } + switch { + case _result.E != nil: + return r, _result.E + } + return _result.GetSuccess(), nil +} + +func (p *kClient) EchoOneway(ctx context.Context, req1 *echo.EchoRequest) (err error) { + var _args echo.EchoServiceEchoOnewayArgs + _args.Req1 = req1 + var _result echo.EchoServiceEchoOnewayResult + if err = p.c.Call(ctx, "EchoOneway", &_args, &_result); err != nil { + return + } + return nil +} + +func (p *kClient) Ping(ctx context.Context) (err error) { + var _args echo.EchoServicePingArgs + var _result echo.EchoServicePingResult + if err = p.c.Call(ctx, "Ping", &_args, &_result); err != nil { + return + } + return nil +} diff --git a/thrift_streaming/kitex_gen/echo/echoservice/invoker.go b/thrift_streaming/kitex_gen/echo/echoservice/invoker.go new file mode 100644 index 0000000..43818c6 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/echoservice/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package echoservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.EchoService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/echo/echoservice/server.go b/thrift_streaming/kitex_gen/echo/echoservice/server.go new file mode 100644 index 0000000..c634884 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/echoservice/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package echoservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.EchoService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/echo/k-api.go b/thrift_streaming/kitex_gen/echo/k-api.go new file mode 100644 index 0000000..fa4c1fc --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/k-api.go @@ -0,0 +1,4404 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package echo + +import ( + "bytes" + "fmt" + "reflect" + "strings" + + "github.com/apache/thrift/lib/go/thrift" + + "github.com/cloudwego/kitex/pkg/protocol/bthrift" + + "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/a/b/c" +) + +// unused protection +var ( + _ = fmt.Formatter(nil) + _ = (*bytes.Buffer)(nil) + _ = (*strings.Builder)(nil) + _ = reflect.Type(nil) + _ = thrift.TProtocol(nil) + _ = bthrift.BinaryWriter(nil) + _ = c.KitexUnusedProtection +) + +func (p *EchoRequest) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + var issetMessage bool = false + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + issetMessage = true + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + if !issetMessage { + fieldId = 1 + goto RequiredFieldNotSetError + } + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoRequest[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +RequiredFieldNotSetError: + return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_EchoRequest[fieldId])) +} + +func (p *EchoRequest) FastReadField1(buf []byte) (int, error) { + offset := 0 + + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.Message = v + + } + return offset, nil +} + +// for compatibility +func (p *EchoRequest) FastWrite(buf []byte) int { + return 0 +} + +func (p *EchoRequest) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoRequest") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *EchoRequest) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoRequest") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *EchoRequest) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) + + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *EchoRequest) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) + l += bthrift.Binary.StringLengthNocopy(p.Message) + + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *EchoResponse) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + var issetMessage bool = false + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + issetMessage = true + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + if !issetMessage { + fieldId = 1 + goto RequiredFieldNotSetError + } + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoResponse[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +RequiredFieldNotSetError: + return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_EchoResponse[fieldId])) +} + +func (p *EchoResponse) FastReadField1(buf []byte) (int, error) { + offset := 0 + + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.Message = v + + } + return offset, nil +} + +// for compatibility +func (p *EchoResponse) FastWrite(buf []byte) int { + return 0 +} + +func (p *EchoResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoResponse") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *EchoResponse) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoResponse") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *EchoResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) + + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *EchoResponse) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) + l += bthrift.Binary.StringLengthNocopy(p.Message) + + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *EchoException) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoException[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoException) FastReadField1(buf []byte) (int, error) { + offset := 0 + + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.Message = v + + } + return offset, nil +} + +// for compatibility +func (p *EchoException) FastWrite(buf []byte) int { + return 0 +} + +func (p *EchoException) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoException") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *EchoException) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoException") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *EchoException) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) + + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *EchoException) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) + l += bthrift.Binary.StringLengthNocopy(p.Message) + + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *EchoServiceEchoBidirectionalArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoBidirectionalArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoBidirectionalArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *EchoServiceEchoBidirectionalArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *EchoServiceEchoBidirectionalArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectional_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *EchoServiceEchoBidirectionalArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoBidirectional_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *EchoServiceEchoBidirectionalArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *EchoServiceEchoBidirectionalArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *EchoServiceEchoBidirectionalResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoBidirectionalResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoBidirectionalResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *EchoServiceEchoBidirectionalResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *EchoServiceEchoBidirectionalResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectional_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *EchoServiceEchoBidirectionalResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoBidirectional_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *EchoServiceEchoBidirectionalResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *EchoServiceEchoBidirectionalResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *EchoServiceEchoClientArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoClientArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoClientArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *EchoServiceEchoClientArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *EchoServiceEchoClientArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoClient_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *EchoServiceEchoClientArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoClient_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *EchoServiceEchoClientArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *EchoServiceEchoClientArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *EchoServiceEchoClientResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoClientResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoClientResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *EchoServiceEchoClientResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *EchoServiceEchoClientResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoClient_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *EchoServiceEchoClientResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoClient_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *EchoServiceEchoClientResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *EchoServiceEchoClientResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *EchoServiceEchoServerArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoServerArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoServerArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *EchoServiceEchoServerArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *EchoServiceEchoServerArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoServer_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *EchoServiceEchoServerArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoServer_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *EchoServiceEchoServerArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *EchoServiceEchoServerArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *EchoServiceEchoServerResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoServerResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoServerResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *EchoServiceEchoServerResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *EchoServiceEchoServerResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoServer_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *EchoServiceEchoServerResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoServer_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *EchoServiceEchoServerResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *EchoServiceEchoServerResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *EchoServiceEchoUnaryArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoUnaryArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoUnaryArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *EchoServiceEchoUnaryArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *EchoServiceEchoUnaryArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoUnary_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *EchoServiceEchoUnaryArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoUnary_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *EchoServiceEchoUnaryArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *EchoServiceEchoUnaryArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *EchoServiceEchoUnaryResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoUnaryResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoUnaryResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *EchoServiceEchoUnaryResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *EchoServiceEchoUnaryResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoUnary_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *EchoServiceEchoUnaryResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoUnary_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *EchoServiceEchoUnaryResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *EchoServiceEchoUnaryResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *EchoServiceEchoPingPongArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + case 2: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField2(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoPingPongArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoPingPongArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +func (p *EchoServiceEchoPingPongArgs) FastReadField2(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req2 = tmp + return offset, nil +} + +// for compatibility +func (p *EchoServiceEchoPingPongArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *EchoServiceEchoPingPongArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPong_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField2(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *EchoServiceEchoPingPongArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoPingPong_args") + if p != nil { + l += p.field1Length() + l += p.field2Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *EchoServiceEchoPingPongArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *EchoServiceEchoPingPongArgs) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req2", thrift.STRUCT, 2) + offset += p.Req2.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *EchoServiceEchoPingPongArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *EchoServiceEchoPingPongArgs) field2Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req2", thrift.STRUCT, 2) + l += p.Req2.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *EchoServiceEchoPingPongResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoPingPongResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoPingPongResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +func (p *EchoServiceEchoPingPongResult) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoException() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.E = tmp + return offset, nil +} + +// for compatibility +func (p *EchoServiceEchoPingPongResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *EchoServiceEchoPingPongResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPong_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *EchoServiceEchoPingPongResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoPingPong_result") + if p != nil { + l += p.field0Length() + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *EchoServiceEchoPingPongResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *EchoServiceEchoPingPongResult) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetE() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "e", thrift.STRUCT, 1) + offset += p.E.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *EchoServiceEchoPingPongResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *EchoServiceEchoPingPongResult) field1Length() int { + l := 0 + if p.IsSetE() { + l += bthrift.Binary.FieldBeginLength("e", thrift.STRUCT, 1) + l += p.E.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *EchoServiceEchoOnewayArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_EchoServiceEchoOnewayArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *EchoServiceEchoOnewayArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *EchoServiceEchoOnewayArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *EchoServiceEchoOnewayArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoOneway_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *EchoServiceEchoOnewayArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoOneway_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *EchoServiceEchoOnewayArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *EchoServiceEchoOnewayArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *EchoServiceEchoOnewayResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +// for compatibility +func (p *EchoServiceEchoOnewayResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *EchoServiceEchoOnewayResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoOneway_result") + if p != nil { + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *EchoServiceEchoOnewayResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoOneway_result") + if p != nil { + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *EchoServicePingArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +// for compatibility +func (p *EchoServicePingArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *EchoServicePingArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Ping_args") + if p != nil { + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *EchoServicePingArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Ping_args") + if p != nil { + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *EchoServicePingResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +// for compatibility +func (p *EchoServicePingResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *EchoServicePingResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Ping_result") + if p != nil { + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *EchoServicePingResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Ping_result") + if p != nil { + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *PingPongOnlyServiceEchoPingPongNewArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongNewArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongNewArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *PingPongOnlyServiceEchoPingPongNewArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *PingPongOnlyServiceEchoPingPongNewArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPongNew_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *PingPongOnlyServiceEchoPingPongNewArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoPingPongNew_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *PingPongOnlyServiceEchoPingPongNewArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *PingPongOnlyServiceEchoPingPongNewArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceEchoPingPongNewResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *PingPongOnlyServiceEchoPingPongNewResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoPingPongNew_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoPingPongNew_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectionalExtended_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoBidirectionalExtended_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PingPongOnlyServiceChildEchoBidirectionalExtendedResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectionalExtended_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoBidirectionalExtended_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalNewArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectionalNew_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoBidirectionalNew_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_StreamOnlyServiceEchoBidirectionalNewResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := NewEchoResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *StreamOnlyServiceEchoBidirectionalNewResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectionalNew_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoBidirectionalNew_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *ABCServiceEchoArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + case 2: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField2(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +func (p *ABCServiceEchoArgs) FastReadField2(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req2 = tmp + return offset, nil +} + +// for compatibility +func (p *ABCServiceEchoArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *ABCServiceEchoArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Echo_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField2(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Echo_args") + if p != nil { + l += p.field1Length() + l += p.field2Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *ABCServiceEchoArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoArgs) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req2", thrift.STRUCT, 2) + offset += p.Req2.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *ABCServiceEchoArgs) field2Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req2", thrift.STRUCT, 2) + l += p.Req2.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *ABCServiceEchoResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *ABCServiceEchoResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *ABCServiceEchoResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Echo_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Echo_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *ABCServiceEchoResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *ABCServiceEchoResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *ABCServiceEchoBidirectionalArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoBidirectionalArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoBidirectionalArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *ABCServiceEchoBidirectionalArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *ABCServiceEchoBidirectionalArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectional_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoBidirectionalArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoBidirectional_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *ABCServiceEchoBidirectionalArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoBidirectionalArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *ABCServiceEchoBidirectionalResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoBidirectionalResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoBidirectionalResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *ABCServiceEchoBidirectionalResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *ABCServiceEchoBidirectionalResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectional_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoBidirectionalResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoBidirectional_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *ABCServiceEchoBidirectionalResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *ABCServiceEchoBidirectionalResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *ABCServiceEchoServerArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoServerArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoServerArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *ABCServiceEchoServerArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *ABCServiceEchoServerArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoServer_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoServerArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoServer_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *ABCServiceEchoServerArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoServerArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *ABCServiceEchoServerResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoServerResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoServerResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *ABCServiceEchoServerResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *ABCServiceEchoServerResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoServer_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoServerResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoServer_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *ABCServiceEchoServerResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *ABCServiceEchoServerResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *ABCServiceEchoClientArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoClientArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoClientArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *ABCServiceEchoClientArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *ABCServiceEchoClientArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoClient_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoClientArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoClient_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *ABCServiceEchoClientArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoClientArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *ABCServiceEchoClientResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoClientResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoClientResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *ABCServiceEchoClientResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *ABCServiceEchoClientResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoClient_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoClientResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoClient_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *ABCServiceEchoClientResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *ABCServiceEchoClientResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *ABCServiceEchoUnaryArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoUnaryArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoUnaryArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *ABCServiceEchoUnaryArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *ABCServiceEchoUnaryArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoUnary_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoUnaryArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoUnary_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *ABCServiceEchoUnaryArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoUnaryArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *ABCServiceEchoUnaryResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoUnaryResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoUnaryResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *ABCServiceEchoUnaryResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *ABCServiceEchoUnaryResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoUnary_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoUnaryResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoUnary_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *ABCServiceEchoUnaryResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *ABCServiceEchoUnaryResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *EchoServiceEchoBidirectionalArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *EchoServiceEchoBidirectionalResult) GetResult() interface{} { + return p.Success +} + +func (p *EchoServiceEchoClientArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *EchoServiceEchoClientResult) GetResult() interface{} { + return p.Success +} + +func (p *EchoServiceEchoServerArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *EchoServiceEchoServerResult) GetResult() interface{} { + return p.Success +} + +func (p *EchoServiceEchoUnaryArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *EchoServiceEchoUnaryResult) GetResult() interface{} { + return p.Success +} + +func (p *EchoServiceEchoPingPongArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *EchoServiceEchoPingPongResult) GetResult() interface{} { + return p.Success +} + +func (p *EchoServiceEchoOnewayArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *EchoServiceEchoOnewayResult) GetResult() interface{} { + return nil +} + +func (p *EchoServicePingArgs) GetFirstArgument() interface{} { + return nil +} + +func (p *EchoServicePingResult) GetResult() interface{} { + return nil +} + +func (p *PingPongOnlyServiceEchoPingPongNewArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) GetResult() interface{} { + return p.Success +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) GetResult() interface{} { + return p.Success +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) GetResult() interface{} { + return p.Success +} + +func (p *ABCServiceEchoArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *ABCServiceEchoResult) GetResult() interface{} { + return p.Success +} + +func (p *ABCServiceEchoBidirectionalArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *ABCServiceEchoBidirectionalResult) GetResult() interface{} { + return p.Success +} + +func (p *ABCServiceEchoServerArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *ABCServiceEchoServerResult) GetResult() interface{} { + return p.Success +} + +func (p *ABCServiceEchoClientArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *ABCServiceEchoClientResult) GetResult() interface{} { + return p.Success +} + +func (p *ABCServiceEchoUnaryArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *ABCServiceEchoUnaryResult) GetResult() interface{} { + return p.Success +} diff --git a/thrift_streaming/kitex_gen/echo/k-consts.go b/thrift_streaming/kitex_gen/echo/k-consts.go new file mode 100644 index 0000000..cf25014 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/k-consts.go @@ -0,0 +1,4 @@ +package echo + +// KitexUnusedProtection is used to prevent 'imported and not used' error. +var KitexUnusedProtection = struct{}{} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservice/client.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/client.go new file mode 100644 index 0000000..0b298a3 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/client.go @@ -0,0 +1,49 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservice + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPongNew(ctx, req1) +} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservice/invoker.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/invoker.go new file mode 100644 index 0000000..da5064f --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.PingPongOnlyService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservice/pingpongonlyservice.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/pingpongonlyservice.go new file mode 100644 index 0000000..0bf7178 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/pingpongonlyservice.go @@ -0,0 +1,125 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservice + +import ( + "context" + "errors" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoPingPongNew": kitex.NewMethodInfo( + echoPingPongNewHandler, + newPingPongOnlyServiceEchoPingPongNewArgs, + newPingPongOnlyServiceEchoPingPongNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), +} + +var ( + pingPongOnlyServiceServiceInfo = NewServiceInfo() + pingPongOnlyServiceServiceInfoForClient = NewServiceInfoForClient() + pingPongOnlyServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return pingPongOnlyServiceServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return pingPongOnlyServiceServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return pingPongOnlyServiceServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "PingPongOnlyService" + handlerType := (*echo.PingPongOnlyService)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "echo", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() +} + +func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongNewArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceEchoPingPongNewResult + if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservice/server.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/server.go new file mode 100644 index 0000000..1c1f548 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservice/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package pingpongonlyservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.PingPongOnlyService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/client.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/client.go new file mode 100644 index 0000000..9603c81 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/client.go @@ -0,0 +1,99 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalExtended(ctx context.Context, callOptions ...streamcall.Option) (stream PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, err error) +} + +type PingPongOnlyServiceChild_EchoBidirectionalExtendedClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceChildClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceChildClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceChildClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPongNew(ctx, req1) +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceChildStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceChildStreamClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceChildStreamClient) EchoBidirectionalExtended(ctx context.Context, callOptions ...streamcall.Option) (stream PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalExtended(ctx) +} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/invoker.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/invoker.go new file mode 100644 index 0000000..1d57220 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.PingPongOnlyServiceChild, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/pingpongonlyservicechild.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/pingpongonlyservicechild.go new file mode 100644 index 0000000..d9fde95 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/pingpongonlyservicechild.go @@ -0,0 +1,190 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechild + +import ( + "context" + "errors" + "fmt" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoPingPongNew": kitex.NewMethodInfo( + echoPingPongNewHandler, + newPingPongOnlyServiceEchoPingPongNewArgs, + newPingPongOnlyServiceEchoPingPongNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "EchoBidirectionalExtended": kitex.NewMethodInfo( + echoBidirectionalExtendedHandler, + newPingPongOnlyServiceChildEchoBidirectionalExtendedArgs, + newPingPongOnlyServiceChildEchoBidirectionalExtendedResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + pingPongOnlyServiceChildServiceInfo = NewServiceInfo() + pingPongOnlyServiceChildServiceInfoForClient = NewServiceInfoForClient() + pingPongOnlyServiceChildServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return pingPongOnlyServiceChildServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return pingPongOnlyServiceChildServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return pingPongOnlyServiceChildServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "PingPongOnlyServiceChild" + handlerType := (*echo.PingPongOnlyServiceChild)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "echo", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() +} + +func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewResult() +} + +func echoBidirectionalExtendedHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("PingPongOnlyServiceChild.EchoBidirectionalExtended is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &pingPongOnlyServiceChildEchoBidirectionalExtendedServer{st.Stream} + return handler.(echo.PingPongOnlyServiceChild).EchoBidirectionalExtended(stream) +} + +type pingPongOnlyServiceChildEchoBidirectionalExtendedClient struct { + streaming.Stream +} + +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type pingPongOnlyServiceChildEchoBidirectionalExtendedServer struct { + streaming.Stream +} + +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() interface{} { + return echo.NewPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() +} + +func newPingPongOnlyServiceChildEchoBidirectionalExtendedResult() interface{} { + return echo.NewPingPongOnlyServiceChildEchoBidirectionalExtendedResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongNewArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceEchoPingPongNewResult + if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) EchoBidirectionalExtended(ctx context.Context) (PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectionalExtended", nil, res) + if err != nil { + return nil, err + } + stream := &pingPongOnlyServiceChildEchoBidirectionalExtendedClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/server.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/server.go new file mode 100644 index 0000000..3c88548 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechild/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package pingpongonlyservicechild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.PingPongOnlyServiceChild, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/client.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/client.go new file mode 100644 index 0000000..dcc00bc --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/client.go @@ -0,0 +1,99 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechildchild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalExtended(ctx context.Context, callOptions ...streamcall.Option) (stream PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, err error) +} + +type PingPongOnlyServiceChild_EchoBidirectionalExtendedClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceChildChildClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceChildChildClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceChildChildClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPongNew(ctx, req1) +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceChildChildStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceChildChildStreamClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceChildChildStreamClient) EchoBidirectionalExtended(ctx context.Context, callOptions ...streamcall.Option) (stream PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalExtended(ctx) +} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/invoker.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/invoker.go new file mode 100644 index 0000000..50d661b --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechildchild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.PingPongOnlyServiceChildChild, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go new file mode 100644 index 0000000..7fe56bb --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go @@ -0,0 +1,190 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pingpongonlyservicechildchild + +import ( + "context" + "errors" + "fmt" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoPingPongNew": kitex.NewMethodInfo( + echoPingPongNewHandler, + newPingPongOnlyServiceEchoPingPongNewArgs, + newPingPongOnlyServiceEchoPingPongNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "EchoBidirectionalExtended": kitex.NewMethodInfo( + echoBidirectionalExtendedHandler, + newPingPongOnlyServiceChildEchoBidirectionalExtendedArgs, + newPingPongOnlyServiceChildEchoBidirectionalExtendedResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + pingPongOnlyServiceChildChildServiceInfo = NewServiceInfo() + pingPongOnlyServiceChildChildServiceInfoForClient = NewServiceInfoForClient() + pingPongOnlyServiceChildChildServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return pingPongOnlyServiceChildChildServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return pingPongOnlyServiceChildChildServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return pingPongOnlyServiceChildChildServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "PingPongOnlyServiceChildChild" + handlerType := (*echo.PingPongOnlyServiceChildChild)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "echo", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.PingPongOnlyServiceEchoPingPongNewArgs) + realResult := result.(*echo.PingPongOnlyServiceEchoPingPongNewResult) + success, err := handler.(echo.PingPongOnlyService).EchoPingPongNew(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newPingPongOnlyServiceEchoPingPongNewArgs() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewArgs() +} + +func newPingPongOnlyServiceEchoPingPongNewResult() interface{} { + return echo.NewPingPongOnlyServiceEchoPingPongNewResult() +} + +func echoBidirectionalExtendedHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("PingPongOnlyServiceChild.EchoBidirectionalExtended is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &pingPongOnlyServiceChildEchoBidirectionalExtendedServer{st.Stream} + return handler.(echo.PingPongOnlyServiceChild).EchoBidirectionalExtended(stream) +} + +type pingPongOnlyServiceChildEchoBidirectionalExtendedClient struct { + streaming.Stream +} + +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type pingPongOnlyServiceChildEchoBidirectionalExtendedServer struct { + streaming.Stream +} + +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *pingPongOnlyServiceChildEchoBidirectionalExtendedServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() interface{} { + return echo.NewPingPongOnlyServiceChildEchoBidirectionalExtendedArgs() +} + +func newPingPongOnlyServiceChildEchoBidirectionalExtendedResult() interface{} { + return echo.NewPingPongOnlyServiceChildEchoBidirectionalExtendedResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest) (r *echo.EchoResponse, err error) { + var _args echo.PingPongOnlyServiceEchoPingPongNewArgs + _args.Req1 = req1 + var _result echo.PingPongOnlyServiceEchoPingPongNewResult + if err = p.c.Call(ctx, "EchoPingPongNew", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) EchoBidirectionalExtended(ctx context.Context) (PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectionalExtended", nil, res) + if err != nil { + return nil, err + } + stream := &pingPongOnlyServiceChildEchoBidirectionalExtendedClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/server.go b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/server.go new file mode 100644 index 0000000..39e1083 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/pingpongonlyservicechildchild/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package pingpongonlyservicechildchild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.PingPongOnlyServiceChildChild, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservice/client.go b/thrift_streaming/kitex_gen/echo/streamonlyservice/client.go new file mode 100644 index 0000000..e86aac5 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservice/client.go @@ -0,0 +1,92 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservice + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) +} + +type StreamOnlyService_EchoBidirectionalNewClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceClient struct { + *kClient +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceStreamClient struct { + *kClient +} + +func (p *kStreamOnlyServiceStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalNew(ctx) +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservice/invoker.go b/thrift_streaming/kitex_gen/echo/streamonlyservice/invoker.go new file mode 100644 index 0000000..3c8d70f --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservice/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.StreamOnlyService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservice/server.go b/thrift_streaming/kitex_gen/echo/streamonlyservice/server.go new file mode 100644 index 0000000..c5666b0 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservice/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package streamonlyservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.StreamOnlyService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservice/streamonlyservice.go b/thrift_streaming/kitex_gen/echo/streamonlyservice/streamonlyservice.go new file mode 100644 index 0000000..269fe07 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservice/streamonlyservice.go @@ -0,0 +1,155 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservice + +import ( + "context" + "errors" + "fmt" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoBidirectionalNew": kitex.NewMethodInfo( + echoBidirectionalNewHandler, + newStreamOnlyServiceEchoBidirectionalNewArgs, + newStreamOnlyServiceEchoBidirectionalNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + streamOnlyServiceServiceInfo = NewServiceInfo() + streamOnlyServiceServiceInfoForClient = NewServiceInfoForClient() + streamOnlyServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return streamOnlyServiceServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return streamOnlyServiceServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return streamOnlyServiceServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "StreamOnlyService" + handlerType := (*echo.StreamOnlyService)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "echo", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("StreamOnlyService.EchoBidirectionalNew is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &streamOnlyServiceEchoBidirectionalNewServer{st.Stream} + return handler.(echo.StreamOnlyService).EchoBidirectionalNew(stream) +} + +type streamOnlyServiceEchoBidirectionalNewClient struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *streamOnlyServiceEchoBidirectionalNewClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type streamOnlyServiceEchoBidirectionalNewServer struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() +} + +func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoBidirectionalNew(ctx context.Context) (StreamOnlyService_EchoBidirectionalNewClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectionalNew", nil, res) + if err != nil { + return nil, err + } + stream := &streamOnlyServiceEchoBidirectionalNewClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechild/client.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechild/client.go new file mode 100644 index 0000000..257e546 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservicechild/client.go @@ -0,0 +1,92 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) +} + +type StreamOnlyService_EchoBidirectionalNewClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceChildClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceChildClient struct { + *kClient +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceChildStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceChildStreamClient struct { + *kClient +} + +func (p *kStreamOnlyServiceChildStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalNew(ctx) +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechild/invoker.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechild/invoker.go new file mode 100644 index 0000000..34a30f2 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservicechild/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.StreamOnlyServiceChild, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechild/server.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechild/server.go new file mode 100644 index 0000000..c2d5088 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservicechild/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package streamonlyservicechild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.StreamOnlyServiceChild, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechild/streamonlyservicechild.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechild/streamonlyservicechild.go new file mode 100644 index 0000000..110d6a4 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservicechild/streamonlyservicechild.go @@ -0,0 +1,155 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechild + +import ( + "context" + "errors" + "fmt" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoBidirectionalNew": kitex.NewMethodInfo( + echoBidirectionalNewHandler, + newStreamOnlyServiceEchoBidirectionalNewArgs, + newStreamOnlyServiceEchoBidirectionalNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + streamOnlyServiceChildServiceInfo = NewServiceInfo() + streamOnlyServiceChildServiceInfoForClient = NewServiceInfoForClient() + streamOnlyServiceChildServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return streamOnlyServiceChildServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return streamOnlyServiceChildServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return streamOnlyServiceChildServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "StreamOnlyServiceChild" + handlerType := (*echo.StreamOnlyServiceChild)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "echo", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("StreamOnlyService.EchoBidirectionalNew is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &streamOnlyServiceEchoBidirectionalNewServer{st.Stream} + return handler.(echo.StreamOnlyService).EchoBidirectionalNew(stream) +} + +type streamOnlyServiceEchoBidirectionalNewClient struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *streamOnlyServiceEchoBidirectionalNewClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type streamOnlyServiceEchoBidirectionalNewServer struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() +} + +func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoBidirectionalNew(ctx context.Context) (StreamOnlyService_EchoBidirectionalNewClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectionalNew", nil, res) + if err != nil { + return nil, err + } + stream := &streamOnlyServiceEchoBidirectionalNewClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/client.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/client.go new file mode 100644 index 0000000..34e5462 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/client.go @@ -0,0 +1,92 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechildchild + +import ( + "context" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) +} + +type StreamOnlyService_EchoBidirectionalNewClient interface { + streaming.Stream + Send(*echo.EchoRequest) error + Recv() (*echo.EchoResponse, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceChildChildClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceChildChildClient struct { + *kClient +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceChildChildStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceChildChildStreamClient struct { + *kClient +} + +func (p *kStreamOnlyServiceChildChildStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalNew(ctx) +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/invoker.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/invoker.go new file mode 100644 index 0000000..d314e03 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechildchild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.StreamOnlyServiceChildChild, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/server.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/server.go new file mode 100644 index 0000000..68b2d4c --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package streamonlyservicechildchild + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.StreamOnlyServiceChildChild, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/streamonlyservicechildchild.go b/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/streamonlyservicechildchild.go new file mode 100644 index 0000000..e254e50 --- /dev/null +++ b/thrift_streaming/kitex_gen/echo/streamonlyservicechildchild/streamonlyservicechildchild.go @@ -0,0 +1,155 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package streamonlyservicechildchild + +import ( + "context" + "errors" + "fmt" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoBidirectionalNew": kitex.NewMethodInfo( + echoBidirectionalNewHandler, + newStreamOnlyServiceEchoBidirectionalNewArgs, + newStreamOnlyServiceEchoBidirectionalNewResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), +} + +var ( + streamOnlyServiceChildChildServiceInfo = NewServiceInfo() + streamOnlyServiceChildChildServiceInfoForClient = NewServiceInfoForClient() + streamOnlyServiceChildChildServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return streamOnlyServiceChildChildServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return streamOnlyServiceChildChildServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return streamOnlyServiceChildChildServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "StreamOnlyServiceChildChild" + handlerType := (*echo.StreamOnlyServiceChildChild)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "echo", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoBidirectionalNewHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("StreamOnlyService.EchoBidirectionalNew is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &streamOnlyServiceEchoBidirectionalNewServer{st.Stream} + return handler.(echo.StreamOnlyService).EchoBidirectionalNew(stream) +} + +type streamOnlyServiceEchoBidirectionalNewClient struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewClient) Send(m *echo.EchoRequest) error { + return x.Stream.SendMsg(m) +} +func (x *streamOnlyServiceEchoBidirectionalNewClient) Recv() (*echo.EchoResponse, error) { + m := new(echo.EchoResponse) + return m, x.Stream.RecvMsg(m) +} + +type streamOnlyServiceEchoBidirectionalNewServer struct { + streaming.Stream +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Send(m *echo.EchoResponse) error { + return x.Stream.SendMsg(m) +} + +func (x *streamOnlyServiceEchoBidirectionalNewServer) Recv() (*echo.EchoRequest, error) { + m := new(echo.EchoRequest) + return m, x.Stream.RecvMsg(m) +} + +func newStreamOnlyServiceEchoBidirectionalNewArgs() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewArgs() +} + +func newStreamOnlyServiceEchoBidirectionalNewResult() interface{} { + return echo.NewStreamOnlyServiceEchoBidirectionalNewResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoBidirectionalNew(ctx context.Context) (StreamOnlyService_EchoBidirectionalNewClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectionalNew", nil, res) + if err != nil { + return nil, err + } + stream := &streamOnlyServiceEchoBidirectionalNewClient{res.Stream} + return stream, nil +} diff --git a/thrift_streaming/kitex_gen/grpc_pb/api.pb.fast.go b/thrift_streaming/kitex_gen/grpc_pb/api.pb.fast.go new file mode 100644 index 0000000..191a376 --- /dev/null +++ b/thrift_streaming/kitex_gen/grpc_pb/api.pb.fast.go @@ -0,0 +1,135 @@ +// Code generated by Fastpb v0.0.2. DO NOT EDIT. + +package grpc_pb + +import ( + fmt "fmt" + fastpb "github.com/cloudwego/fastpb" +) + +var ( + _ = fmt.Errorf + _ = fastpb.Skip +) + +func (x *Request) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_Request[number], err) +} + +func (x *Request) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.Message, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *Response) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_Response[number], err) +} + +func (x *Response) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.Message, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *Request) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + return offset +} + +func (x *Request) fastWriteField1(buf []byte) (offset int) { + if x.Message == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 1, x.GetMessage()) + return offset +} + +func (x *Response) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + return offset +} + +func (x *Response) fastWriteField1(buf []byte) (offset int) { + if x.Message == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 1, x.GetMessage()) + return offset +} + +func (x *Request) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + return n +} + +func (x *Request) sizeField1() (n int) { + if x.Message == "" { + return n + } + n += fastpb.SizeString(1, x.GetMessage()) + return n +} + +func (x *Response) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + return n +} + +func (x *Response) sizeField1() (n int) { + if x.Message == "" { + return n + } + n += fastpb.SizeString(1, x.GetMessage()) + return n +} + +var fieldIDToName_Request = map[int32]string{ + 1: "Message", +} + +var fieldIDToName_Response = map[int32]string{ + 1: "Message", +} diff --git a/thrift_streaming/kitex_gen/grpc_pb/api.pb.go b/thrift_streaming/kitex_gen/grpc_pb/api.pb.go new file mode 100644 index 0000000..a46c9e4 --- /dev/null +++ b/thrift_streaming/kitex_gen/grpc_pb/api.pb.go @@ -0,0 +1,274 @@ +// Copyright 2023 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v3.21.12 +// source: idl/api.proto + +package grpc_pb + +import ( + context "context" + streaming "github.com/cloudwego/kitex/pkg/streaming" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Request struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *Request) Reset() { + *x = Request{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_api_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Request) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Request) ProtoMessage() {} + +func (x *Request) ProtoReflect() protoreflect.Message { + mi := &file_idl_api_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Request.ProtoReflect.Descriptor instead. +func (*Request) Descriptor() ([]byte, []int) { + return file_idl_api_proto_rawDescGZIP(), []int{0} +} + +func (x *Request) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +type Response struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *Response) Reset() { + *x = Response{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_api_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Response) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Response) ProtoMessage() {} + +func (x *Response) ProtoReflect() protoreflect.Message { + mi := &file_idl_api_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Response.ProtoReflect.Descriptor instead. +func (*Response) Descriptor() ([]byte, []int) { + return file_idl_api_proto_rawDescGZIP(), []int{1} +} + +func (x *Response) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +var File_idl_api_proto protoreflect.FileDescriptor + +var file_idl_api_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x69, 0x64, 0x6c, 0x2f, 0x61, 0x70, 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x07, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, 0x22, 0x23, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x24, 0x0a, + 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x32, 0xe3, 0x01, 0x0a, 0x09, 0x50, 0x42, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x12, 0x31, 0x0a, 0x04, 0x45, 0x63, 0x68, 0x6f, 0x12, 0x10, 0x2e, 0x67, 0x72, 0x70, 0x63, + 0x5f, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x67, 0x72, + 0x70, 0x63, 0x5f, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x28, 0x01, 0x30, 0x01, 0x12, 0x35, 0x0a, 0x0a, 0x45, 0x63, 0x68, 0x6f, 0x43, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x12, 0x10, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, 0x2e, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x12, 0x35, 0x0a, 0x0a, 0x45, + 0x63, 0x68, 0x6f, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x10, 0x2e, 0x67, 0x72, 0x70, 0x63, + 0x5f, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x67, 0x72, + 0x70, 0x63, 0x5f, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x30, 0x01, 0x12, 0x35, 0x0a, 0x0c, 0x45, 0x63, 0x68, 0x6f, 0x50, 0x69, 0x6e, 0x67, 0x50, 0x6f, + 0x6e, 0x67, 0x12, 0x10, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, 0x2e, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x45, 0x5a, 0x43, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x77, 0x65, 0x67, + 0x6f, 0x2f, 0x6b, 0x69, 0x74, 0x65, 0x78, 0x2d, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x74, 0x68, + 0x72, 0x69, 0x66, 0x74, 0x5f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x69, 0x6e, 0x67, 0x2f, 0x6b, + 0x69, 0x74, 0x65, 0x78, 0x5f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x70, 0x62, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_idl_api_proto_rawDescOnce sync.Once + file_idl_api_proto_rawDescData = file_idl_api_proto_rawDesc +) + +func file_idl_api_proto_rawDescGZIP() []byte { + file_idl_api_proto_rawDescOnce.Do(func() { + file_idl_api_proto_rawDescData = protoimpl.X.CompressGZIP(file_idl_api_proto_rawDescData) + }) + return file_idl_api_proto_rawDescData +} + +var file_idl_api_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_idl_api_proto_goTypes = []interface{}{ + (*Request)(nil), // 0: grpc_pb.Request + (*Response)(nil), // 1: grpc_pb.Response +} +var file_idl_api_proto_depIdxs = []int32{ + 0, // 0: grpc_pb.PBService.Echo:input_type -> grpc_pb.Request + 0, // 1: grpc_pb.PBService.EchoClient:input_type -> grpc_pb.Request + 0, // 2: grpc_pb.PBService.EchoServer:input_type -> grpc_pb.Request + 0, // 3: grpc_pb.PBService.EchoPingPong:input_type -> grpc_pb.Request + 1, // 4: grpc_pb.PBService.Echo:output_type -> grpc_pb.Response + 1, // 5: grpc_pb.PBService.EchoClient:output_type -> grpc_pb.Response + 1, // 6: grpc_pb.PBService.EchoServer:output_type -> grpc_pb.Response + 1, // 7: grpc_pb.PBService.EchoPingPong:output_type -> grpc_pb.Response + 4, // [4:8] is the sub-list for method output_type + 0, // [0:4] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_idl_api_proto_init() } +func file_idl_api_proto_init() { + if File_idl_api_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_idl_api_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Request); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_idl_api_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Response); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_idl_api_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_idl_api_proto_goTypes, + DependencyIndexes: file_idl_api_proto_depIdxs, + MessageInfos: file_idl_api_proto_msgTypes, + }.Build() + File_idl_api_proto = out.File + file_idl_api_proto_rawDesc = nil + file_idl_api_proto_goTypes = nil + file_idl_api_proto_depIdxs = nil +} + +var _ context.Context + +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +type PBService interface { + Echo(stream PBService_EchoServer) (err error) + EchoClient(stream PBService_EchoClientServer) (err error) + EchoServer(req *Request, stream PBService_EchoServerServer) (err error) + EchoPingPong(ctx context.Context, req *Request) (res *Response, err error) +} + +type PBService_EchoServer interface { + streaming.Stream + Recv() (*Request, error) + Send(*Response) error +} + +type PBService_EchoClientServer interface { + streaming.Stream + Recv() (*Request, error) + SendAndClose(*Response) error +} + +type PBService_EchoServerServer interface { + streaming.Stream + Send(*Response) error +} diff --git a/thrift_streaming/kitex_gen/grpc_pb/pbservice/client.go b/thrift_streaming/kitex_gen/grpc_pb/pbservice/client.go new file mode 100644 index 0000000..6d93321 --- /dev/null +++ b/thrift_streaming/kitex_gen/grpc_pb/pbservice/client.go @@ -0,0 +1,142 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pbservice + +import ( + "context" + grpc_pb "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/grpc_pb" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" + "github.com/cloudwego/kitex/client/streamclient" + "github.com/cloudwego/kitex/client/callopt/streamcall" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + Echo(ctx context.Context, callOptions ...callopt.Option) (stream PBService_EchoClient, err error) + EchoClient(ctx context.Context, callOptions ...callopt.Option) (stream PBService_EchoClientClient, err error) + EchoServer(ctx context.Context, Req *grpc_pb.Request, callOptions ...callopt.Option) (stream PBService_EchoServerClient, err error) + EchoPingPong(ctx context.Context, Req *grpc_pb.Request, callOptions ...callopt.Option) (r *grpc_pb.Response, err error) +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + Echo(ctx context.Context, callOptions ...streamcall.Option) (stream PBService_EchoClient, err error) + EchoClient(ctx context.Context, callOptions ...streamcall.Option) (stream PBService_EchoClientClient, err error) + EchoServer(ctx context.Context, Req *grpc_pb.Request, callOptions ...streamcall.Option) (stream PBService_EchoServerClient, err error) +} + +type PBService_EchoClient interface { + streaming.Stream + Send(*grpc_pb.Request) error + Recv() (*grpc_pb.Response, error) +} + +type PBService_EchoClientClient interface { + streaming.Stream + Send(*grpc_pb.Request) error + CloseAndRecv() (*grpc_pb.Response, error) +} + +type PBService_EchoServerClient interface { + streaming.Stream + Recv() (*grpc_pb.Response, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, client.WithTransportProtocol(transport.GRPC)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfo(), options...) + if err != nil { + return nil, err + } + return &kPBServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPBServiceClient struct { + *kClient +} + +func (p *kPBServiceClient) Echo(ctx context.Context, callOptions ...callopt.Option) (stream PBService_EchoClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.Echo(ctx) +} + +func (p *kPBServiceClient) EchoClient(ctx context.Context, callOptions ...callopt.Option) (stream PBService_EchoClientClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoClient(ctx) +} + +func (p *kPBServiceClient) EchoServer(ctx context.Context, Req *grpc_pb.Request, callOptions ...callopt.Option) (stream PBService_EchoServerClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoServer(ctx, Req) +} + +func (p *kPBServiceClient) EchoPingPong(ctx context.Context, Req *grpc_pb.Request, callOptions ...callopt.Option) (r *grpc_pb.Response, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPong(ctx, Req) +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kPBServiceStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPBServiceStreamClient struct { + *kClient +} + +func (p *kPBServiceStreamClient) Echo(ctx context.Context, callOptions ...streamcall.Option) (stream PBService_EchoClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.Echo(ctx) +} + +func (p *kPBServiceStreamClient) EchoClient(ctx context.Context, callOptions ...streamcall.Option) (stream PBService_EchoClientClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoClient(ctx) +} + +func (p *kPBServiceStreamClient) EchoServer(ctx context.Context, Req *grpc_pb.Request, callOptions ...streamcall.Option) (stream PBService_EchoServerClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoServer(ctx, Req) +} diff --git a/thrift_streaming/kitex_gen/grpc_pb/pbservice/invoker.go b/thrift_streaming/kitex_gen/grpc_pb/pbservice/invoker.go new file mode 100644 index 0000000..d35eb3f --- /dev/null +++ b/thrift_streaming/kitex_gen/grpc_pb/pbservice/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pbservice + +import ( + grpc_pb "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/grpc_pb" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler grpc_pb.PBService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/grpc_pb/pbservice/pbservice.go b/thrift_streaming/kitex_gen/grpc_pb/pbservice/pbservice.go new file mode 100644 index 0000000..c18e62c --- /dev/null +++ b/thrift_streaming/kitex_gen/grpc_pb/pbservice/pbservice.go @@ -0,0 +1,809 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pbservice + +import ( + "context" + "errors" + "fmt" + grpc_pb "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/grpc_pb" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" + proto "google.golang.org/protobuf/proto" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "Echo": kitex.NewMethodInfo( + echoHandler, + newEchoArgs, + newEchoResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), + "EchoClient": kitex.NewMethodInfo( + echoClientHandler, + newEchoClientArgs, + newEchoClientResult, + false, + kitex.WithStreamingMode(kitex.StreamingClient), + ), + "EchoServer": kitex.NewMethodInfo( + echoServerHandler, + newEchoServerArgs, + newEchoServerResult, + false, + kitex.WithStreamingMode(kitex.StreamingServer), + ), + "EchoPingPong": kitex.NewMethodInfo( + echoPingPongHandler, + newEchoPingPongArgs, + newEchoPingPongResult, + false, + kitex.WithStreamingMode(kitex.StreamingUnary), + ), +} + +var ( + pBServiceServiceInfo = NewServiceInfo() + pBServiceServiceInfoForClient = NewServiceInfoForClient() + pBServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return pBServiceServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return pBServiceServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return pBServiceServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "PBService" + handlerType := (*grpc_pb.PBService)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "grpc_pb", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Protobuf, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st := arg.(*streaming.Args).Stream + stream := &pBServiceEchoServer{st} + return handler.(grpc_pb.PBService).Echo(stream) +} + +type pBServiceEchoClient struct { + streaming.Stream +} + +func (x *pBServiceEchoClient) Send(m *grpc_pb.Request) error { + return x.Stream.SendMsg(m) +} +func (x *pBServiceEchoClient) Recv() (*grpc_pb.Response, error) { + m := new(grpc_pb.Response) + return m, x.Stream.RecvMsg(m) +} + +type pBServiceEchoServer struct { + streaming.Stream +} + +func (x *pBServiceEchoServer) Send(m *grpc_pb.Response) error { + return x.Stream.SendMsg(m) +} + +func (x *pBServiceEchoServer) Recv() (*grpc_pb.Request, error) { + m := new(grpc_pb.Request) + return m, x.Stream.RecvMsg(m) +} + +func newEchoArgs() interface{} { + return &EchoArgs{} +} + +func newEchoResult() interface{} { + return &EchoResult{} +} + +type EchoArgs struct { + Req *grpc_pb.Request +} + +func (p *EchoArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetReq() { + p.Req = new(grpc_pb.Request) + } + return p.Req.FastRead(buf, _type, number) +} + +func (p *EchoArgs) FastWrite(buf []byte) (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.FastWrite(buf) +} + +func (p *EchoArgs) Size() (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.Size() +} + +func (p *EchoArgs) Marshal(out []byte) ([]byte, error) { + if !p.IsSetReq() { + return out, nil + } + return proto.Marshal(p.Req) +} + +func (p *EchoArgs) Unmarshal(in []byte) error { + msg := new(grpc_pb.Request) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Req = msg + return nil +} + +var EchoArgs_Req_DEFAULT *grpc_pb.Request + +func (p *EchoArgs) GetReq() *grpc_pb.Request { + if !p.IsSetReq() { + return EchoArgs_Req_DEFAULT + } + return p.Req +} + +func (p *EchoArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *EchoArgs) GetFirstArgument() interface{} { + return p.Req +} + +type EchoResult struct { + Success *grpc_pb.Response +} + +var EchoResult_Success_DEFAULT *grpc_pb.Response + +func (p *EchoResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetSuccess() { + p.Success = new(grpc_pb.Response) + } + return p.Success.FastRead(buf, _type, number) +} + +func (p *EchoResult) FastWrite(buf []byte) (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.FastWrite(buf) +} + +func (p *EchoResult) Size() (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.Size() +} + +func (p *EchoResult) Marshal(out []byte) ([]byte, error) { + if !p.IsSetSuccess() { + return out, nil + } + return proto.Marshal(p.Success) +} + +func (p *EchoResult) Unmarshal(in []byte) error { + msg := new(grpc_pb.Response) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Success = msg + return nil +} + +func (p *EchoResult) GetSuccess() *grpc_pb.Response { + if !p.IsSetSuccess() { + return EchoResult_Success_DEFAULT + } + return p.Success +} + +func (p *EchoResult) SetSuccess(x interface{}) { + p.Success = x.(*grpc_pb.Response) +} + +func (p *EchoResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *EchoResult) GetResult() interface{} { + return p.Success +} + +func echoClientHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st := arg.(*streaming.Args).Stream + stream := &pBServiceEchoClientServer{st} + return handler.(grpc_pb.PBService).EchoClient(stream) +} + +type pBServiceEchoClientClient struct { + streaming.Stream +} + +func (x *pBServiceEchoClientClient) Send(m *grpc_pb.Request) error { + return x.Stream.SendMsg(m) +} +func (x *pBServiceEchoClientClient) CloseAndRecv() (*grpc_pb.Response, error) { + if err := x.Stream.Close(); err != nil { + return nil, err + } + m := new(grpc_pb.Response) + return m, x.Stream.RecvMsg(m) +} + +type pBServiceEchoClientServer struct { + streaming.Stream +} + +func (x *pBServiceEchoClientServer) SendAndClose(m *grpc_pb.Response) error { + return x.Stream.SendMsg(m) +} + +func (x *pBServiceEchoClientServer) Recv() (*grpc_pb.Request, error) { + m := new(grpc_pb.Request) + return m, x.Stream.RecvMsg(m) +} + +func newEchoClientArgs() interface{} { + return &EchoClientArgs{} +} + +func newEchoClientResult() interface{} { + return &EchoClientResult{} +} + +type EchoClientArgs struct { + Req *grpc_pb.Request +} + +func (p *EchoClientArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetReq() { + p.Req = new(grpc_pb.Request) + } + return p.Req.FastRead(buf, _type, number) +} + +func (p *EchoClientArgs) FastWrite(buf []byte) (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.FastWrite(buf) +} + +func (p *EchoClientArgs) Size() (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.Size() +} + +func (p *EchoClientArgs) Marshal(out []byte) ([]byte, error) { + if !p.IsSetReq() { + return out, nil + } + return proto.Marshal(p.Req) +} + +func (p *EchoClientArgs) Unmarshal(in []byte) error { + msg := new(grpc_pb.Request) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Req = msg + return nil +} + +var EchoClientArgs_Req_DEFAULT *grpc_pb.Request + +func (p *EchoClientArgs) GetReq() *grpc_pb.Request { + if !p.IsSetReq() { + return EchoClientArgs_Req_DEFAULT + } + return p.Req +} + +func (p *EchoClientArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *EchoClientArgs) GetFirstArgument() interface{} { + return p.Req +} + +type EchoClientResult struct { + Success *grpc_pb.Response +} + +var EchoClientResult_Success_DEFAULT *grpc_pb.Response + +func (p *EchoClientResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetSuccess() { + p.Success = new(grpc_pb.Response) + } + return p.Success.FastRead(buf, _type, number) +} + +func (p *EchoClientResult) FastWrite(buf []byte) (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.FastWrite(buf) +} + +func (p *EchoClientResult) Size() (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.Size() +} + +func (p *EchoClientResult) Marshal(out []byte) ([]byte, error) { + if !p.IsSetSuccess() { + return out, nil + } + return proto.Marshal(p.Success) +} + +func (p *EchoClientResult) Unmarshal(in []byte) error { + msg := new(grpc_pb.Response) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Success = msg + return nil +} + +func (p *EchoClientResult) GetSuccess() *grpc_pb.Response { + if !p.IsSetSuccess() { + return EchoClientResult_Success_DEFAULT + } + return p.Success +} + +func (p *EchoClientResult) SetSuccess(x interface{}) { + p.Success = x.(*grpc_pb.Response) +} + +func (p *EchoClientResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *EchoClientResult) GetResult() interface{} { + return p.Success +} + +func echoServerHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st := arg.(*streaming.Args).Stream + stream := &pBServiceEchoServerServer{st} + req := new(grpc_pb.Request) + if err := st.RecvMsg(req); err != nil { + return err + } + return handler.(grpc_pb.PBService).EchoServer(req, stream) +} + +type pBServiceEchoServerClient struct { + streaming.Stream +} + +func (x *pBServiceEchoServerClient) Recv() (*grpc_pb.Response, error) { + m := new(grpc_pb.Response) + return m, x.Stream.RecvMsg(m) +} + +type pBServiceEchoServerServer struct { + streaming.Stream +} + +func (x *pBServiceEchoServerServer) Send(m *grpc_pb.Response) error { + return x.Stream.SendMsg(m) +} + +func newEchoServerArgs() interface{} { + return &EchoServerArgs{} +} + +func newEchoServerResult() interface{} { + return &EchoServerResult{} +} + +type EchoServerArgs struct { + Req *grpc_pb.Request +} + +func (p *EchoServerArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetReq() { + p.Req = new(grpc_pb.Request) + } + return p.Req.FastRead(buf, _type, number) +} + +func (p *EchoServerArgs) FastWrite(buf []byte) (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.FastWrite(buf) +} + +func (p *EchoServerArgs) Size() (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.Size() +} + +func (p *EchoServerArgs) Marshal(out []byte) ([]byte, error) { + if !p.IsSetReq() { + return out, nil + } + return proto.Marshal(p.Req) +} + +func (p *EchoServerArgs) Unmarshal(in []byte) error { + msg := new(grpc_pb.Request) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Req = msg + return nil +} + +var EchoServerArgs_Req_DEFAULT *grpc_pb.Request + +func (p *EchoServerArgs) GetReq() *grpc_pb.Request { + if !p.IsSetReq() { + return EchoServerArgs_Req_DEFAULT + } + return p.Req +} + +func (p *EchoServerArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *EchoServerArgs) GetFirstArgument() interface{} { + return p.Req +} + +type EchoServerResult struct { + Success *grpc_pb.Response +} + +var EchoServerResult_Success_DEFAULT *grpc_pb.Response + +func (p *EchoServerResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetSuccess() { + p.Success = new(grpc_pb.Response) + } + return p.Success.FastRead(buf, _type, number) +} + +func (p *EchoServerResult) FastWrite(buf []byte) (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.FastWrite(buf) +} + +func (p *EchoServerResult) Size() (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.Size() +} + +func (p *EchoServerResult) Marshal(out []byte) ([]byte, error) { + if !p.IsSetSuccess() { + return out, nil + } + return proto.Marshal(p.Success) +} + +func (p *EchoServerResult) Unmarshal(in []byte) error { + msg := new(grpc_pb.Response) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Success = msg + return nil +} + +func (p *EchoServerResult) GetSuccess() *grpc_pb.Response { + if !p.IsSetSuccess() { + return EchoServerResult_Success_DEFAULT + } + return p.Success +} + +func (p *EchoServerResult) SetSuccess(x interface{}) { + p.Success = x.(*grpc_pb.Response) +} + +func (p *EchoServerResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *EchoServerResult) GetResult() interface{} { + return p.Success +} + +func echoPingPongHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + switch s := arg.(type) { + case *streaming.Args: + st := s.Stream + req := new(grpc_pb.Request) + if err := st.RecvMsg(req); err != nil { + return err + } + resp, err := handler.(grpc_pb.PBService).EchoPingPong(ctx, req) + if err != nil { + return err + } + return st.SendMsg(resp) + case *EchoPingPongArgs: + success, err := handler.(grpc_pb.PBService).EchoPingPong(ctx, s.Req) + if err != nil { + return err + } + realResult := result.(*EchoPingPongResult) + realResult.Success = success + return nil + default: + return errInvalidMessageType + } +} +func newEchoPingPongArgs() interface{} { + return &EchoPingPongArgs{} +} + +func newEchoPingPongResult() interface{} { + return &EchoPingPongResult{} +} + +type EchoPingPongArgs struct { + Req *grpc_pb.Request +} + +func (p *EchoPingPongArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetReq() { + p.Req = new(grpc_pb.Request) + } + return p.Req.FastRead(buf, _type, number) +} + +func (p *EchoPingPongArgs) FastWrite(buf []byte) (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.FastWrite(buf) +} + +func (p *EchoPingPongArgs) Size() (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.Size() +} + +func (p *EchoPingPongArgs) Marshal(out []byte) ([]byte, error) { + if !p.IsSetReq() { + return out, nil + } + return proto.Marshal(p.Req) +} + +func (p *EchoPingPongArgs) Unmarshal(in []byte) error { + msg := new(grpc_pb.Request) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Req = msg + return nil +} + +var EchoPingPongArgs_Req_DEFAULT *grpc_pb.Request + +func (p *EchoPingPongArgs) GetReq() *grpc_pb.Request { + if !p.IsSetReq() { + return EchoPingPongArgs_Req_DEFAULT + } + return p.Req +} + +func (p *EchoPingPongArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *EchoPingPongArgs) GetFirstArgument() interface{} { + return p.Req +} + +type EchoPingPongResult struct { + Success *grpc_pb.Response +} + +var EchoPingPongResult_Success_DEFAULT *grpc_pb.Response + +func (p *EchoPingPongResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetSuccess() { + p.Success = new(grpc_pb.Response) + } + return p.Success.FastRead(buf, _type, number) +} + +func (p *EchoPingPongResult) FastWrite(buf []byte) (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.FastWrite(buf) +} + +func (p *EchoPingPongResult) Size() (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.Size() +} + +func (p *EchoPingPongResult) Marshal(out []byte) ([]byte, error) { + if !p.IsSetSuccess() { + return out, nil + } + return proto.Marshal(p.Success) +} + +func (p *EchoPingPongResult) Unmarshal(in []byte) error { + msg := new(grpc_pb.Response) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Success = msg + return nil +} + +func (p *EchoPingPongResult) GetSuccess() *grpc_pb.Response { + if !p.IsSetSuccess() { + return EchoPingPongResult_Success_DEFAULT + } + return p.Success +} + +func (p *EchoPingPongResult) SetSuccess(x interface{}) { + p.Success = x.(*grpc_pb.Response) +} + +func (p *EchoPingPongResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *EchoPingPongResult) GetResult() interface{} { + return p.Success +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) Echo(ctx context.Context) (PBService_EchoClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "Echo", nil, res) + if err != nil { + return nil, err + } + stream := &pBServiceEchoClient{res.Stream} + return stream, nil +} + +func (p *kClient) EchoClient(ctx context.Context) (PBService_EchoClientClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoClient", nil, res) + if err != nil { + return nil, err + } + stream := &pBServiceEchoClientClient{res.Stream} + return stream, nil +} + +func (p *kClient) EchoServer(ctx context.Context, req *grpc_pb.Request) (PBService_EchoServerClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoServer", nil, res) + if err != nil { + return nil, err + } + stream := &pBServiceEchoServerClient{res.Stream} + + if err := stream.Stream.SendMsg(req); err != nil { + return nil, err + } + if err := stream.Stream.Close(); err != nil { + return nil, err + } + return stream, nil +} + +func (p *kClient) EchoPingPong(ctx context.Context, Req *grpc_pb.Request) (r *grpc_pb.Response, err error) { + var _args EchoPingPongArgs + _args.Req = Req + var _result EchoPingPongResult + if err = p.c.Call(ctx, "EchoPingPong", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen/grpc_pb/pbservice/server.go b/thrift_streaming/kitex_gen/grpc_pb/pbservice/server.go new file mode 100644 index 0000000..aa66822 --- /dev/null +++ b/thrift_streaming/kitex_gen/grpc_pb/pbservice/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package pbservice + +import ( + grpc_pb "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/grpc_pb" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler grpc_pb.PBService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.fast.go b/thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.fast.go new file mode 100644 index 0000000..aca5f22 --- /dev/null +++ b/thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.fast.go @@ -0,0 +1,135 @@ +// Code generated by Fastpb v0.0.2. DO NOT EDIT. + +package kitex_pb + +import ( + fmt "fmt" + fastpb "github.com/cloudwego/fastpb" +) + +var ( + _ = fmt.Errorf + _ = fastpb.Skip +) + +func (x *Request) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_Request[number], err) +} + +func (x *Request) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.Message, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *Response) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_Response[number], err) +} + +func (x *Response) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.Message, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *Request) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + return offset +} + +func (x *Request) fastWriteField1(buf []byte) (offset int) { + if x.Message == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 1, x.GetMessage()) + return offset +} + +func (x *Response) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + return offset +} + +func (x *Response) fastWriteField1(buf []byte) (offset int) { + if x.Message == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 1, x.GetMessage()) + return offset +} + +func (x *Request) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + return n +} + +func (x *Request) sizeField1() (n int) { + if x.Message == "" { + return n + } + n += fastpb.SizeString(1, x.GetMessage()) + return n +} + +func (x *Response) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + return n +} + +func (x *Response) sizeField1() (n int) { + if x.Message == "" { + return n + } + n += fastpb.SizeString(1, x.GetMessage()) + return n +} + +var fieldIDToName_Request = map[int32]string{ + 1: "Message", +} + +var fieldIDToName_Response = map[int32]string{ + 1: "Message", +} diff --git a/thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.go b/thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.go new file mode 100644 index 0000000..12e1add --- /dev/null +++ b/thrift_streaming/kitex_gen/kitex_pb/api_no_stream.pb.go @@ -0,0 +1,238 @@ +// Copyright 2023 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v3.21.12 +// source: idl/api_no_stream.proto + +package kitex_pb + +import ( + context "context" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Request struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *Request) Reset() { + *x = Request{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_api_no_stream_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Request) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Request) ProtoMessage() {} + +func (x *Request) ProtoReflect() protoreflect.Message { + mi := &file_idl_api_no_stream_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Request.ProtoReflect.Descriptor instead. +func (*Request) Descriptor() ([]byte, []int) { + return file_idl_api_no_stream_proto_rawDescGZIP(), []int{0} +} + +func (x *Request) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +type Response struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *Response) Reset() { + *x = Response{} + if protoimpl.UnsafeEnabled { + mi := &file_idl_api_no_stream_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Response) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Response) ProtoMessage() {} + +func (x *Response) ProtoReflect() protoreflect.Message { + mi := &file_idl_api_no_stream_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Response.ProtoReflect.Descriptor instead. +func (*Response) Descriptor() ([]byte, []int) { + return file_idl_api_no_stream_proto_rawDescGZIP(), []int{1} +} + +func (x *Response) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +var File_idl_api_no_stream_proto protoreflect.FileDescriptor + +var file_idl_api_no_stream_proto_rawDesc = []byte{ + 0x0a, 0x17, 0x69, 0x64, 0x6c, 0x2f, 0x61, 0x70, 0x69, 0x5f, 0x6e, 0x6f, 0x5f, 0x73, 0x74, 0x72, + 0x65, 0x61, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x6b, 0x69, 0x74, 0x65, 0x78, + 0x5f, 0x70, 0x62, 0x22, 0x23, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, + 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x24, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x44, + 0x0a, 0x09, 0x50, 0x42, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x37, 0x0a, 0x0c, 0x45, + 0x63, 0x68, 0x6f, 0x50, 0x69, 0x6e, 0x67, 0x50, 0x6f, 0x6e, 0x67, 0x12, 0x11, 0x2e, 0x6b, 0x69, + 0x74, 0x65, 0x78, 0x5f, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, + 0x2e, 0x6b, 0x69, 0x74, 0x65, 0x78, 0x5f, 0x70, 0x62, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x42, 0x46, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x77, 0x65, 0x67, 0x6f, 0x2f, 0x6b, 0x69, 0x74, + 0x65, 0x78, 0x2d, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x74, 0x68, 0x72, 0x69, 0x66, 0x74, 0x5f, + 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x69, 0x6e, 0x67, 0x2f, 0x6b, 0x69, 0x74, 0x65, 0x78, 0x5f, + 0x67, 0x65, 0x6e, 0x2f, 0x6b, 0x69, 0x74, 0x65, 0x78, 0x5f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_idl_api_no_stream_proto_rawDescOnce sync.Once + file_idl_api_no_stream_proto_rawDescData = file_idl_api_no_stream_proto_rawDesc +) + +func file_idl_api_no_stream_proto_rawDescGZIP() []byte { + file_idl_api_no_stream_proto_rawDescOnce.Do(func() { + file_idl_api_no_stream_proto_rawDescData = protoimpl.X.CompressGZIP(file_idl_api_no_stream_proto_rawDescData) + }) + return file_idl_api_no_stream_proto_rawDescData +} + +var file_idl_api_no_stream_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_idl_api_no_stream_proto_goTypes = []interface{}{ + (*Request)(nil), // 0: kitex_pb.Request + (*Response)(nil), // 1: kitex_pb.Response +} +var file_idl_api_no_stream_proto_depIdxs = []int32{ + 0, // 0: kitex_pb.PBService.EchoPingPong:input_type -> kitex_pb.Request + 1, // 1: kitex_pb.PBService.EchoPingPong:output_type -> kitex_pb.Response + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_idl_api_no_stream_proto_init() } +func file_idl_api_no_stream_proto_init() { + if File_idl_api_no_stream_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_idl_api_no_stream_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Request); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_idl_api_no_stream_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Response); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_idl_api_no_stream_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_idl_api_no_stream_proto_goTypes, + DependencyIndexes: file_idl_api_no_stream_proto_depIdxs, + MessageInfos: file_idl_api_no_stream_proto_msgTypes, + }.Build() + File_idl_api_no_stream_proto = out.File + file_idl_api_no_stream_proto_rawDesc = nil + file_idl_api_no_stream_proto_goTypes = nil + file_idl_api_no_stream_proto_depIdxs = nil +} + +var _ context.Context + +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +type PBService interface { + EchoPingPong(ctx context.Context, req *Request) (res *Response, err error) +} diff --git a/thrift_streaming/kitex_gen/kitex_pb/pbservice/client.go b/thrift_streaming/kitex_gen/kitex_pb/pbservice/client.go new file mode 100644 index 0000000..f3f3ce9 --- /dev/null +++ b/thrift_streaming/kitex_gen/kitex_pb/pbservice/client.go @@ -0,0 +1,49 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pbservice + +import ( + "context" + kitex_pb "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/kitex_pb" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + EchoPingPong(ctx context.Context, Req *kitex_pb.Request, callOptions ...callopt.Option) (r *kitex_pb.Response, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfo(), options...) + if err != nil { + return nil, err + } + return &kPBServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPBServiceClient struct { + *kClient +} + +func (p *kPBServiceClient) EchoPingPong(ctx context.Context, Req *kitex_pb.Request, callOptions ...callopt.Option) (r *kitex_pb.Response, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoPingPong(ctx, Req) +} diff --git a/thrift_streaming/kitex_gen/kitex_pb/pbservice/invoker.go b/thrift_streaming/kitex_gen/kitex_pb/pbservice/invoker.go new file mode 100644 index 0000000..159bb61 --- /dev/null +++ b/thrift_streaming/kitex_gen/kitex_pb/pbservice/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pbservice + +import ( + kitex_pb "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/kitex_pb" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler kitex_pb.PBService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen/kitex_pb/pbservice/pbservice.go b/thrift_streaming/kitex_gen/kitex_pb/pbservice/pbservice.go new file mode 100644 index 0000000..618851e --- /dev/null +++ b/thrift_streaming/kitex_gen/kitex_pb/pbservice/pbservice.go @@ -0,0 +1,262 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package pbservice + +import ( + "context" + "errors" + kitex_pb "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/kitex_pb" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" + proto "google.golang.org/protobuf/proto" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "EchoPingPong": kitex.NewMethodInfo( + echoPingPongHandler, + newEchoPingPongArgs, + newEchoPingPongResult, + false, + kitex.WithStreamingMode(kitex.StreamingUnary), + ), +} + +var ( + pBServiceServiceInfo = NewServiceInfo() + pBServiceServiceInfoForClient = NewServiceInfoForClient() + pBServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return pBServiceServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return pBServiceServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return pBServiceServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(false, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "PBService" + handlerType := (*kitex_pb.PBService)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "kitex_pb", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Protobuf, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoPingPongHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + switch s := arg.(type) { + case *streaming.Args: + st := s.Stream + req := new(kitex_pb.Request) + if err := st.RecvMsg(req); err != nil { + return err + } + resp, err := handler.(kitex_pb.PBService).EchoPingPong(ctx, req) + if err != nil { + return err + } + return st.SendMsg(resp) + case *EchoPingPongArgs: + success, err := handler.(kitex_pb.PBService).EchoPingPong(ctx, s.Req) + if err != nil { + return err + } + realResult := result.(*EchoPingPongResult) + realResult.Success = success + return nil + default: + return errInvalidMessageType + } +} +func newEchoPingPongArgs() interface{} { + return &EchoPingPongArgs{} +} + +func newEchoPingPongResult() interface{} { + return &EchoPingPongResult{} +} + +type EchoPingPongArgs struct { + Req *kitex_pb.Request +} + +func (p *EchoPingPongArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetReq() { + p.Req = new(kitex_pb.Request) + } + return p.Req.FastRead(buf, _type, number) +} + +func (p *EchoPingPongArgs) FastWrite(buf []byte) (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.FastWrite(buf) +} + +func (p *EchoPingPongArgs) Size() (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.Size() +} + +func (p *EchoPingPongArgs) Marshal(out []byte) ([]byte, error) { + if !p.IsSetReq() { + return out, nil + } + return proto.Marshal(p.Req) +} + +func (p *EchoPingPongArgs) Unmarshal(in []byte) error { + msg := new(kitex_pb.Request) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Req = msg + return nil +} + +var EchoPingPongArgs_Req_DEFAULT *kitex_pb.Request + +func (p *EchoPingPongArgs) GetReq() *kitex_pb.Request { + if !p.IsSetReq() { + return EchoPingPongArgs_Req_DEFAULT + } + return p.Req +} + +func (p *EchoPingPongArgs) IsSetReq() bool { + return p.Req != nil +} + +func (p *EchoPingPongArgs) GetFirstArgument() interface{} { + return p.Req +} + +type EchoPingPongResult struct { + Success *kitex_pb.Response +} + +var EchoPingPongResult_Success_DEFAULT *kitex_pb.Response + +func (p *EchoPingPongResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetSuccess() { + p.Success = new(kitex_pb.Response) + } + return p.Success.FastRead(buf, _type, number) +} + +func (p *EchoPingPongResult) FastWrite(buf []byte) (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.FastWrite(buf) +} + +func (p *EchoPingPongResult) Size() (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.Size() +} + +func (p *EchoPingPongResult) Marshal(out []byte) ([]byte, error) { + if !p.IsSetSuccess() { + return out, nil + } + return proto.Marshal(p.Success) +} + +func (p *EchoPingPongResult) Unmarshal(in []byte) error { + msg := new(kitex_pb.Response) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Success = msg + return nil +} + +func (p *EchoPingPongResult) GetSuccess() *kitex_pb.Response { + if !p.IsSetSuccess() { + return EchoPingPongResult_Success_DEFAULT + } + return p.Success +} + +func (p *EchoPingPongResult) SetSuccess(x interface{}) { + p.Success = x.(*kitex_pb.Response) +} + +func (p *EchoPingPongResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *EchoPingPongResult) GetResult() interface{} { + return p.Success +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) EchoPingPong(ctx context.Context, Req *kitex_pb.Request) (r *kitex_pb.Response, err error) { + var _args EchoPingPongArgs + _args.Req = Req + var _result EchoPingPongResult + if err = p.c.Call(ctx, "EchoPingPong", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen/kitex_pb/pbservice/server.go b/thrift_streaming/kitex_gen/kitex_pb/pbservice/server.go new file mode 100644 index 0000000..5bf8bae --- /dev/null +++ b/thrift_streaming/kitex_gen/kitex_pb/pbservice/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package pbservice + +import ( + kitex_pb "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/kitex_pb" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler kitex_pb.PBService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_cross/a/b/c/a.b.c.go b/thrift_streaming/kitex_gen_cross/a/b/c/a.b.c.go new file mode 100644 index 0000000..ea7a08e --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/a/b/c/a.b.c.go @@ -0,0 +1,333 @@ +// Code generated by thriftgo (0.3.6). DO NOT EDIT. + +package c + +import ( + "fmt" + "github.com/apache/thrift/lib/go/thrift" + "strings" +) + +type Request struct { + Message string `thrift:"message,1" frugal:"1,default,string" json:"message"` +} + +func NewRequest() *Request { + return &Request{} +} + +func (p *Request) InitDefault() { + *p = Request{} +} + +func (p *Request) GetMessage() (v string) { + return p.Message +} +func (p *Request) SetMessage(val string) { + p.Message = val +} + +var fieldIDToName_Request = map[int16]string{ + 1: "message", +} + +func (p *Request) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Request[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *Request) ReadField1(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadString(); err != nil { + return err + } else { + p.Message = v + } + return nil +} + +func (p *Request) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Request"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *Request) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Message); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *Request) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Request(%+v)", *p) + +} + +func (p *Request) DeepEqual(ano *Request) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Message) { + return false + } + return true +} + +func (p *Request) Field1DeepEqual(src string) bool { + + if strings.Compare(p.Message, src) != 0 { + return false + } + return true +} + +type Response struct { + Message string `thrift:"message,1" frugal:"1,default,string" json:"message"` +} + +func NewResponse() *Response { + return &Response{} +} + +func (p *Response) InitDefault() { + *p = Response{} +} + +func (p *Response) GetMessage() (v string) { + return p.Message +} +func (p *Response) SetMessage(val string) { + p.Message = val +} + +var fieldIDToName_Response = map[int16]string{ + 1: "message", +} + +func (p *Response) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Response[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *Response) ReadField1(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadString(); err != nil { + return err + } else { + p.Message = v + } + return nil +} + +func (p *Response) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Response"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *Response) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Message); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *Response) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Response(%+v)", *p) + +} + +func (p *Response) DeepEqual(ano *Response) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Message) { + return false + } + return true +} + +func (p *Response) Field1DeepEqual(src string) bool { + + if strings.Compare(p.Message, src) != 0 { + return false + } + return true +} diff --git a/thrift_streaming/kitex_gen_cross/a/b/c/k-a.b.c.go b/thrift_streaming/kitex_gen_cross/a/b/c/k-a.b.c.go new file mode 100644 index 0000000..b66b2ca --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/a/b/c/k-a.b.c.go @@ -0,0 +1,284 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package c + +import ( + "bytes" + "fmt" + "reflect" + "strings" + + "github.com/apache/thrift/lib/go/thrift" + + "github.com/cloudwego/kitex/pkg/protocol/bthrift" +) + +// unused protection +var ( + _ = fmt.Formatter(nil) + _ = (*bytes.Buffer)(nil) + _ = (*strings.Builder)(nil) + _ = reflect.Type(nil) + _ = thrift.TProtocol(nil) + _ = bthrift.BinaryWriter(nil) +) + +func (p *Request) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Request[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *Request) FastReadField1(buf []byte) (int, error) { + offset := 0 + + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.Message = v + + } + return offset, nil +} + +// for compatibility +func (p *Request) FastWrite(buf []byte) int { + return 0 +} + +func (p *Request) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Request") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *Request) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Request") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *Request) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) + + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Request) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) + l += bthrift.Binary.StringLengthNocopy(p.Message) + + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Response) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Response[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *Response) FastReadField1(buf []byte) (int, error) { + offset := 0 + + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.Message = v + + } + return offset, nil +} + +// for compatibility +func (p *Response) FastWrite(buf []byte) int { + return 0 +} + +func (p *Response) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Response") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *Response) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Response") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *Response) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) + + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Response) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) + l += bthrift.Binary.StringLengthNocopy(p.Message) + + l += bthrift.Binary.FieldEndLength() + return l +} diff --git a/thrift_streaming/kitex_gen_cross/a/b/c/k-consts.go b/thrift_streaming/kitex_gen_cross/a/b/c/k-consts.go new file mode 100644 index 0000000..2fdbc7e --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/a/b/c/k-consts.go @@ -0,0 +1,4 @@ +package c + +// KitexUnusedProtection is used to prevent 'imported and not used' error. +var KitexUnusedProtection = struct{}{} diff --git a/thrift_streaming/kitex_gen_cross/echo/abcservice/abcservice.go b/thrift_streaming/kitex_gen_cross/echo/abcservice/abcservice.go new file mode 100644 index 0000000..df33b8d --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/abcservice/abcservice.go @@ -0,0 +1,77 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package abcservice + +import ( + "context" + c "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/a/b/c" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +func serviceInfo() *kitex.ServiceInfo { + return aBCServiceServiceInfo +} + +var aBCServiceServiceInfo = NewServiceInfo() + +func NewServiceInfo() *kitex.ServiceInfo { + serviceName := "ABCService" + handlerType := (*echo.ABCService)(nil) + methods := map[string]kitex.MethodInfo{ + "Echo": kitex.NewMethodInfo(echoHandler, newABCServiceEchoArgs, newABCServiceEchoResult, false), + } + extra := map[string]interface{}{ + "PackageName": "echo", + "ServiceFilePath": `idl/api.thrift`, + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.ABCServiceEchoArgs) + realResult := result.(*echo.ABCServiceEchoResult) + success, err := handler.(echo.ABCService).Echo(ctx, realArg.Req1, realArg.Req2) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newABCServiceEchoArgs() interface{} { + return echo.NewABCServiceEchoArgs() +} + +func newABCServiceEchoResult() interface{} { + return echo.NewABCServiceEchoResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) Echo(ctx context.Context, req1 *c.Request, req2 *c.Request) (r *c.Response, err error) { + var _args echo.ABCServiceEchoArgs + _args.Req1 = req1 + _args.Req2 = req2 + var _result echo.ABCServiceEchoResult + if err = p.c.Call(ctx, "Echo", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen_cross/echo/abcservice/client.go b/thrift_streaming/kitex_gen_cross/echo/abcservice/client.go new file mode 100644 index 0000000..e715f8a --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/abcservice/client.go @@ -0,0 +1,49 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package abcservice + +import ( + "context" + c "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/a/b/c" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + Echo(ctx context.Context, req1 *c.Request, req2 *c.Request, callOptions ...callopt.Option) (r *c.Response, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfo(), options...) + if err != nil { + return nil, err + } + return &kABCServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kABCServiceClient struct { + *kClient +} + +func (p *kABCServiceClient) Echo(ctx context.Context, req1 *c.Request, req2 *c.Request, callOptions ...callopt.Option) (r *c.Response, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.Echo(ctx, req1, req2) +} diff --git a/thrift_streaming/kitex_gen_cross/echo/abcservice/invoker.go b/thrift_streaming/kitex_gen_cross/echo/abcservice/invoker.go new file mode 100644 index 0000000..b8b8745 --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/abcservice/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package abcservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.ABCService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_cross/echo/abcservice/server.go b/thrift_streaming/kitex_gen_cross/echo/abcservice/server.go new file mode 100644 index 0000000..bc84d71 --- /dev/null +++ b/thrift_streaming/kitex_gen_cross/echo/abcservice/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package abcservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.ABCService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_cross/echo/api.go b/thrift_streaming/kitex_gen_cross/echo/api.go index 7bcbee0..c8c0c94 100644 --- a/thrift_streaming/kitex_gen_cross/echo/api.go +++ b/thrift_streaming/kitex_gen_cross/echo/api.go @@ -1,4 +1,4 @@ -// Code generated by thriftgo (0.3.5). DO NOT EDIT. +// Code generated by thriftgo (0.3.6). DO NOT EDIT. package echo @@ -6,6 +6,7 @@ import ( "context" "fmt" "github.com/apache/thrift/lib/go/thrift" + "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/a/b/c" "strings" ) @@ -753,6 +754,47 @@ func NewStreamOnlyServiceChildChildClient(c thrift.TClient) *StreamOnlyServiceCh } } +type ABCService interface { + Echo(ctx context.Context, req1 *c.Request, req2 *c.Request) (r *c.Response, err error) +} + +type ABCServiceClient struct { + c thrift.TClient +} + +func NewABCServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ABCServiceClient { + return &ABCServiceClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewABCServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *ABCServiceClient { + return &ABCServiceClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewABCServiceClient(c thrift.TClient) *ABCServiceClient { + return &ABCServiceClient{ + c: c, + } +} + +func (p *ABCServiceClient) Client_() thrift.TClient { + return p.c +} + +func (p *ABCServiceClient) Echo(ctx context.Context, req1 *c.Request, req2 *c.Request) (r *c.Response, err error) { + var _args ABCServiceEchoArgs + _args.Req1 = req1 + _args.Req2 = req2 + var _result ABCServiceEchoResult + if err = p.Client_().Call(ctx, "Echo", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + type EchoServiceProcessor struct { processorMap map[string]thrift.TProcessorFunction handler EchoService @@ -2361,3 +2403,496 @@ func NewStreamOnlyServiceChildChildProcessor(handler StreamOnlyServiceChildChild self := &StreamOnlyServiceChildChildProcessor{NewStreamOnlyServiceChildProcessor(handler)} return self } + +type ABCServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler ABCService +} + +func (p *ABCServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *ABCServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *ABCServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewABCServiceProcessor(handler ABCService) *ABCServiceProcessor { + self := &ABCServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self.AddToProcessorMap("Echo", &aBCServiceProcessorEcho{handler: handler}) + return self +} +func (p *ABCServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} + +type aBCServiceProcessorEcho struct { + handler ABCService +} + +func (p *aBCServiceProcessorEcho) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := ABCServiceEchoArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("Echo", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := ABCServiceEchoResult{} + var retval *c.Response + if retval, err2 = p.handler.Echo(ctx, args.Req1, args.Req2); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Echo: "+err2.Error()) + oprot.WriteMessageBegin("Echo", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("Echo", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type ABCServiceEchoArgs struct { + Req1 *c.Request `thrift:"req1,1" frugal:"1,default,c.Request" json:"req1"` + Req2 *c.Request `thrift:"req2,2" frugal:"2,default,c.Request" json:"req2"` +} + +func NewABCServiceEchoArgs() *ABCServiceEchoArgs { + return &ABCServiceEchoArgs{} +} + +func (p *ABCServiceEchoArgs) InitDefault() { + *p = ABCServiceEchoArgs{} +} + +var ABCServiceEchoArgs_Req1_DEFAULT *c.Request + +func (p *ABCServiceEchoArgs) GetReq1() (v *c.Request) { + if !p.IsSetReq1() { + return ABCServiceEchoArgs_Req1_DEFAULT + } + return p.Req1 +} + +var ABCServiceEchoArgs_Req2_DEFAULT *c.Request + +func (p *ABCServiceEchoArgs) GetReq2() (v *c.Request) { + if !p.IsSetReq2() { + return ABCServiceEchoArgs_Req2_DEFAULT + } + return p.Req2 +} +func (p *ABCServiceEchoArgs) SetReq1(val *c.Request) { + p.Req1 = val +} +func (p *ABCServiceEchoArgs) SetReq2(val *c.Request) { + p.Req2 = val +} + +var fieldIDToName_ABCServiceEchoArgs = map[int16]string{ + 1: "req1", + 2: "req2", +} + +func (p *ABCServiceEchoArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *ABCServiceEchoArgs) IsSetReq2() bool { + return p.Req2 != nil +} + +func (p *ABCServiceEchoArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = c.NewRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} +func (p *ABCServiceEchoArgs) ReadField2(iprot thrift.TProtocol) error { + p.Req2 = c.NewRequest() + if err := p.Req2.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Echo_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *ABCServiceEchoArgs) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req2", thrift.STRUCT, 2); err != nil { + goto WriteFieldBeginError + } + if err := p.Req2.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} + +func (p *ABCServiceEchoArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoArgs(%+v)", *p) + +} + +func (p *ABCServiceEchoArgs) DeepEqual(ano *ABCServiceEchoArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + if !p.Field2DeepEqual(ano.Req2) { + return false + } + return true +} + +func (p *ABCServiceEchoArgs) Field1DeepEqual(src *c.Request) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} +func (p *ABCServiceEchoArgs) Field2DeepEqual(src *c.Request) bool { + + if !p.Req2.DeepEqual(src) { + return false + } + return true +} + +type ABCServiceEchoResult struct { + Success *c.Response `thrift:"success,0,optional" frugal:"0,optional,c.Response" json:"success,omitempty"` +} + +func NewABCServiceEchoResult() *ABCServiceEchoResult { + return &ABCServiceEchoResult{} +} + +func (p *ABCServiceEchoResult) InitDefault() { + *p = ABCServiceEchoResult{} +} + +var ABCServiceEchoResult_Success_DEFAULT *c.Response + +func (p *ABCServiceEchoResult) GetSuccess() (v *c.Response) { + if !p.IsSetSuccess() { + return ABCServiceEchoResult_Success_DEFAULT + } + return p.Success +} +func (p *ABCServiceEchoResult) SetSuccess(x interface{}) { + p.Success = x.(*c.Response) +} + +var fieldIDToName_ABCServiceEchoResult = map[int16]string{ + 0: "success", +} + +func (p *ABCServiceEchoResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ABCServiceEchoResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = c.NewResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Echo_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *ABCServiceEchoResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoResult(%+v)", *p) + +} + +func (p *ABCServiceEchoResult) DeepEqual(ano *ABCServiceEchoResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *ABCServiceEchoResult) Field0DeepEqual(src *c.Response) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} diff --git a/thrift_streaming/kitex_gen_cross/echo/k-api.go b/thrift_streaming/kitex_gen_cross/echo/k-api.go index fe4400c..5936474 100644 --- a/thrift_streaming/kitex_gen_cross/echo/k-api.go +++ b/thrift_streaming/kitex_gen_cross/echo/k-api.go @@ -11,6 +11,8 @@ import ( "github.com/apache/thrift/lib/go/thrift" "github.com/cloudwego/kitex/pkg/protocol/bthrift" + + "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_cross/a/b/c" ) // unused protection @@ -21,6 +23,7 @@ var ( _ = reflect.Type(nil) _ = thrift.TProtocol(nil) _ = bthrift.BinaryWriter(nil) + _ = c.KitexUnusedProtection ) func (p *EchoRequest) FastRead(buf []byte) (int, error) { @@ -1397,6 +1400,309 @@ func (p *PingPongOnlyServiceEchoPingPongNewResult) field0Length() int { return l } +func (p *ABCServiceEchoArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + case 2: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField2(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +func (p *ABCServiceEchoArgs) FastReadField2(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req2 = tmp + return offset, nil +} + +// for compatibility +func (p *ABCServiceEchoArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *ABCServiceEchoArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Echo_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField2(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Echo_args") + if p != nil { + l += p.field1Length() + l += p.field2Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *ABCServiceEchoArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoArgs) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req2", thrift.STRUCT, 2) + offset += p.Req2.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *ABCServiceEchoArgs) field2Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req2", thrift.STRUCT, 2) + l += p.Req2.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *ABCServiceEchoResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *ABCServiceEchoResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *ABCServiceEchoResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Echo_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Echo_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *ABCServiceEchoResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *ABCServiceEchoResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + func (p *EchoServiceEchoPingPongArgs) GetFirstArgument() interface{} { return p.Req1 } @@ -1428,3 +1734,11 @@ func (p *PingPongOnlyServiceEchoPingPongNewArgs) GetFirstArgument() interface{} func (p *PingPongOnlyServiceEchoPingPongNewResult) GetResult() interface{} { return p.Success } + +func (p *ABCServiceEchoArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *ABCServiceEchoResult) GetResult() interface{} { + return p.Success +} diff --git a/thrift_streaming/kitex_gen_old/a/b/c/a.b.c.go b/thrift_streaming/kitex_gen_old/a/b/c/a.b.c.go new file mode 100644 index 0000000..f5c0890 --- /dev/null +++ b/thrift_streaming/kitex_gen_old/a/b/c/a.b.c.go @@ -0,0 +1,333 @@ +// Code generated by thriftgo (0.3.4). DO NOT EDIT. + +package c + +import ( + "fmt" + "github.com/apache/thrift/lib/go/thrift" + "strings" +) + +type Request struct { + Message string `thrift:"message,1" frugal:"1,default,string" json:"message"` +} + +func NewRequest() *Request { + return &Request{} +} + +func (p *Request) InitDefault() { + *p = Request{} +} + +func (p *Request) GetMessage() (v string) { + return p.Message +} +func (p *Request) SetMessage(val string) { + p.Message = val +} + +var fieldIDToName_Request = map[int16]string{ + 1: "message", +} + +func (p *Request) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Request[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *Request) ReadField1(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadString(); err != nil { + return err + } else { + p.Message = v + } + return nil +} + +func (p *Request) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Request"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *Request) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Message); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *Request) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Request(%+v)", *p) + +} + +func (p *Request) DeepEqual(ano *Request) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Message) { + return false + } + return true +} + +func (p *Request) Field1DeepEqual(src string) bool { + + if strings.Compare(p.Message, src) != 0 { + return false + } + return true +} + +type Response struct { + Message string `thrift:"message,1" frugal:"1,default,string" json:"message"` +} + +func NewResponse() *Response { + return &Response{} +} + +func (p *Response) InitDefault() { + *p = Response{} +} + +func (p *Response) GetMessage() (v string) { + return p.Message +} +func (p *Response) SetMessage(val string) { + p.Message = val +} + +var fieldIDToName_Response = map[int16]string{ + 1: "message", +} + +func (p *Response) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Response[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *Response) ReadField1(iprot thrift.TProtocol) error { + + if v, err := iprot.ReadString(); err != nil { + return err + } else { + p.Message = v + } + return nil +} + +func (p *Response) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Response"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *Response) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { + goto WriteFieldBeginError + } + if err := oprot.WriteString(p.Message); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *Response) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Response(%+v)", *p) + +} + +func (p *Response) DeepEqual(ano *Response) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Message) { + return false + } + return true +} + +func (p *Response) Field1DeepEqual(src string) bool { + + if strings.Compare(p.Message, src) != 0 { + return false + } + return true +} diff --git a/thrift_streaming/kitex_gen_old/a/b/c/k-a.b.c.go b/thrift_streaming/kitex_gen_old/a/b/c/k-a.b.c.go new file mode 100644 index 0000000..b66b2ca --- /dev/null +++ b/thrift_streaming/kitex_gen_old/a/b/c/k-a.b.c.go @@ -0,0 +1,284 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package c + +import ( + "bytes" + "fmt" + "reflect" + "strings" + + "github.com/apache/thrift/lib/go/thrift" + + "github.com/cloudwego/kitex/pkg/protocol/bthrift" +) + +// unused protection +var ( + _ = fmt.Formatter(nil) + _ = (*bytes.Buffer)(nil) + _ = (*strings.Builder)(nil) + _ = reflect.Type(nil) + _ = thrift.TProtocol(nil) + _ = bthrift.BinaryWriter(nil) +) + +func (p *Request) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Request[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *Request) FastReadField1(buf []byte) (int, error) { + offset := 0 + + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.Message = v + + } + return offset, nil +} + +// for compatibility +func (p *Request) FastWrite(buf []byte) int { + return 0 +} + +func (p *Request) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Request") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *Request) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Request") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *Request) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) + + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Request) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) + l += bthrift.Binary.StringLengthNocopy(p.Message) + + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *Response) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Response[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *Response) FastReadField1(buf []byte) (int, error) { + offset := 0 + + if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + + p.Message = v + + } + return offset, nil +} + +// for compatibility +func (p *Response) FastWrite(buf []byte) int { + return 0 +} + +func (p *Response) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Response") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *Response) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Response") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *Response) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "message", thrift.STRING, 1) + offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Message) + + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *Response) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("message", thrift.STRING, 1) + l += bthrift.Binary.StringLengthNocopy(p.Message) + + l += bthrift.Binary.FieldEndLength() + return l +} diff --git a/thrift_streaming/kitex_gen_old/a/b/c/k-consts.go b/thrift_streaming/kitex_gen_old/a/b/c/k-consts.go new file mode 100644 index 0000000..2fdbc7e --- /dev/null +++ b/thrift_streaming/kitex_gen_old/a/b/c/k-consts.go @@ -0,0 +1,4 @@ +package c + +// KitexUnusedProtection is used to prevent 'imported and not used' error. +var KitexUnusedProtection = struct{}{} diff --git a/thrift_streaming/kitex_gen_old/echo/abcservice/abcservice.go b/thrift_streaming/kitex_gen_old/echo/abcservice/abcservice.go new file mode 100644 index 0000000..8884fa4 --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/abcservice/abcservice.go @@ -0,0 +1,193 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package abcservice + +import ( + "context" + c "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/a/b/c" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" +) + +func serviceInfo() *kitex.ServiceInfo { + return aBCServiceServiceInfo +} + +var aBCServiceServiceInfo = NewServiceInfo() + +func NewServiceInfo() *kitex.ServiceInfo { + serviceName := "ABCService" + handlerType := (*echo.ABCService)(nil) + methods := map[string]kitex.MethodInfo{ + "Echo": kitex.NewMethodInfo(echoHandler, newABCServiceEchoArgs, newABCServiceEchoResult, false), + "EchoBidirectional": kitex.NewMethodInfo(echoBidirectionalHandler, newABCServiceEchoBidirectionalArgs, newABCServiceEchoBidirectionalResult, false), + "EchoServer": kitex.NewMethodInfo(echoServerHandler, newABCServiceEchoServerArgs, newABCServiceEchoServerResult, false), + "EchoClient": kitex.NewMethodInfo(echoClientHandler, newABCServiceEchoClientArgs, newABCServiceEchoClientResult, false), + "EchoUnary": kitex.NewMethodInfo(echoUnaryHandler, newABCServiceEchoUnaryArgs, newABCServiceEchoUnaryResult, false), + } + extra := map[string]interface{}{ + "PackageName": "echo", + "ServiceFilePath": `idl/api.thrift`, + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.ABCServiceEchoArgs) + realResult := result.(*echo.ABCServiceEchoResult) + success, err := handler.(echo.ABCService).Echo(ctx, realArg.Req1, realArg.Req2) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newABCServiceEchoArgs() interface{} { + return echo.NewABCServiceEchoArgs() +} + +func newABCServiceEchoResult() interface{} { + return echo.NewABCServiceEchoResult() +} + +func echoBidirectionalHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.ABCServiceEchoBidirectionalArgs) + realResult := result.(*echo.ABCServiceEchoBidirectionalResult) + success, err := handler.(echo.ABCService).EchoBidirectional(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newABCServiceEchoBidirectionalArgs() interface{} { + return echo.NewABCServiceEchoBidirectionalArgs() +} + +func newABCServiceEchoBidirectionalResult() interface{} { + return echo.NewABCServiceEchoBidirectionalResult() +} + +func echoServerHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.ABCServiceEchoServerArgs) + realResult := result.(*echo.ABCServiceEchoServerResult) + success, err := handler.(echo.ABCService).EchoServer(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newABCServiceEchoServerArgs() interface{} { + return echo.NewABCServiceEchoServerArgs() +} + +func newABCServiceEchoServerResult() interface{} { + return echo.NewABCServiceEchoServerResult() +} + +func echoClientHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.ABCServiceEchoClientArgs) + realResult := result.(*echo.ABCServiceEchoClientResult) + success, err := handler.(echo.ABCService).EchoClient(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newABCServiceEchoClientArgs() interface{} { + return echo.NewABCServiceEchoClientArgs() +} + +func newABCServiceEchoClientResult() interface{} { + return echo.NewABCServiceEchoClientResult() +} + +func echoUnaryHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.ABCServiceEchoUnaryArgs) + realResult := result.(*echo.ABCServiceEchoUnaryResult) + success, err := handler.(echo.ABCService).EchoUnary(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newABCServiceEchoUnaryArgs() interface{} { + return echo.NewABCServiceEchoUnaryArgs() +} + +func newABCServiceEchoUnaryResult() interface{} { + return echo.NewABCServiceEchoUnaryResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) Echo(ctx context.Context, req1 *c.Request, req2 *c.Request) (r *c.Response, err error) { + var _args echo.ABCServiceEchoArgs + _args.Req1 = req1 + _args.Req2 = req2 + var _result echo.ABCServiceEchoResult + if err = p.c.Call(ctx, "Echo", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) EchoBidirectional(ctx context.Context, req1 *c.Request) (r *c.Response, err error) { + var _args echo.ABCServiceEchoBidirectionalArgs + _args.Req1 = req1 + var _result echo.ABCServiceEchoBidirectionalResult + if err = p.c.Call(ctx, "EchoBidirectional", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) EchoServer(ctx context.Context, req1 *c.Request) (r *c.Response, err error) { + var _args echo.ABCServiceEchoServerArgs + _args.Req1 = req1 + var _result echo.ABCServiceEchoServerResult + if err = p.c.Call(ctx, "EchoServer", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) EchoClient(ctx context.Context, req1 *c.Request) (r *c.Response, err error) { + var _args echo.ABCServiceEchoClientArgs + _args.Req1 = req1 + var _result echo.ABCServiceEchoClientResult + if err = p.c.Call(ctx, "EchoClient", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) EchoUnary(ctx context.Context, req1 *c.Request) (r *c.Response, err error) { + var _args echo.ABCServiceEchoUnaryArgs + _args.Req1 = req1 + var _result echo.ABCServiceEchoUnaryResult + if err = p.c.Call(ctx, "EchoUnary", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen_old/echo/abcservice/client.go b/thrift_streaming/kitex_gen_old/echo/abcservice/client.go new file mode 100644 index 0000000..527316c --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/abcservice/client.go @@ -0,0 +1,73 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package abcservice + +import ( + "context" + c "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/a/b/c" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + Echo(ctx context.Context, req1 *c.Request, req2 *c.Request, callOptions ...callopt.Option) (r *c.Response, err error) + EchoBidirectional(ctx context.Context, req1 *c.Request, callOptions ...callopt.Option) (r *c.Response, err error) + EchoServer(ctx context.Context, req1 *c.Request, callOptions ...callopt.Option) (r *c.Response, err error) + EchoClient(ctx context.Context, req1 *c.Request, callOptions ...callopt.Option) (r *c.Response, err error) + EchoUnary(ctx context.Context, req1 *c.Request, callOptions ...callopt.Option) (r *c.Response, err error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfo(), options...) + if err != nil { + return nil, err + } + return &kABCServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kABCServiceClient struct { + *kClient +} + +func (p *kABCServiceClient) Echo(ctx context.Context, req1 *c.Request, req2 *c.Request, callOptions ...callopt.Option) (r *c.Response, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.Echo(ctx, req1, req2) +} + +func (p *kABCServiceClient) EchoBidirectional(ctx context.Context, req1 *c.Request, callOptions ...callopt.Option) (r *c.Response, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoBidirectional(ctx, req1) +} + +func (p *kABCServiceClient) EchoServer(ctx context.Context, req1 *c.Request, callOptions ...callopt.Option) (r *c.Response, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoServer(ctx, req1) +} + +func (p *kABCServiceClient) EchoClient(ctx context.Context, req1 *c.Request, callOptions ...callopt.Option) (r *c.Response, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoClient(ctx, req1) +} + +func (p *kABCServiceClient) EchoUnary(ctx context.Context, req1 *c.Request, callOptions ...callopt.Option) (r *c.Response, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.EchoUnary(ctx, req1) +} diff --git a/thrift_streaming/kitex_gen_old/echo/abcservice/invoker.go b/thrift_streaming/kitex_gen_old/echo/abcservice/invoker.go new file mode 100644 index 0000000..21304a3 --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/abcservice/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package abcservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.ABCService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_old/echo/abcservice/server.go b/thrift_streaming/kitex_gen_old/echo/abcservice/server.go new file mode 100644 index 0000000..d4ae3d8 --- /dev/null +++ b/thrift_streaming/kitex_gen_old/echo/abcservice/server.go @@ -0,0 +1,20 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package abcservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.ABCService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_old/echo/api.go b/thrift_streaming/kitex_gen_old/echo/api.go index a767632..c59828e 100644 --- a/thrift_streaming/kitex_gen_old/echo/api.go +++ b/thrift_streaming/kitex_gen_old/echo/api.go @@ -6,6 +6,7 @@ import ( "context" "fmt" "github.com/apache/thrift/lib/go/thrift" + "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/a/b/c" "strings" ) @@ -820,6 +821,91 @@ func NewStreamOnlyServiceChildChildClient(c thrift.TClient) *StreamOnlyServiceCh } } +type ABCService interface { + Echo(ctx context.Context, req1 *c.Request, req2 *c.Request) (r *c.Response, err error) + + EchoBidirectional(ctx context.Context, req1 *c.Request) (r *c.Response, err error) + + EchoServer(ctx context.Context, req1 *c.Request) (r *c.Response, err error) + + EchoClient(ctx context.Context, req1 *c.Request) (r *c.Response, err error) + + EchoUnary(ctx context.Context, req1 *c.Request) (r *c.Response, err error) +} + +type ABCServiceClient struct { + c thrift.TClient +} + +func NewABCServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ABCServiceClient { + return &ABCServiceClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewABCServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *ABCServiceClient { + return &ABCServiceClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewABCServiceClient(c thrift.TClient) *ABCServiceClient { + return &ABCServiceClient{ + c: c, + } +} + +func (p *ABCServiceClient) Client_() thrift.TClient { + return p.c +} + +func (p *ABCServiceClient) Echo(ctx context.Context, req1 *c.Request, req2 *c.Request) (r *c.Response, err error) { + var _args ABCServiceEchoArgs + _args.Req1 = req1 + _args.Req2 = req2 + var _result ABCServiceEchoResult + if err = p.Client_().Call(ctx, "Echo", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} +func (p *ABCServiceClient) EchoBidirectional(ctx context.Context, req1 *c.Request) (r *c.Response, err error) { + var _args ABCServiceEchoBidirectionalArgs + _args.Req1 = req1 + var _result ABCServiceEchoBidirectionalResult + if err = p.Client_().Call(ctx, "EchoBidirectional", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} +func (p *ABCServiceClient) EchoServer(ctx context.Context, req1 *c.Request) (r *c.Response, err error) { + var _args ABCServiceEchoServerArgs + _args.Req1 = req1 + var _result ABCServiceEchoServerResult + if err = p.Client_().Call(ctx, "EchoServer", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} +func (p *ABCServiceClient) EchoClient(ctx context.Context, req1 *c.Request) (r *c.Response, err error) { + var _args ABCServiceEchoClientArgs + _args.Req1 = req1 + var _result ABCServiceEchoClientResult + if err = p.Client_().Call(ctx, "EchoClient", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} +func (p *ABCServiceClient) EchoUnary(ctx context.Context, req1 *c.Request) (r *c.Response, err error) { + var _args ABCServiceEchoUnaryArgs + _args.Req1 = req1 + var _result ABCServiceEchoUnaryResult + if err = p.Client_().Call(ctx, "EchoUnary", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + type EchoServiceProcessor struct { processorMap map[string]thrift.TProcessorFunction handler EchoService @@ -4762,3 +4848,2052 @@ func NewStreamOnlyServiceChildChildProcessor(handler StreamOnlyServiceChildChild self := &StreamOnlyServiceChildChildProcessor{NewStreamOnlyServiceChildProcessor(handler)} return self } + +type ABCServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler ABCService +} + +func (p *ABCServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *ABCServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *ABCServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewABCServiceProcessor(handler ABCService) *ABCServiceProcessor { + self := &ABCServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self.AddToProcessorMap("Echo", &aBCServiceProcessorEcho{handler: handler}) + self.AddToProcessorMap("EchoBidirectional", &aBCServiceProcessorEchoBidirectional{handler: handler}) + self.AddToProcessorMap("EchoServer", &aBCServiceProcessorEchoServer{handler: handler}) + self.AddToProcessorMap("EchoClient", &aBCServiceProcessorEchoClient{handler: handler}) + self.AddToProcessorMap("EchoUnary", &aBCServiceProcessorEchoUnary{handler: handler}) + return self +} +func (p *ABCServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return false, err + } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, x +} + +type aBCServiceProcessorEcho struct { + handler ABCService +} + +func (p *aBCServiceProcessorEcho) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := ABCServiceEchoArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("Echo", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := ABCServiceEchoResult{} + var retval *c.Response + if retval, err2 = p.handler.Echo(ctx, args.Req1, args.Req2); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Echo: "+err2.Error()) + oprot.WriteMessageBegin("Echo", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("Echo", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type aBCServiceProcessorEchoBidirectional struct { + handler ABCService +} + +func (p *aBCServiceProcessorEchoBidirectional) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := ABCServiceEchoBidirectionalArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("EchoBidirectional", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := ABCServiceEchoBidirectionalResult{} + var retval *c.Response + if retval, err2 = p.handler.EchoBidirectional(ctx, args.Req1); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoBidirectional: "+err2.Error()) + oprot.WriteMessageBegin("EchoBidirectional", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("EchoBidirectional", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type aBCServiceProcessorEchoServer struct { + handler ABCService +} + +func (p *aBCServiceProcessorEchoServer) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := ABCServiceEchoServerArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("EchoServer", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := ABCServiceEchoServerResult{} + var retval *c.Response + if retval, err2 = p.handler.EchoServer(ctx, args.Req1); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoServer: "+err2.Error()) + oprot.WriteMessageBegin("EchoServer", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("EchoServer", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type aBCServiceProcessorEchoClient struct { + handler ABCService +} + +func (p *aBCServiceProcessorEchoClient) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := ABCServiceEchoClientArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("EchoClient", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := ABCServiceEchoClientResult{} + var retval *c.Response + if retval, err2 = p.handler.EchoClient(ctx, args.Req1); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoClient: "+err2.Error()) + oprot.WriteMessageBegin("EchoClient", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("EchoClient", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type aBCServiceProcessorEchoUnary struct { + handler ABCService +} + +func (p *aBCServiceProcessorEchoUnary) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := ABCServiceEchoUnaryArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("EchoUnary", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return false, err + } + + iprot.ReadMessageEnd() + var err2 error + result := ABCServiceEchoUnaryResult{} + var retval *c.Response + if retval, err2 = p.handler.EchoUnary(ctx, args.Req1); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing EchoUnary: "+err2.Error()) + oprot.WriteMessageBegin("EchoUnary", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush(ctx) + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("EchoUnary", thrift.REPLY, seqId); err2 != nil { + err = err2 + } + if err2 = result.Write(oprot); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { + err = err2 + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type ABCServiceEchoArgs struct { + Req1 *c.Request `thrift:"req1,1" frugal:"1,default,c.Request" json:"req1"` + Req2 *c.Request `thrift:"req2,2" frugal:"2,default,c.Request" json:"req2"` +} + +func NewABCServiceEchoArgs() *ABCServiceEchoArgs { + return &ABCServiceEchoArgs{} +} + +func (p *ABCServiceEchoArgs) InitDefault() { + *p = ABCServiceEchoArgs{} +} + +var ABCServiceEchoArgs_Req1_DEFAULT *c.Request + +func (p *ABCServiceEchoArgs) GetReq1() (v *c.Request) { + if !p.IsSetReq1() { + return ABCServiceEchoArgs_Req1_DEFAULT + } + return p.Req1 +} + +var ABCServiceEchoArgs_Req2_DEFAULT *c.Request + +func (p *ABCServiceEchoArgs) GetReq2() (v *c.Request) { + if !p.IsSetReq2() { + return ABCServiceEchoArgs_Req2_DEFAULT + } + return p.Req2 +} +func (p *ABCServiceEchoArgs) SetReq1(val *c.Request) { + p.Req1 = val +} +func (p *ABCServiceEchoArgs) SetReq2(val *c.Request) { + p.Req2 = val +} + +var fieldIDToName_ABCServiceEchoArgs = map[int16]string{ + 1: "req1", + 2: "req2", +} + +func (p *ABCServiceEchoArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *ABCServiceEchoArgs) IsSetReq2() bool { + return p.Req2 != nil +} + +func (p *ABCServiceEchoArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField2(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = c.NewRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} +func (p *ABCServiceEchoArgs) ReadField2(iprot thrift.TProtocol) error { + p.Req2 = c.NewRequest() + if err := p.Req2.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Echo_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + if err = p.writeField2(oprot); err != nil { + fieldId = 2 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *ABCServiceEchoArgs) writeField2(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req2", thrift.STRUCT, 2); err != nil { + goto WriteFieldBeginError + } + if err := p.Req2.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) +} + +func (p *ABCServiceEchoArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoArgs(%+v)", *p) + +} + +func (p *ABCServiceEchoArgs) DeepEqual(ano *ABCServiceEchoArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + if !p.Field2DeepEqual(ano.Req2) { + return false + } + return true +} + +func (p *ABCServiceEchoArgs) Field1DeepEqual(src *c.Request) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} +func (p *ABCServiceEchoArgs) Field2DeepEqual(src *c.Request) bool { + + if !p.Req2.DeepEqual(src) { + return false + } + return true +} + +type ABCServiceEchoResult struct { + Success *c.Response `thrift:"success,0,optional" frugal:"0,optional,c.Response" json:"success,omitempty"` +} + +func NewABCServiceEchoResult() *ABCServiceEchoResult { + return &ABCServiceEchoResult{} +} + +func (p *ABCServiceEchoResult) InitDefault() { + *p = ABCServiceEchoResult{} +} + +var ABCServiceEchoResult_Success_DEFAULT *c.Response + +func (p *ABCServiceEchoResult) GetSuccess() (v *c.Response) { + if !p.IsSetSuccess() { + return ABCServiceEchoResult_Success_DEFAULT + } + return p.Success +} +func (p *ABCServiceEchoResult) SetSuccess(x interface{}) { + p.Success = x.(*c.Response) +} + +var fieldIDToName_ABCServiceEchoResult = map[int16]string{ + 0: "success", +} + +func (p *ABCServiceEchoResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ABCServiceEchoResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = c.NewResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("Echo_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *ABCServiceEchoResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoResult(%+v)", *p) + +} + +func (p *ABCServiceEchoResult) DeepEqual(ano *ABCServiceEchoResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *ABCServiceEchoResult) Field0DeepEqual(src *c.Response) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type ABCServiceEchoBidirectionalArgs struct { + Req1 *c.Request `thrift:"req1,1" frugal:"1,default,c.Request" json:"req1"` +} + +func NewABCServiceEchoBidirectionalArgs() *ABCServiceEchoBidirectionalArgs { + return &ABCServiceEchoBidirectionalArgs{} +} + +func (p *ABCServiceEchoBidirectionalArgs) InitDefault() { + *p = ABCServiceEchoBidirectionalArgs{} +} + +var ABCServiceEchoBidirectionalArgs_Req1_DEFAULT *c.Request + +func (p *ABCServiceEchoBidirectionalArgs) GetReq1() (v *c.Request) { + if !p.IsSetReq1() { + return ABCServiceEchoBidirectionalArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *ABCServiceEchoBidirectionalArgs) SetReq1(val *c.Request) { + p.Req1 = val +} + +var fieldIDToName_ABCServiceEchoBidirectionalArgs = map[int16]string{ + 1: "req1", +} + +func (p *ABCServiceEchoBidirectionalArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *ABCServiceEchoBidirectionalArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoBidirectionalArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoBidirectionalArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = c.NewRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoBidirectionalArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoBidirectional_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoBidirectionalArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *ABCServiceEchoBidirectionalArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoBidirectionalArgs(%+v)", *p) + +} + +func (p *ABCServiceEchoBidirectionalArgs) DeepEqual(ano *ABCServiceEchoBidirectionalArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *ABCServiceEchoBidirectionalArgs) Field1DeepEqual(src *c.Request) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type ABCServiceEchoBidirectionalResult struct { + Success *c.Response `thrift:"success,0,optional" frugal:"0,optional,c.Response" json:"success,omitempty"` +} + +func NewABCServiceEchoBidirectionalResult() *ABCServiceEchoBidirectionalResult { + return &ABCServiceEchoBidirectionalResult{} +} + +func (p *ABCServiceEchoBidirectionalResult) InitDefault() { + *p = ABCServiceEchoBidirectionalResult{} +} + +var ABCServiceEchoBidirectionalResult_Success_DEFAULT *c.Response + +func (p *ABCServiceEchoBidirectionalResult) GetSuccess() (v *c.Response) { + if !p.IsSetSuccess() { + return ABCServiceEchoBidirectionalResult_Success_DEFAULT + } + return p.Success +} +func (p *ABCServiceEchoBidirectionalResult) SetSuccess(x interface{}) { + p.Success = x.(*c.Response) +} + +var fieldIDToName_ABCServiceEchoBidirectionalResult = map[int16]string{ + 0: "success", +} + +func (p *ABCServiceEchoBidirectionalResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ABCServiceEchoBidirectionalResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoBidirectionalResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoBidirectionalResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = c.NewResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoBidirectionalResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoBidirectional_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoBidirectionalResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *ABCServiceEchoBidirectionalResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoBidirectionalResult(%+v)", *p) + +} + +func (p *ABCServiceEchoBidirectionalResult) DeepEqual(ano *ABCServiceEchoBidirectionalResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *ABCServiceEchoBidirectionalResult) Field0DeepEqual(src *c.Response) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type ABCServiceEchoServerArgs struct { + Req1 *c.Request `thrift:"req1,1" frugal:"1,default,c.Request" json:"req1"` +} + +func NewABCServiceEchoServerArgs() *ABCServiceEchoServerArgs { + return &ABCServiceEchoServerArgs{} +} + +func (p *ABCServiceEchoServerArgs) InitDefault() { + *p = ABCServiceEchoServerArgs{} +} + +var ABCServiceEchoServerArgs_Req1_DEFAULT *c.Request + +func (p *ABCServiceEchoServerArgs) GetReq1() (v *c.Request) { + if !p.IsSetReq1() { + return ABCServiceEchoServerArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *ABCServiceEchoServerArgs) SetReq1(val *c.Request) { + p.Req1 = val +} + +var fieldIDToName_ABCServiceEchoServerArgs = map[int16]string{ + 1: "req1", +} + +func (p *ABCServiceEchoServerArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *ABCServiceEchoServerArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoServerArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoServerArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = c.NewRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoServerArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoServer_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoServerArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *ABCServiceEchoServerArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoServerArgs(%+v)", *p) + +} + +func (p *ABCServiceEchoServerArgs) DeepEqual(ano *ABCServiceEchoServerArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *ABCServiceEchoServerArgs) Field1DeepEqual(src *c.Request) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type ABCServiceEchoServerResult struct { + Success *c.Response `thrift:"success,0,optional" frugal:"0,optional,c.Response" json:"success,omitempty"` +} + +func NewABCServiceEchoServerResult() *ABCServiceEchoServerResult { + return &ABCServiceEchoServerResult{} +} + +func (p *ABCServiceEchoServerResult) InitDefault() { + *p = ABCServiceEchoServerResult{} +} + +var ABCServiceEchoServerResult_Success_DEFAULT *c.Response + +func (p *ABCServiceEchoServerResult) GetSuccess() (v *c.Response) { + if !p.IsSetSuccess() { + return ABCServiceEchoServerResult_Success_DEFAULT + } + return p.Success +} +func (p *ABCServiceEchoServerResult) SetSuccess(x interface{}) { + p.Success = x.(*c.Response) +} + +var fieldIDToName_ABCServiceEchoServerResult = map[int16]string{ + 0: "success", +} + +func (p *ABCServiceEchoServerResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ABCServiceEchoServerResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoServerResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoServerResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = c.NewResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoServerResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoServer_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoServerResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *ABCServiceEchoServerResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoServerResult(%+v)", *p) + +} + +func (p *ABCServiceEchoServerResult) DeepEqual(ano *ABCServiceEchoServerResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *ABCServiceEchoServerResult) Field0DeepEqual(src *c.Response) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type ABCServiceEchoClientArgs struct { + Req1 *c.Request `thrift:"req1,1" frugal:"1,default,c.Request" json:"req1"` +} + +func NewABCServiceEchoClientArgs() *ABCServiceEchoClientArgs { + return &ABCServiceEchoClientArgs{} +} + +func (p *ABCServiceEchoClientArgs) InitDefault() { + *p = ABCServiceEchoClientArgs{} +} + +var ABCServiceEchoClientArgs_Req1_DEFAULT *c.Request + +func (p *ABCServiceEchoClientArgs) GetReq1() (v *c.Request) { + if !p.IsSetReq1() { + return ABCServiceEchoClientArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *ABCServiceEchoClientArgs) SetReq1(val *c.Request) { + p.Req1 = val +} + +var fieldIDToName_ABCServiceEchoClientArgs = map[int16]string{ + 1: "req1", +} + +func (p *ABCServiceEchoClientArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *ABCServiceEchoClientArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoClientArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoClientArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = c.NewRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoClientArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoClient_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoClientArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *ABCServiceEchoClientArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoClientArgs(%+v)", *p) + +} + +func (p *ABCServiceEchoClientArgs) DeepEqual(ano *ABCServiceEchoClientArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *ABCServiceEchoClientArgs) Field1DeepEqual(src *c.Request) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type ABCServiceEchoClientResult struct { + Success *c.Response `thrift:"success,0,optional" frugal:"0,optional,c.Response" json:"success,omitempty"` +} + +func NewABCServiceEchoClientResult() *ABCServiceEchoClientResult { + return &ABCServiceEchoClientResult{} +} + +func (p *ABCServiceEchoClientResult) InitDefault() { + *p = ABCServiceEchoClientResult{} +} + +var ABCServiceEchoClientResult_Success_DEFAULT *c.Response + +func (p *ABCServiceEchoClientResult) GetSuccess() (v *c.Response) { + if !p.IsSetSuccess() { + return ABCServiceEchoClientResult_Success_DEFAULT + } + return p.Success +} +func (p *ABCServiceEchoClientResult) SetSuccess(x interface{}) { + p.Success = x.(*c.Response) +} + +var fieldIDToName_ABCServiceEchoClientResult = map[int16]string{ + 0: "success", +} + +func (p *ABCServiceEchoClientResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ABCServiceEchoClientResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoClientResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoClientResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = c.NewResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoClientResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoClient_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoClientResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *ABCServiceEchoClientResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoClientResult(%+v)", *p) + +} + +func (p *ABCServiceEchoClientResult) DeepEqual(ano *ABCServiceEchoClientResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *ABCServiceEchoClientResult) Field0DeepEqual(src *c.Response) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} + +type ABCServiceEchoUnaryArgs struct { + Req1 *c.Request `thrift:"req1,1" frugal:"1,default,c.Request" json:"req1"` +} + +func NewABCServiceEchoUnaryArgs() *ABCServiceEchoUnaryArgs { + return &ABCServiceEchoUnaryArgs{} +} + +func (p *ABCServiceEchoUnaryArgs) InitDefault() { + *p = ABCServiceEchoUnaryArgs{} +} + +var ABCServiceEchoUnaryArgs_Req1_DEFAULT *c.Request + +func (p *ABCServiceEchoUnaryArgs) GetReq1() (v *c.Request) { + if !p.IsSetReq1() { + return ABCServiceEchoUnaryArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *ABCServiceEchoUnaryArgs) SetReq1(val *c.Request) { + p.Req1 = val +} + +var fieldIDToName_ABCServiceEchoUnaryArgs = map[int16]string{ + 1: "req1", +} + +func (p *ABCServiceEchoUnaryArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *ABCServiceEchoUnaryArgs) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField1(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoUnaryArgs[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoUnaryArgs) ReadField1(iprot thrift.TProtocol) error { + p.Req1 = c.NewRequest() + if err := p.Req1.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoUnaryArgs) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoUnary_args"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField1(oprot); err != nil { + fieldId = 1 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoUnaryArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err = oprot.WriteFieldBegin("req1", thrift.STRUCT, 1); err != nil { + goto WriteFieldBeginError + } + if err := p.Req1.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) +} + +func (p *ABCServiceEchoUnaryArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoUnaryArgs(%+v)", *p) + +} + +func (p *ABCServiceEchoUnaryArgs) DeepEqual(ano *ABCServiceEchoUnaryArgs) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field1DeepEqual(ano.Req1) { + return false + } + return true +} + +func (p *ABCServiceEchoUnaryArgs) Field1DeepEqual(src *c.Request) bool { + + if !p.Req1.DeepEqual(src) { + return false + } + return true +} + +type ABCServiceEchoUnaryResult struct { + Success *c.Response `thrift:"success,0,optional" frugal:"0,optional,c.Response" json:"success,omitempty"` +} + +func NewABCServiceEchoUnaryResult() *ABCServiceEchoUnaryResult { + return &ABCServiceEchoUnaryResult{} +} + +func (p *ABCServiceEchoUnaryResult) InitDefault() { + *p = ABCServiceEchoUnaryResult{} +} + +var ABCServiceEchoUnaryResult_Success_DEFAULT *c.Response + +func (p *ABCServiceEchoUnaryResult) GetSuccess() (v *c.Response) { + if !p.IsSetSuccess() { + return ABCServiceEchoUnaryResult_Success_DEFAULT + } + return p.Success +} +func (p *ABCServiceEchoUnaryResult) SetSuccess(x interface{}) { + p.Success = x.(*c.Response) +} + +var fieldIDToName_ABCServiceEchoUnaryResult = map[int16]string{ + 0: "success", +} + +func (p *ABCServiceEchoUnaryResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ABCServiceEchoUnaryResult) Read(iprot thrift.TProtocol) (err error) { + + var fieldTypeId thrift.TType + var fieldId int16 + + if _, err = iprot.ReadStructBegin(); err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err = p.ReadField0(iprot); err != nil { + goto ReadFieldError + } + } else if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + default: + if err = iprot.Skip(fieldTypeId); err != nil { + goto SkipFieldError + } + } + if err = iprot.ReadFieldEnd(); err != nil { + goto ReadFieldEndError + } + } + if err = iprot.ReadStructEnd(); err != nil { + goto ReadStructEndError + } + + return nil +ReadStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoUnaryResult[fieldId]), err) +SkipFieldError: + return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) + +ReadFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoUnaryResult) ReadField0(iprot thrift.TProtocol) error { + p.Success = c.NewResponse() + if err := p.Success.Read(iprot); err != nil { + return err + } + return nil +} + +func (p *ABCServiceEchoUnaryResult) Write(oprot thrift.TProtocol) (err error) { + var fieldId int16 + if err = oprot.WriteStructBegin("EchoUnary_result"); err != nil { + goto WriteStructBeginError + } + if p != nil { + if err = p.writeField0(oprot); err != nil { + fieldId = 0 + goto WriteFieldError + } + } + if err = oprot.WriteFieldStop(); err != nil { + goto WriteFieldStopError + } + if err = oprot.WriteStructEnd(); err != nil { + goto WriteStructEndError + } + return nil +WriteStructBeginError: + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) +WriteFieldError: + return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) +WriteFieldStopError: + return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) +WriteStructEndError: + return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) +} + +func (p *ABCServiceEchoUnaryResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + goto WriteFieldBeginError + } + if err := p.Success.Write(oprot); err != nil { + return err + } + if err = oprot.WriteFieldEnd(); err != nil { + goto WriteFieldEndError + } + } + return nil +WriteFieldBeginError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err) +WriteFieldEndError: + return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err) +} + +func (p *ABCServiceEchoUnaryResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoUnaryResult(%+v)", *p) + +} + +func (p *ABCServiceEchoUnaryResult) DeepEqual(ano *ABCServiceEchoUnaryResult) bool { + if p == ano { + return true + } else if p == nil || ano == nil { + return false + } + if !p.Field0DeepEqual(ano.Success) { + return false + } + return true +} + +func (p *ABCServiceEchoUnaryResult) Field0DeepEqual(src *c.Response) bool { + + if !p.Success.DeepEqual(src) { + return false + } + return true +} diff --git a/thrift_streaming/kitex_gen_old/echo/k-api.go b/thrift_streaming/kitex_gen_old/echo/k-api.go index 9eaa6c2..0e37142 100644 --- a/thrift_streaming/kitex_gen_old/echo/k-api.go +++ b/thrift_streaming/kitex_gen_old/echo/k-api.go @@ -11,6 +11,8 @@ import ( "github.com/apache/thrift/lib/go/thrift" "github.com/cloudwego/kitex/pkg/protocol/bthrift" + + "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_old/a/b/c" ) // unused protection @@ -21,6 +23,7 @@ var ( _ = reflect.Type(nil) _ = thrift.TProtocol(nil) _ = bthrift.BinaryWriter(nil) + _ = c.KitexUnusedProtection ) func (p *EchoRequest) FastRead(buf []byte) (int, error) { @@ -2945,82 +2948,1457 @@ func (p *StreamOnlyServiceEchoBidirectionalNewResult) field0Length() int { return l } -func (p *EchoServiceEchoBidirectionalArgs) GetFirstArgument() interface{} { - return p.Req1 -} +func (p *ABCServiceEchoArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } -func (p *EchoServiceEchoBidirectionalResult) GetResult() interface{} { - return p.Success -} + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + case 2: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField2(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } -func (p *EchoServiceEchoClientArgs) GetFirstArgument() interface{} { - return p.Req1 -} + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } -func (p *EchoServiceEchoClientResult) GetResult() interface{} { - return p.Success + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *EchoServiceEchoServerArgs) GetFirstArgument() interface{} { - return p.Req1 -} +func (p *ABCServiceEchoArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 -func (p *EchoServiceEchoServerResult) GetResult() interface{} { - return p.Success + tmp := c.NewRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil } -func (p *EchoServiceEchoUnaryArgs) GetFirstArgument() interface{} { - return p.Req1 -} +func (p *ABCServiceEchoArgs) FastReadField2(buf []byte) (int, error) { + offset := 0 -func (p *EchoServiceEchoUnaryResult) GetResult() interface{} { - return p.Success + tmp := c.NewRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req2 = tmp + return offset, nil } -func (p *EchoServiceEchoPingPongArgs) GetFirstArgument() interface{} { - return p.Req1 +// for compatibility +func (p *ABCServiceEchoArgs) FastWrite(buf []byte) int { + return 0 } -func (p *EchoServiceEchoPingPongResult) GetResult() interface{} { - return p.Success +func (p *ABCServiceEchoArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Echo_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + offset += p.fastWriteField2(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset } -func (p *EchoServiceEchoOnewayArgs) GetFirstArgument() interface{} { - return p.Req1 +func (p *ABCServiceEchoArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Echo_args") + if p != nil { + l += p.field1Length() + l += p.field2Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l } -func (p *EchoServiceEchoOnewayResult) GetResult() interface{} { - return nil +func (p *ABCServiceEchoArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset } -func (p *EchoServicePingArgs) GetFirstArgument() interface{} { - return nil +func (p *ABCServiceEchoArgs) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req2", thrift.STRUCT, 2) + offset += p.Req2.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset } -func (p *EchoServicePingResult) GetResult() interface{} { - return nil +func (p *ABCServiceEchoArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l } -func (p *PingPongOnlyServiceEchoPingPongNewArgs) GetFirstArgument() interface{} { - return p.Req1 +func (p *ABCServiceEchoArgs) field2Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req2", thrift.STRUCT, 2) + l += p.Req2.BLength() + l += bthrift.Binary.FieldEndLength() + return l } -func (p *PingPongOnlyServiceEchoPingPongNewResult) GetResult() interface{} { - return p.Success -} +func (p *ABCServiceEchoResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) GetFirstArgument() interface{} { - return p.Req1 + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } -func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) GetResult() interface{} { - return p.Success +func (p *ABCServiceEchoResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil } -func (p *StreamOnlyServiceEchoBidirectionalNewArgs) GetFirstArgument() interface{} { - return p.Req1 +// for compatibility +func (p *ABCServiceEchoResult) FastWrite(buf []byte) int { + return 0 } -func (p *StreamOnlyServiceEchoBidirectionalNewResult) GetResult() interface{} { +func (p *ABCServiceEchoResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Echo_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("Echo_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *ABCServiceEchoResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *ABCServiceEchoResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *ABCServiceEchoBidirectionalArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoBidirectionalArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoBidirectionalArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *ABCServiceEchoBidirectionalArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *ABCServiceEchoBidirectionalArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectional_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoBidirectionalArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoBidirectional_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *ABCServiceEchoBidirectionalArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoBidirectionalArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *ABCServiceEchoBidirectionalResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoBidirectionalResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoBidirectionalResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *ABCServiceEchoBidirectionalResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *ABCServiceEchoBidirectionalResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoBidirectional_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoBidirectionalResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoBidirectional_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *ABCServiceEchoBidirectionalResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *ABCServiceEchoBidirectionalResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *ABCServiceEchoServerArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoServerArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoServerArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *ABCServiceEchoServerArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *ABCServiceEchoServerArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoServer_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoServerArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoServer_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *ABCServiceEchoServerArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoServerArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *ABCServiceEchoServerResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoServerResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoServerResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *ABCServiceEchoServerResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *ABCServiceEchoServerResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoServer_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoServerResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoServer_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *ABCServiceEchoServerResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *ABCServiceEchoServerResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *ABCServiceEchoClientArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoClientArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoClientArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *ABCServiceEchoClientArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *ABCServiceEchoClientArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoClient_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoClientArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoClient_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *ABCServiceEchoClientArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoClientArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *ABCServiceEchoClientResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoClientResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoClientResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *ABCServiceEchoClientResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *ABCServiceEchoClientResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoClient_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoClientResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoClient_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *ABCServiceEchoClientResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *ABCServiceEchoClientResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *ABCServiceEchoUnaryArgs) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField1(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoUnaryArgs[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoUnaryArgs) FastReadField1(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewRequest() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Req1 = tmp + return offset, nil +} + +// for compatibility +func (p *ABCServiceEchoUnaryArgs) FastWrite(buf []byte) int { + return 0 +} + +func (p *ABCServiceEchoUnaryArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoUnary_args") + if p != nil { + offset += p.fastWriteField1(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoUnaryArgs) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoUnary_args") + if p != nil { + l += p.field1Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *ABCServiceEchoUnaryArgs) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "req1", thrift.STRUCT, 1) + offset += p.Req1.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoUnaryArgs) field1Length() int { + l := 0 + l += bthrift.Binary.FieldBeginLength("req1", thrift.STRUCT, 1) + l += p.Req1.BLength() + l += bthrift.Binary.FieldEndLength() + return l +} + +func (p *ABCServiceEchoUnaryResult) FastRead(buf []byte) (int, error) { + var err error + var offset int + var l int + var fieldTypeId thrift.TType + var fieldId int16 + _, l, err = bthrift.Binary.ReadStructBegin(buf) + offset += l + if err != nil { + goto ReadStructBeginError + } + + for { + _, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldBeginError + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + l, err = p.FastReadField0(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldError + } + } else { + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + default: + l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId) + offset += l + if err != nil { + goto SkipFieldError + } + } + + l, err = bthrift.Binary.ReadFieldEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadFieldEndError + } + } + l, err = bthrift.Binary.ReadStructEnd(buf[offset:]) + offset += l + if err != nil { + goto ReadStructEndError + } + + return offset, nil +ReadStructBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) +ReadFieldBeginError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) +ReadFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_ABCServiceEchoUnaryResult[fieldId]), err) +SkipFieldError: + return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) +ReadFieldEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) +ReadStructEndError: + return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) +} + +func (p *ABCServiceEchoUnaryResult) FastReadField0(buf []byte) (int, error) { + offset := 0 + + tmp := c.NewResponse() + if l, err := tmp.FastRead(buf[offset:]); err != nil { + return offset, err + } else { + offset += l + } + p.Success = tmp + return offset, nil +} + +// for compatibility +func (p *ABCServiceEchoUnaryResult) FastWrite(buf []byte) int { + return 0 +} + +func (p *ABCServiceEchoUnaryResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + offset += bthrift.Binary.WriteStructBegin(buf[offset:], "EchoUnary_result") + if p != nil { + offset += p.fastWriteField0(buf[offset:], binaryWriter) + } + offset += bthrift.Binary.WriteFieldStop(buf[offset:]) + offset += bthrift.Binary.WriteStructEnd(buf[offset:]) + return offset +} + +func (p *ABCServiceEchoUnaryResult) BLength() int { + l := 0 + l += bthrift.Binary.StructBeginLength("EchoUnary_result") + if p != nil { + l += p.field0Length() + } + l += bthrift.Binary.FieldStopLength() + l += bthrift.Binary.StructEndLength() + return l +} + +func (p *ABCServiceEchoUnaryResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int { + offset := 0 + if p.IsSetSuccess() { + offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0) + offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter) + offset += bthrift.Binary.WriteFieldEnd(buf[offset:]) + } + return offset +} + +func (p *ABCServiceEchoUnaryResult) field0Length() int { + l := 0 + if p.IsSetSuccess() { + l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0) + l += p.Success.BLength() + l += bthrift.Binary.FieldEndLength() + } + return l +} + +func (p *EchoServiceEchoBidirectionalArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *EchoServiceEchoBidirectionalResult) GetResult() interface{} { + return p.Success +} + +func (p *EchoServiceEchoClientArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *EchoServiceEchoClientResult) GetResult() interface{} { + return p.Success +} + +func (p *EchoServiceEchoServerArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *EchoServiceEchoServerResult) GetResult() interface{} { + return p.Success +} + +func (p *EchoServiceEchoUnaryArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *EchoServiceEchoUnaryResult) GetResult() interface{} { + return p.Success +} + +func (p *EchoServiceEchoPingPongArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *EchoServiceEchoPingPongResult) GetResult() interface{} { + return p.Success +} + +func (p *EchoServiceEchoOnewayArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *EchoServiceEchoOnewayResult) GetResult() interface{} { + return nil +} + +func (p *EchoServicePingArgs) GetFirstArgument() interface{} { + return nil +} + +func (p *EchoServicePingResult) GetResult() interface{} { + return nil +} + +func (p *PingPongOnlyServiceEchoPingPongNewArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *PingPongOnlyServiceEchoPingPongNewResult) GetResult() interface{} { + return p.Success +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *PingPongOnlyServiceChildEchoBidirectionalExtendedResult) GetResult() interface{} { + return p.Success +} + +func (p *StreamOnlyServiceEchoBidirectionalNewArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *StreamOnlyServiceEchoBidirectionalNewResult) GetResult() interface{} { + return p.Success +} + +func (p *ABCServiceEchoArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *ABCServiceEchoResult) GetResult() interface{} { + return p.Success +} + +func (p *ABCServiceEchoBidirectionalArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *ABCServiceEchoBidirectionalResult) GetResult() interface{} { + return p.Success +} + +func (p *ABCServiceEchoServerArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *ABCServiceEchoServerResult) GetResult() interface{} { + return p.Success +} + +func (p *ABCServiceEchoClientArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *ABCServiceEchoClientResult) GetResult() interface{} { + return p.Success +} + +func (p *ABCServiceEchoUnaryArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +func (p *ABCServiceEchoUnaryResult) GetResult() interface{} { return p.Success } diff --git a/thrift_streaming/kitex_gen_slim/a/b/c/a.b.c.go b/thrift_streaming/kitex_gen_slim/a/b/c/a.b.c.go new file mode 100644 index 0000000..9a6cb0b --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/a/b/c/a.b.c.go @@ -0,0 +1,59 @@ +// Code generated by thriftgo (0.3.6). DO NOT EDIT. + +package c + +import ( + "fmt" +) + +type Request struct { + Message string `thrift:"message,1" frugal:"1,default,string" json:"message"` +} + +func NewRequest() *Request { + return &Request{} +} + +func (p *Request) InitDefault() { + *p = Request{} +} + +func (p *Request) GetMessage() (v string) { + return p.Message +} +func (p *Request) SetMessage(val string) { + p.Message = val +} + +func (p *Request) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Request(%+v)", *p) +} + +type Response struct { + Message string `thrift:"message,1" frugal:"1,default,string" json:"message"` +} + +func NewResponse() *Response { + return &Response{} +} + +func (p *Response) InitDefault() { + *p = Response{} +} + +func (p *Response) GetMessage() (v string) { + return p.Message +} +func (p *Response) SetMessage(val string) { + p.Message = val +} + +func (p *Response) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Response(%+v)", *p) +} diff --git a/thrift_streaming/kitex_gen_slim/a/b/c/k-a.b.c.go b/thrift_streaming/kitex_gen_slim/a/b/c/k-a.b.c.go new file mode 100644 index 0000000..022f043 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/a/b/c/k-a.b.c.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package c + +import ( + "bytes" + "fmt" + "reflect" + "strings" + + "github.com/apache/thrift/lib/go/thrift" +) + +// unused protection +var ( + _ = fmt.Formatter(nil) + _ = (*bytes.Buffer)(nil) + _ = (*strings.Builder)(nil) + _ = reflect.Type(nil) + _ = thrift.TProtocol(nil) +) diff --git a/thrift_streaming/kitex_gen_slim/a/b/c/k-consts.go b/thrift_streaming/kitex_gen_slim/a/b/c/k-consts.go new file mode 100644 index 0000000..2fdbc7e --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/a/b/c/k-consts.go @@ -0,0 +1,4 @@ +package c + +// KitexUnusedProtection is used to prevent 'imported and not used' error. +var KitexUnusedProtection = struct{}{} diff --git a/thrift_streaming/kitex_gen_slim/combine/b/client.go b/thrift_streaming/kitex_gen_slim/combine/b/client.go index eda7a6a..14535a0 100644 --- a/thrift_streaming/kitex_gen_slim/combine/b/client.go +++ b/thrift_streaming/kitex_gen_slim/combine/b/client.go @@ -6,7 +6,6 @@ import ( "context" combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/combine" client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" "github.com/cloudwego/kitex/client/callopt/streamcall" "github.com/cloudwego/kitex/client/streamclient" streaming "github.com/cloudwego/kitex/pkg/streaming" diff --git a/thrift_streaming/kitex_gen_slim/combine/combine.go b/thrift_streaming/kitex_gen_slim/combine/combine.go index 5b8e843..26c5b4c 100644 --- a/thrift_streaming/kitex_gen_slim/combine/combine.go +++ b/thrift_streaming/kitex_gen_slim/combine/combine.go @@ -1,4 +1,4 @@ -// Code generated by thriftgo (0.3.5). DO NOT EDIT. +// Code generated by thriftgo (0.3.6). DO NOT EDIT. package combine diff --git a/thrift_streaming/kitex_gen_slim/combine/combineservice/client.go b/thrift_streaming/kitex_gen_slim/combine/combineservice/client.go index 26a15be..e4d3722 100644 --- a/thrift_streaming/kitex_gen_slim/combine/combineservice/client.go +++ b/thrift_streaming/kitex_gen_slim/combine/combineservice/client.go @@ -7,6 +7,10 @@ import ( combine "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/combine" client "github.com/cloudwego/kitex/client" callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" ) // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. @@ -14,6 +18,11 @@ type Client interface { Foo(ctx context.Context, req *combine.Req, callOptions ...callopt.Option) (r *combine.Rsp, err error) } +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + Bar(ctx context.Context, callOptions ...streamcall.Option) (stream B_BarClient, err error) +} + type B_BarClient interface { streaming.Stream Send(*combine.Req) error @@ -53,3 +62,38 @@ func (p *kCombineServiceClient) Foo(ctx context.Context, req *combine.Req, callO ctx = client.NewCtxWithCallOptions(ctx, callOptions) return p.kClient.Foo(ctx, req) } + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kCombineServiceStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kCombineServiceStreamClient struct { + *kClient +} + +func (p *kCombineServiceStreamClient) Bar(ctx context.Context, callOptions ...streamcall.Option) (stream B_BarClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.Bar(ctx) +} diff --git a/thrift_streaming/kitex_gen_slim/combine/combineservice/combineservice.go b/thrift_streaming/kitex_gen_slim/combine/combineservice/combineservice.go index fbe6eb9..42222e0 100644 --- a/thrift_streaming/kitex_gen_slim/combine/combineservice/combineservice.go +++ b/thrift_streaming/kitex_gen_slim/combine/combineservice/combineservice.go @@ -59,7 +59,7 @@ func serviceInfoForClient() *kitex.ServiceInfo { // NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(false, true, true) + return newServiceInfo(true, true, true) } // NewServiceInfo creates a new ServiceInfo containing non-streaming methods diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/b/b.go b/thrift_streaming/kitex_gen_slim/combine_extend/b/b.go index f12fba6..a06b21d 100644 --- a/thrift_streaming/kitex_gen_slim/combine_extend/b/b.go +++ b/thrift_streaming/kitex_gen_slim/combine_extend/b/b.go @@ -48,7 +48,7 @@ func serviceInfoForClient() *kitex.ServiceInfo { // NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(false, true, true) + return newServiceInfo(true, true, true) } // NewServiceInfo creates a new ServiceInfo containing non-streaming methods diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/b/client.go b/thrift_streaming/kitex_gen_slim/combine_extend/b/client.go index 2892924..4ebfd2f 100644 --- a/thrift_streaming/kitex_gen_slim/combine_extend/b/client.go +++ b/thrift_streaming/kitex_gen_slim/combine_extend/b/client.go @@ -6,13 +6,21 @@ import ( "context" echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" ) // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. type Client interface { } +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) +} + type StreamOnlyService_EchoBidirectionalNewClient interface { streaming.Stream Send(*echo.EchoRequest) error @@ -47,3 +55,38 @@ func MustNewClient(destService string, opts ...client.Option) Client { type kBClient struct { *kClient } + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kBStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kBStreamClient struct { + *kClient +} + +func (p *kBStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalNew(ctx) +} diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/combine_extend.go b/thrift_streaming/kitex_gen_slim/combine_extend/combine_extend.go index 5ad4ba6..8d8812b 100644 --- a/thrift_streaming/kitex_gen_slim/combine_extend/combine_extend.go +++ b/thrift_streaming/kitex_gen_slim/combine_extend/combine_extend.go @@ -1,4 +1,4 @@ -// Code generated by thriftgo (0.3.5). DO NOT EDIT. +// Code generated by thriftgo (0.3.6). DO NOT EDIT. package combine_extend diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/client.go b/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/client.go index 1b4be59..c297e43 100644 --- a/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/client.go +++ b/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/client.go @@ -7,6 +7,10 @@ import ( echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" client "github.com/cloudwego/kitex/client" callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" ) // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. @@ -14,6 +18,11 @@ type Client interface { EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) } +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) +} + type StreamOnlyService_EchoBidirectionalNewClient interface { streaming.Stream Send(*echo.EchoRequest) error @@ -53,3 +62,38 @@ func (p *kCombineServiceClient) EchoPingPongNew(ctx context.Context, req1 *echo. ctx = client.NewCtxWithCallOptions(ctx, callOptions) return p.kClient.EchoPingPongNew(ctx, req1) } + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kCombineServiceStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kCombineServiceStreamClient struct { + *kClient +} + +func (p *kCombineServiceStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalNew(ctx) +} diff --git a/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/combineservice.go b/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/combineservice.go index e95b6ad..9a1ef94 100644 --- a/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/combineservice.go +++ b/thrift_streaming/kitex_gen_slim/combine_extend/combineservice/combineservice.go @@ -60,7 +60,7 @@ func serviceInfoForClient() *kitex.ServiceInfo { // NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(false, true, true) + return newServiceInfo(true, true, true) } // NewServiceInfo creates a new ServiceInfo containing non-streaming methods diff --git a/thrift_streaming/kitex_gen_slim/echo/abcservice/abcservice.go b/thrift_streaming/kitex_gen_slim/echo/abcservice/abcservice.go new file mode 100644 index 0000000..2701cc1 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/abcservice/abcservice.go @@ -0,0 +1,362 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package abcservice + +import ( + "context" + "errors" + "fmt" + c "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/a/b/c" + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + client "github.com/cloudwego/kitex/client" + kitex "github.com/cloudwego/kitex/pkg/serviceinfo" + streaming "github.com/cloudwego/kitex/pkg/streaming" +) + +var errInvalidMessageType = errors.New("invalid message type for service method handler") + +var serviceMethods = map[string]kitex.MethodInfo{ + "Echo": kitex.NewMethodInfo( + echoHandler, + newABCServiceEchoArgs, + newABCServiceEchoResult, + false, + kitex.WithStreamingMode(kitex.StreamingNone), + ), + "EchoBidirectional": kitex.NewMethodInfo( + echoBidirectionalHandler, + newABCServiceEchoBidirectionalArgs, + newABCServiceEchoBidirectionalResult, + false, + kitex.WithStreamingMode(kitex.StreamingBidirectional), + ), + "EchoServer": kitex.NewMethodInfo( + echoServerHandler, + newABCServiceEchoServerArgs, + newABCServiceEchoServerResult, + false, + kitex.WithStreamingMode(kitex.StreamingServer), + ), + "EchoClient": kitex.NewMethodInfo( + echoClientHandler, + newABCServiceEchoClientArgs, + newABCServiceEchoClientResult, + false, + kitex.WithStreamingMode(kitex.StreamingClient), + ), + "EchoUnary": kitex.NewMethodInfo( + echoUnaryHandler, + newABCServiceEchoUnaryArgs, + newABCServiceEchoUnaryResult, + false, + kitex.WithStreamingMode(kitex.StreamingUnary), + ), +} + +var ( + aBCServiceServiceInfo = NewServiceInfo() + aBCServiceServiceInfoForClient = NewServiceInfoForClient() + aBCServiceServiceInfoForStreamClient = NewServiceInfoForStreamClient() +) + +// for server +func serviceInfo() *kitex.ServiceInfo { + return aBCServiceServiceInfo +} + +// for client +func serviceInfoForStreamClient() *kitex.ServiceInfo { + return aBCServiceServiceInfoForStreamClient +} + +// for stream client +func serviceInfoForClient() *kitex.ServiceInfo { + return aBCServiceServiceInfoForClient +} + +// NewServiceInfo creates a new ServiceInfo containing all methods +func NewServiceInfo() *kitex.ServiceInfo { + return newServiceInfo(true, true, true) +} + +// NewServiceInfo creates a new ServiceInfo containing non-streaming methods +func NewServiceInfoForClient() *kitex.ServiceInfo { + return newServiceInfo(false, false, true) +} +func NewServiceInfoForStreamClient() *kitex.ServiceInfo { + return newServiceInfo(true, true, false) +} + +func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreamingMethods bool) *kitex.ServiceInfo { + serviceName := "ABCService" + handlerType := (*echo.ABCService)(nil) + methods := map[string]kitex.MethodInfo{} + for name, m := range serviceMethods { + if m.IsStreaming() && !keepStreamingMethods { + continue + } + if !m.IsStreaming() && !keepNonStreamingMethods { + continue + } + methods[name] = m + } + extra := map[string]interface{}{ + "PackageName": "echo", + } + if hasStreaming { + extra["streaming"] = hasStreaming + } + svcInfo := &kitex.ServiceInfo{ + ServiceName: serviceName, + HandlerType: handlerType, + Methods: methods, + PayloadCodec: kitex.Thrift, + KiteXGenVersion: "v0.8.0", + Extra: extra, + } + return svcInfo +} + +func echoHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + realArg := arg.(*echo.ABCServiceEchoArgs) + realResult := result.(*echo.ABCServiceEchoResult) + success, err := handler.(echo.ABCService).Echo(ctx, realArg.Req1, realArg.Req2) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newABCServiceEchoArgs() interface{} { + return echo.NewABCServiceEchoArgs() +} + +func newABCServiceEchoResult() interface{} { + return echo.NewABCServiceEchoResult() +} + +func echoBidirectionalHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("ABCService.EchoBidirectional is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &aBCServiceEchoBidirectionalServer{st.Stream} + return handler.(echo.ABCService).EchoBidirectional(stream) +} + +type aBCServiceEchoBidirectionalClient struct { + streaming.Stream +} + +func (x *aBCServiceEchoBidirectionalClient) Send(m *c.Request) error { + return x.Stream.SendMsg(m) +} +func (x *aBCServiceEchoBidirectionalClient) Recv() (*c.Response, error) { + m := new(c.Response) + return m, x.Stream.RecvMsg(m) +} + +type aBCServiceEchoBidirectionalServer struct { + streaming.Stream +} + +func (x *aBCServiceEchoBidirectionalServer) Send(m *c.Response) error { + return x.Stream.SendMsg(m) +} + +func (x *aBCServiceEchoBidirectionalServer) Recv() (*c.Request, error) { + m := new(c.Request) + return m, x.Stream.RecvMsg(m) +} + +func newABCServiceEchoBidirectionalArgs() interface{} { + return echo.NewABCServiceEchoBidirectionalArgs() +} + +func newABCServiceEchoBidirectionalResult() interface{} { + return echo.NewABCServiceEchoBidirectionalResult() +} + +func echoServerHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("ABCService.EchoServer is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &aBCServiceEchoServerServer{st.Stream} + req := new(c.Request) + if err := st.Stream.RecvMsg(req); err != nil { + return err + } + return handler.(echo.ABCService).EchoServer(req, stream) +} + +type aBCServiceEchoServerClient struct { + streaming.Stream +} + +func (x *aBCServiceEchoServerClient) Recv() (*c.Response, error) { + m := new(c.Response) + return m, x.Stream.RecvMsg(m) +} + +type aBCServiceEchoServerServer struct { + streaming.Stream +} + +func (x *aBCServiceEchoServerServer) Send(m *c.Response) error { + return x.Stream.SendMsg(m) +} + +func newABCServiceEchoServerArgs() interface{} { + return echo.NewABCServiceEchoServerArgs() +} + +func newABCServiceEchoServerResult() interface{} { + return echo.NewABCServiceEchoServerResult() +} + +func echoClientHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + st, ok := arg.(*streaming.Args) + if !ok { + return errors.New("ABCService.EchoClient is a thrift streaming method, please call with Kitex StreamClient") + } + stream := &aBCServiceEchoClientServer{st.Stream} + return handler.(echo.ABCService).EchoClient(stream) +} + +type aBCServiceEchoClientClient struct { + streaming.Stream +} + +func (x *aBCServiceEchoClientClient) Send(m *c.Request) error { + return x.Stream.SendMsg(m) +} +func (x *aBCServiceEchoClientClient) CloseAndRecv() (*c.Response, error) { + if err := x.Stream.Close(); err != nil { + return nil, err + } + m := new(c.Response) + return m, x.Stream.RecvMsg(m) +} + +type aBCServiceEchoClientServer struct { + streaming.Stream +} + +func (x *aBCServiceEchoClientServer) SendAndClose(m *c.Response) error { + return x.Stream.SendMsg(m) +} + +func (x *aBCServiceEchoClientServer) Recv() (*c.Request, error) { + m := new(c.Request) + return m, x.Stream.RecvMsg(m) +} + +func newABCServiceEchoClientArgs() interface{} { + return echo.NewABCServiceEchoClientArgs() +} + +func newABCServiceEchoClientResult() interface{} { + return echo.NewABCServiceEchoClientResult() +} + +func echoUnaryHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + if streaming.GetStream(ctx) == nil { + return errors.New("ABCService.EchoUnary is a thrift streaming unary method, please call with Kitex StreamClient or remove the annotation streaming.mode") + } + realArg := arg.(*echo.ABCServiceEchoUnaryArgs) + realResult := result.(*echo.ABCServiceEchoUnaryResult) + success, err := handler.(echo.ABCService).EchoUnary(ctx, realArg.Req1) + if err != nil { + return err + } + realResult.Success = success + return nil +} +func newABCServiceEchoUnaryArgs() interface{} { + return echo.NewABCServiceEchoUnaryArgs() +} + +func newABCServiceEchoUnaryResult() interface{} { + return echo.NewABCServiceEchoUnaryResult() +} + +type kClient struct { + c client.Client +} + +func newServiceClient(c client.Client) *kClient { + return &kClient{ + c: c, + } +} + +func (p *kClient) Echo(ctx context.Context, req1 *c.Request, req2 *c.Request) (r *c.Response, err error) { + var _args echo.ABCServiceEchoArgs + _args.Req1 = req1 + _args.Req2 = req2 + var _result echo.ABCServiceEchoResult + if err = p.c.Call(ctx, "Echo", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) EchoBidirectional(ctx context.Context) (ABCService_EchoBidirectionalClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoBidirectional", nil, res) + if err != nil { + return nil, err + } + stream := &aBCServiceEchoBidirectionalClient{res.Stream} + return stream, nil +} + +func (p *kClient) EchoServer(ctx context.Context, req1 *c.Request) (ABCService_EchoServerClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoServer", nil, res) + if err != nil { + return nil, err + } + stream := &aBCServiceEchoServerClient{res.Stream} + + if err := stream.Stream.SendMsg(req1); err != nil { + return nil, err + } + if err := stream.Stream.Close(); err != nil { + return nil, err + } + return stream, nil +} + +func (p *kClient) EchoClient(ctx context.Context) (ABCService_EchoClientClient, error) { + streamClient, ok := p.c.(client.Streaming) + if !ok { + return nil, fmt.Errorf("client not support streaming") + } + res := new(streaming.Result) + err := streamClient.Stream(ctx, "EchoClient", nil, res) + if err != nil { + return nil, err + } + stream := &aBCServiceEchoClientClient{res.Stream} + return stream, nil +} + +func (p *kClient) EchoUnary(ctx context.Context, req1 *c.Request) (r *c.Response, err error) { + var _args echo.ABCServiceEchoUnaryArgs + _args.Req1 = req1 + var _result echo.ABCServiceEchoUnaryResult + if err = p.c.Call(ctx, "EchoUnary", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/thrift_streaming/kitex_gen_slim/echo/abcservice/client.go b/thrift_streaming/kitex_gen_slim/echo/abcservice/client.go new file mode 100644 index 0000000..e8934f2 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/abcservice/client.go @@ -0,0 +1,128 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package abcservice + +import ( + "context" + c "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/a/b/c" + client "github.com/cloudwego/kitex/client" + callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" +) + +// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. +type Client interface { + Echo(ctx context.Context, req1 *c.Request, req2 *c.Request, callOptions ...callopt.Option) (r *c.Response, err error) +} + +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectional(ctx context.Context, callOptions ...streamcall.Option) (stream ABCService_EchoBidirectionalClient, err error) + EchoServer(ctx context.Context, req1 *c.Request, callOptions ...streamcall.Option) (stream ABCService_EchoServerClient, err error) + EchoClient(ctx context.Context, callOptions ...streamcall.Option) (stream ABCService_EchoClientClient, err error) + EchoUnary(ctx context.Context, req1 *c.Request, callOptions ...streamcall.Option) (r *c.Response, err error) +} + +type ABCService_EchoBidirectionalClient interface { + streaming.Stream + Send(*c.Request) error + Recv() (*c.Response, error) +} + +type ABCService_EchoServerClient interface { + streaming.Stream + Recv() (*c.Response, error) +} + +type ABCService_EchoClientClient interface { + streaming.Stream + Send(*c.Request) error + CloseAndRecv() (*c.Response, error) +} + +// NewClient creates a client for the service defined in IDL. +func NewClient(destService string, opts ...client.Option) (Client, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + + options = append(options, opts...) + + kc, err := client.NewClient(serviceInfoForClient(), options...) + if err != nil { + return nil, err + } + return &kABCServiceClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. +func MustNewClient(destService string, opts ...client.Option) Client { + kc, err := NewClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kABCServiceClient struct { + *kClient +} + +func (p *kABCServiceClient) Echo(ctx context.Context, req1 *c.Request, req2 *c.Request, callOptions ...callopt.Option) (r *c.Response, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.Echo(ctx, req1, req2) +} + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kABCServiceStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kABCServiceStreamClient struct { + *kClient +} + +func (p *kABCServiceStreamClient) EchoBidirectional(ctx context.Context, callOptions ...streamcall.Option) (stream ABCService_EchoBidirectionalClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectional(ctx) +} + +func (p *kABCServiceStreamClient) EchoServer(ctx context.Context, req1 *c.Request, callOptions ...streamcall.Option) (stream ABCService_EchoServerClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoServer(ctx, req1) +} + +func (p *kABCServiceStreamClient) EchoClient(ctx context.Context, callOptions ...streamcall.Option) (stream ABCService_EchoClientClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoClient(ctx) +} + +func (p *kABCServiceStreamClient) EchoUnary(ctx context.Context, req1 *c.Request, callOptions ...streamcall.Option) (r *c.Response, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoUnary(ctx, req1) +} diff --git a/thrift_streaming/kitex_gen_slim/echo/abcservice/invoker.go b/thrift_streaming/kitex_gen_slim/echo/abcservice/invoker.go new file mode 100644 index 0000000..56fca07 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/abcservice/invoker.go @@ -0,0 +1,24 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. + +package abcservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewInvoker creates a server.Invoker with the given handler and options. +func NewInvoker(handler echo.ABCService, opts ...server.Option) server.Invoker { + var options []server.Option + + options = append(options, opts...) + + s := server.NewInvoker(options...) + if err := s.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + if err := s.Init(); err != nil { + panic(err) + } + return s +} diff --git a/thrift_streaming/kitex_gen_slim/echo/abcservice/server.go b/thrift_streaming/kitex_gen_slim/echo/abcservice/server.go new file mode 100644 index 0000000..a6e5616 --- /dev/null +++ b/thrift_streaming/kitex_gen_slim/echo/abcservice/server.go @@ -0,0 +1,21 @@ +// Code generated by Kitex v0.8.0. DO NOT EDIT. +package abcservice + +import ( + echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" + server "github.com/cloudwego/kitex/server" +) + +// NewServer creates a server.Server with the given handler and options. +func NewServer(handler echo.ABCService, opts ...server.Option) server.Server { + var options []server.Option + + options = append(options, opts...) + options = append(options, server.WithCompatibleMiddlewareForUnary()) + + svr := server.NewServer(options...) + if err := svr.RegisterService(serviceInfo(), handler); err != nil { + panic(err) + } + return svr +} diff --git a/thrift_streaming/kitex_gen_slim/echo/api.go b/thrift_streaming/kitex_gen_slim/echo/api.go index 55ab800..911be21 100644 --- a/thrift_streaming/kitex_gen_slim/echo/api.go +++ b/thrift_streaming/kitex_gen_slim/echo/api.go @@ -1,10 +1,11 @@ -// Code generated by thriftgo (0.3.5). DO NOT EDIT. +// Code generated by thriftgo (0.3.6). DO NOT EDIT. package echo import ( "context" "fmt" + "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/a/b/c" "github.com/cloudwego/kitex/pkg/streaming" ) @@ -167,6 +168,38 @@ type StreamOnlyServiceChildChild interface { StreamOnlyServiceChild } +type ABCService interface { + Echo(ctx context.Context, req1 *c.Request, req2 *c.Request) (r *c.Response, err error) + + EchoBidirectional(stream ABCService_EchoBidirectionalServer) (err error) + + EchoServer(req *c.Request, stream ABCService_EchoServerServer) (err error) + + EchoClient(stream ABCService_EchoClientServer) (err error) + + EchoUnary(ctx context.Context, req1 *c.Request) (r *c.Response, err error) +} + +type ABCService_EchoBidirectionalServer interface { + streaming.Stream + + Recv() (*c.Request, error) + + Send(*c.Response) error +} +type ABCService_EchoServerServer interface { + streaming.Stream + + Send(*c.Response) error +} +type ABCService_EchoClientServer interface { + streaming.Stream + + Recv() (*c.Request, error) + + SendAndClose(*c.Response) error +} + // exceptions of methods in EchoService. var ( _ error = (*EchoException)(nil) diff --git a/thrift_streaming/kitex_gen_slim/echo/k-api.go b/thrift_streaming/kitex_gen_slim/echo/k-api.go index c91af16..dfcd1b9 100644 --- a/thrift_streaming/kitex_gen_slim/echo/k-api.go +++ b/thrift_streaming/kitex_gen_slim/echo/k-api.go @@ -9,6 +9,8 @@ import ( "strings" "github.com/apache/thrift/lib/go/thrift" + + "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/a/b/c" ) // unused protection @@ -18,6 +20,7 @@ var ( _ = (*strings.Builder)(nil) _ = reflect.Type(nil) _ = thrift.TProtocol(nil) + _ = c.KitexUnusedProtection ) type EchoServiceEchoBidirectionalArgs struct { @@ -762,3 +765,400 @@ func (p *StreamOnlyServiceEchoBidirectionalNewResult) String() string { func (p *StreamOnlyServiceEchoBidirectionalNewResult) GetResult() interface{} { return p.Success } + +type ABCServiceEchoArgs struct { + Req1 *c.Request `thrift:"req1,1" frugal:"1,default,c.Request" json:"req1"` + Req2 *c.Request `thrift:"req2,2" frugal:"2,default,c.Request" json:"req2"` +} + +func NewABCServiceEchoArgs() *ABCServiceEchoArgs { + return &ABCServiceEchoArgs{} +} + +func (p *ABCServiceEchoArgs) InitDefault() { + *p = ABCServiceEchoArgs{} +} + +var ABCServiceEchoArgs_Req1_DEFAULT *c.Request + +func (p *ABCServiceEchoArgs) GetReq1() (v *c.Request) { + if !p.IsSetReq1() { + return ABCServiceEchoArgs_Req1_DEFAULT + } + return p.Req1 +} + +var ABCServiceEchoArgs_Req2_DEFAULT *c.Request + +func (p *ABCServiceEchoArgs) GetReq2() (v *c.Request) { + if !p.IsSetReq2() { + return ABCServiceEchoArgs_Req2_DEFAULT + } + return p.Req2 +} +func (p *ABCServiceEchoArgs) SetReq1(val *c.Request) { + p.Req1 = val +} +func (p *ABCServiceEchoArgs) SetReq2(val *c.Request) { + p.Req2 = val +} + +func (p *ABCServiceEchoArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *ABCServiceEchoArgs) IsSetReq2() bool { + return p.Req2 != nil +} + +func (p *ABCServiceEchoArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoArgs(%+v)", *p) +} +func (p *ABCServiceEchoArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +type ABCServiceEchoResult struct { + Success *c.Response `thrift:"success,0,optional" frugal:"0,optional,c.Response" json:"success,omitempty"` +} + +func NewABCServiceEchoResult() *ABCServiceEchoResult { + return &ABCServiceEchoResult{} +} + +func (p *ABCServiceEchoResult) InitDefault() { + *p = ABCServiceEchoResult{} +} + +var ABCServiceEchoResult_Success_DEFAULT *c.Response + +func (p *ABCServiceEchoResult) GetSuccess() (v *c.Response) { + if !p.IsSetSuccess() { + return ABCServiceEchoResult_Success_DEFAULT + } + return p.Success +} +func (p *ABCServiceEchoResult) SetSuccess(x interface{}) { + p.Success = x.(*c.Response) +} + +func (p *ABCServiceEchoResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ABCServiceEchoResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoResult(%+v)", *p) +} +func (p *ABCServiceEchoResult) GetResult() interface{} { + return p.Success +} + +type ABCServiceEchoBidirectionalArgs struct { + Req1 *c.Request `thrift:"req1,1" frugal:"1,default,c.Request" json:"req1"` +} + +func NewABCServiceEchoBidirectionalArgs() *ABCServiceEchoBidirectionalArgs { + return &ABCServiceEchoBidirectionalArgs{} +} + +func (p *ABCServiceEchoBidirectionalArgs) InitDefault() { + *p = ABCServiceEchoBidirectionalArgs{} +} + +var ABCServiceEchoBidirectionalArgs_Req1_DEFAULT *c.Request + +func (p *ABCServiceEchoBidirectionalArgs) GetReq1() (v *c.Request) { + if !p.IsSetReq1() { + return ABCServiceEchoBidirectionalArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *ABCServiceEchoBidirectionalArgs) SetReq1(val *c.Request) { + p.Req1 = val +} + +func (p *ABCServiceEchoBidirectionalArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *ABCServiceEchoBidirectionalArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoBidirectionalArgs(%+v)", *p) +} +func (p *ABCServiceEchoBidirectionalArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +type ABCServiceEchoBidirectionalResult struct { + Success *c.Response `thrift:"success,0,optional" frugal:"0,optional,c.Response" json:"success,omitempty"` +} + +func NewABCServiceEchoBidirectionalResult() *ABCServiceEchoBidirectionalResult { + return &ABCServiceEchoBidirectionalResult{} +} + +func (p *ABCServiceEchoBidirectionalResult) InitDefault() { + *p = ABCServiceEchoBidirectionalResult{} +} + +var ABCServiceEchoBidirectionalResult_Success_DEFAULT *c.Response + +func (p *ABCServiceEchoBidirectionalResult) GetSuccess() (v *c.Response) { + if !p.IsSetSuccess() { + return ABCServiceEchoBidirectionalResult_Success_DEFAULT + } + return p.Success +} +func (p *ABCServiceEchoBidirectionalResult) SetSuccess(x interface{}) { + p.Success = x.(*c.Response) +} + +func (p *ABCServiceEchoBidirectionalResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ABCServiceEchoBidirectionalResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoBidirectionalResult(%+v)", *p) +} +func (p *ABCServiceEchoBidirectionalResult) GetResult() interface{} { + return p.Success +} + +type ABCServiceEchoServerArgs struct { + Req1 *c.Request `thrift:"req1,1" frugal:"1,default,c.Request" json:"req1"` +} + +func NewABCServiceEchoServerArgs() *ABCServiceEchoServerArgs { + return &ABCServiceEchoServerArgs{} +} + +func (p *ABCServiceEchoServerArgs) InitDefault() { + *p = ABCServiceEchoServerArgs{} +} + +var ABCServiceEchoServerArgs_Req1_DEFAULT *c.Request + +func (p *ABCServiceEchoServerArgs) GetReq1() (v *c.Request) { + if !p.IsSetReq1() { + return ABCServiceEchoServerArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *ABCServiceEchoServerArgs) SetReq1(val *c.Request) { + p.Req1 = val +} + +func (p *ABCServiceEchoServerArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *ABCServiceEchoServerArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoServerArgs(%+v)", *p) +} +func (p *ABCServiceEchoServerArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +type ABCServiceEchoServerResult struct { + Success *c.Response `thrift:"success,0,optional" frugal:"0,optional,c.Response" json:"success,omitempty"` +} + +func NewABCServiceEchoServerResult() *ABCServiceEchoServerResult { + return &ABCServiceEchoServerResult{} +} + +func (p *ABCServiceEchoServerResult) InitDefault() { + *p = ABCServiceEchoServerResult{} +} + +var ABCServiceEchoServerResult_Success_DEFAULT *c.Response + +func (p *ABCServiceEchoServerResult) GetSuccess() (v *c.Response) { + if !p.IsSetSuccess() { + return ABCServiceEchoServerResult_Success_DEFAULT + } + return p.Success +} +func (p *ABCServiceEchoServerResult) SetSuccess(x interface{}) { + p.Success = x.(*c.Response) +} + +func (p *ABCServiceEchoServerResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ABCServiceEchoServerResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoServerResult(%+v)", *p) +} +func (p *ABCServiceEchoServerResult) GetResult() interface{} { + return p.Success +} + +type ABCServiceEchoClientArgs struct { + Req1 *c.Request `thrift:"req1,1" frugal:"1,default,c.Request" json:"req1"` +} + +func NewABCServiceEchoClientArgs() *ABCServiceEchoClientArgs { + return &ABCServiceEchoClientArgs{} +} + +func (p *ABCServiceEchoClientArgs) InitDefault() { + *p = ABCServiceEchoClientArgs{} +} + +var ABCServiceEchoClientArgs_Req1_DEFAULT *c.Request + +func (p *ABCServiceEchoClientArgs) GetReq1() (v *c.Request) { + if !p.IsSetReq1() { + return ABCServiceEchoClientArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *ABCServiceEchoClientArgs) SetReq1(val *c.Request) { + p.Req1 = val +} + +func (p *ABCServiceEchoClientArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *ABCServiceEchoClientArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoClientArgs(%+v)", *p) +} +func (p *ABCServiceEchoClientArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +type ABCServiceEchoClientResult struct { + Success *c.Response `thrift:"success,0,optional" frugal:"0,optional,c.Response" json:"success,omitempty"` +} + +func NewABCServiceEchoClientResult() *ABCServiceEchoClientResult { + return &ABCServiceEchoClientResult{} +} + +func (p *ABCServiceEchoClientResult) InitDefault() { + *p = ABCServiceEchoClientResult{} +} + +var ABCServiceEchoClientResult_Success_DEFAULT *c.Response + +func (p *ABCServiceEchoClientResult) GetSuccess() (v *c.Response) { + if !p.IsSetSuccess() { + return ABCServiceEchoClientResult_Success_DEFAULT + } + return p.Success +} +func (p *ABCServiceEchoClientResult) SetSuccess(x interface{}) { + p.Success = x.(*c.Response) +} + +func (p *ABCServiceEchoClientResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ABCServiceEchoClientResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoClientResult(%+v)", *p) +} +func (p *ABCServiceEchoClientResult) GetResult() interface{} { + return p.Success +} + +type ABCServiceEchoUnaryArgs struct { + Req1 *c.Request `thrift:"req1,1" frugal:"1,default,c.Request" json:"req1"` +} + +func NewABCServiceEchoUnaryArgs() *ABCServiceEchoUnaryArgs { + return &ABCServiceEchoUnaryArgs{} +} + +func (p *ABCServiceEchoUnaryArgs) InitDefault() { + *p = ABCServiceEchoUnaryArgs{} +} + +var ABCServiceEchoUnaryArgs_Req1_DEFAULT *c.Request + +func (p *ABCServiceEchoUnaryArgs) GetReq1() (v *c.Request) { + if !p.IsSetReq1() { + return ABCServiceEchoUnaryArgs_Req1_DEFAULT + } + return p.Req1 +} +func (p *ABCServiceEchoUnaryArgs) SetReq1(val *c.Request) { + p.Req1 = val +} + +func (p *ABCServiceEchoUnaryArgs) IsSetReq1() bool { + return p.Req1 != nil +} + +func (p *ABCServiceEchoUnaryArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoUnaryArgs(%+v)", *p) +} +func (p *ABCServiceEchoUnaryArgs) GetFirstArgument() interface{} { + return p.Req1 +} + +type ABCServiceEchoUnaryResult struct { + Success *c.Response `thrift:"success,0,optional" frugal:"0,optional,c.Response" json:"success,omitempty"` +} + +func NewABCServiceEchoUnaryResult() *ABCServiceEchoUnaryResult { + return &ABCServiceEchoUnaryResult{} +} + +func (p *ABCServiceEchoUnaryResult) InitDefault() { + *p = ABCServiceEchoUnaryResult{} +} + +var ABCServiceEchoUnaryResult_Success_DEFAULT *c.Response + +func (p *ABCServiceEchoUnaryResult) GetSuccess() (v *c.Response) { + if !p.IsSetSuccess() { + return ABCServiceEchoUnaryResult_Success_DEFAULT + } + return p.Success +} +func (p *ABCServiceEchoUnaryResult) SetSuccess(x interface{}) { + p.Success = x.(*c.Response) +} + +func (p *ABCServiceEchoUnaryResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ABCServiceEchoUnaryResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ABCServiceEchoUnaryResult(%+v)", *p) +} +func (p *ABCServiceEchoUnaryResult) GetResult() interface{} { + return p.Success +} diff --git a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/client.go b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/client.go index e1ad4c7..95c27e7 100644 --- a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/client.go +++ b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/client.go @@ -7,6 +7,10 @@ import ( echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" client "github.com/cloudwego/kitex/client" callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" ) // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. @@ -14,6 +18,11 @@ type Client interface { EchoPingPongNew(ctx context.Context, req1 *echo.EchoRequest, callOptions ...callopt.Option) (r *echo.EchoResponse, err error) } +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalExtended(ctx context.Context, callOptions ...streamcall.Option) (stream PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, err error) +} + type PingPongOnlyServiceChild_EchoBidirectionalExtendedClient interface { streaming.Stream Send(*echo.EchoRequest) error @@ -53,3 +62,38 @@ func (p *kPingPongOnlyServiceChildChildClient) EchoPingPongNew(ctx context.Conte ctx = client.NewCtxWithCallOptions(ctx, callOptions) return p.kClient.EchoPingPongNew(ctx, req1) } + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kPingPongOnlyServiceChildChildStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kPingPongOnlyServiceChildChildStreamClient struct { + *kClient +} + +func (p *kPingPongOnlyServiceChildChildStreamClient) EchoBidirectionalExtended(ctx context.Context, callOptions ...streamcall.Option) (stream PingPongOnlyServiceChild_EchoBidirectionalExtendedClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalExtended(ctx) +} diff --git a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go index 6c40880..927e9f3 100644 --- a/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go +++ b/thrift_streaming/kitex_gen_slim/echo/pingpongonlyservicechildchild/pingpongonlyservicechildchild.go @@ -54,7 +54,7 @@ func serviceInfoForClient() *kitex.ServiceInfo { // NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(false, true, true) + return newServiceInfo(true, true, true) } // NewServiceInfo creates a new ServiceInfo containing non-streaming methods diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/client.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/client.go index 0da7823..5f46814 100644 --- a/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/client.go +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservice/client.go @@ -6,7 +6,6 @@ import ( "context" echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" "github.com/cloudwego/kitex/client/callopt/streamcall" "github.com/cloudwego/kitex/client/streamclient" streaming "github.com/cloudwego/kitex/pkg/streaming" diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/client.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/client.go index 7eb0f10..6264905 100644 --- a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/client.go +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/client.go @@ -6,13 +6,21 @@ import ( "context" echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" ) // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. type Client interface { } +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) +} + type StreamOnlyService_EchoBidirectionalNewClient interface { streaming.Stream Send(*echo.EchoRequest) error @@ -47,3 +55,38 @@ func MustNewClient(destService string, opts ...client.Option) Client { type kStreamOnlyServiceChildClient struct { *kClient } + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceChildStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceChildStreamClient struct { + *kClient +} + +func (p *kStreamOnlyServiceChildStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalNew(ctx) +} diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/streamonlyservicechild.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/streamonlyservicechild.go index dfdec1d..ef1d65e 100644 --- a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/streamonlyservicechild.go +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechild/streamonlyservicechild.go @@ -47,7 +47,7 @@ func serviceInfoForClient() *kitex.ServiceInfo { // NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(false, true, true) + return newServiceInfo(true, true, true) } // NewServiceInfo creates a new ServiceInfo containing non-streaming methods diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/client.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/client.go index e0567ba..bfd6bbc 100644 --- a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/client.go +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/client.go @@ -6,13 +6,21 @@ import ( "context" echo "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen_slim/echo" client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/client/callopt/streamcall" + "github.com/cloudwego/kitex/client/streamclient" + streaming "github.com/cloudwego/kitex/pkg/streaming" + transport "github.com/cloudwego/kitex/transport" ) // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. type Client interface { } +// StreamClient is designed to provide Interface for Streaming APIs. +type StreamClient interface { + EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) +} + type StreamOnlyService_EchoBidirectionalNewClient interface { streaming.Stream Send(*echo.EchoRequest) error @@ -47,3 +55,38 @@ func MustNewClient(destService string, opts ...client.Option) Client { type kStreamOnlyServiceChildChildClient struct { *kClient } + +// NewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +func NewStreamClient(destService string, opts ...streamclient.Option) (StreamClient, error) { + var options []client.Option + options = append(options, client.WithDestService(destService)) + options = append(options, client.WithTransportProtocol(transport.GRPC)) + options = append(options, streamclient.GetClientOptions(opts)...) + + kc, err := client.NewClient(serviceInfoForStreamClient(), options...) + if err != nil { + return nil, err + } + return &kStreamOnlyServiceChildChildStreamClient{ + kClient: newServiceClient(kc), + }, nil +} + +// MustNewStreamClient creates a stream client for the service's streaming APIs defined in IDL. +// It panics if any error occurs. +func MustNewStreamClient(destService string, opts ...streamclient.Option) StreamClient { + kc, err := NewStreamClient(destService, opts...) + if err != nil { + panic(err) + } + return kc +} + +type kStreamOnlyServiceChildChildStreamClient struct { + *kClient +} + +func (p *kStreamOnlyServiceChildChildStreamClient) EchoBidirectionalNew(ctx context.Context, callOptions ...streamcall.Option) (stream StreamOnlyService_EchoBidirectionalNewClient, err error) { + ctx = client.NewCtxWithCallOptions(ctx, streamcall.GetCallOptions(callOptions)) + return p.kClient.EchoBidirectionalNew(ctx) +} diff --git a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/streamonlyservicechildchild.go b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/streamonlyservicechildchild.go index 0b9939a..fffaaa8 100644 --- a/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/streamonlyservicechildchild.go +++ b/thrift_streaming/kitex_gen_slim/echo/streamonlyservicechildchild/streamonlyservicechildchild.go @@ -47,7 +47,7 @@ func serviceInfoForClient() *kitex.ServiceInfo { // NewServiceInfo creates a new ServiceInfo containing all methods func NewServiceInfo() *kitex.ServiceInfo { - return newServiceInfo(false, true, true) + return newServiceInfo(true, true, true) } // NewServiceInfo creates a new ServiceInfo containing non-streaming methods diff --git a/thrift_streaming/main_test.go b/thrift_streaming/main_test.go index 17ce09b..e644864 100644 --- a/thrift_streaming/main_test.go +++ b/thrift_streaming/main_test.go @@ -132,12 +132,24 @@ func TestMain(m *testing.M) { go func() { slimServer = RunSlimThriftServer(&SlimEchoServiceImpl{}, slimAddr) }() go func() { combineServer = RunCombineThriftServer(&CombineServiceImpl{}, combineAddr) }() defer func() { - go thriftSvr.Stop() - go grpcServer.Stop() - go pbServer.Stop() - go slimServer.Stop() - go thriftCrossSvr.Stop() - go combineServer.Stop() + if thriftSvr != nil { + thriftSvr.Stop() + } + if thriftCrossSvr != nil { + thriftCrossSvr.Stop() + } + if slimServer != nil { + slimServer.Stop() + } + if grpcServer != nil { + grpcServer.Stop() + } + if pbServer != nil { + pbServer.Stop() + } + if combineServer != nil { + combineServer.Stop() + } }() common.WaitServer(thriftAddr) common.WaitServer(crossAddr) diff --git a/thrift_streaming/thrift_test.go b/thrift_streaming/thrift_test.go index 3345f53..3834ff1 100644 --- a/thrift_streaming/thrift_test.go +++ b/thrift_streaming/thrift_test.go @@ -26,8 +26,11 @@ import ( "time" "github.com/bytedance/gopkg/cloud/metainfo" + "github.com/cloudwego/kitex-tests/common" + "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/a/b/c" "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine" "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/combine/combineservice" + "github.com/cloudwego/kitex-tests/thrift_streaming/kitex_gen/echo/abcservice" "github.com/cloudwego/kitex/client" "github.com/cloudwego/kitex/client/streamclient" "github.com/cloudwego/kitex/pkg/endpoint" @@ -976,3 +979,99 @@ func TestThriftStreamLogID(t *testing.T) { t.Errorf("stream ctx got logID = %v", got) } } + +func RunABCServer(handler echo.ABCService, addr string, opts ...server.Option) server.Server { + opts = append(opts, WithServerAddr(addr)) + opts = append(opts, server.WithExitWaitTime(time.Millisecond*10)) + svr := abcservice.NewServer(handler, opts...) + go func() { + if err := svr.Run(); err != nil { + panic(err) + } + }() + common.WaitServer(addr) + return svr +} + +type abcServerImpl struct { +} + +func (a abcServerImpl) Echo(ctx context.Context, req1 *c.Request, req2 *c.Request) (r *c.Response, err error) { + r = &c.Response{ + Message: req1.Message + req2.Message, + } + return +} + +func (a abcServerImpl) EchoBidirectional(stream echo.ABCService_EchoBidirectionalServer) (err error) { + req, err := stream.Recv() + if err != nil { + return err + } + return stream.Send(&c.Response{Message: req.Message}) +} + +func (a abcServerImpl) EchoServer(req *c.Request, stream echo.ABCService_EchoServerServer) (err error) { + return stream.Send(&c.Response{Message: req.Message}) +} + +func (a abcServerImpl) EchoClient(stream echo.ABCService_EchoClientServer) (err error) { + req, err := stream.Recv() + if err != nil { + return err + } + return stream.SendAndClose(&c.Response{Message: req.Message}) +} + +func (a abcServerImpl) EchoUnary(ctx context.Context, req1 *c.Request) (r *c.Response, err error) { + r = &c.Response{ + Message: req1.Message, + } + return +} + +func TestABCService(t *testing.T) { + addr := addrAllocator() + svr := RunABCServer(&abcServerImpl{}, addr) + defer svr.Stop() + t.Run("echo", func(t *testing.T) { + cli := abcservice.MustNewClient("service", client.WithHostPorts(addr)) + rsp, err := cli.Echo(context.Background(), &c.Request{Message: "hello"}, &c.Request{Message: "world"}) + test.Assert(t, err == nil, err) + test.Assert(t, rsp.Message == "helloworld") + }) + t.Run("echo-unary", func(t *testing.T) { + cli := abcservice.MustNewStreamClient("service", streamclient.WithHostPorts(addr)) + rsp, err := cli.EchoUnary(context.Background(), &c.Request{Message: "hello"}) + test.Assert(t, err == nil, err) + test.Assert(t, rsp.Message == "hello") + }) + t.Run("echo-bidirectional", func(t *testing.T) { + cli := abcservice.MustNewStreamClient("service", streamclient.WithHostPorts(addr)) + stream, err := cli.EchoBidirectional(context.Background()) + test.Assert(t, err == nil, err) + err = stream.Send(&c.Request{Message: "hello"}) + test.Assert(t, err == nil, err) + rsp, err := stream.Recv() + test.Assert(t, err == nil, err) + test.Assert(t, rsp.Message == "hello") + }) + t.Run("echo-server", func(t *testing.T) { + cli := abcservice.MustNewStreamClient("service", streamclient.WithHostPorts(addr)) + stream, err := cli.EchoServer(context.Background(), &c.Request{Message: "hello"}) + test.Assert(t, err == nil, err) + rsp, err := stream.Recv() + test.Assert(t, err == nil, err) + test.Assert(t, rsp.Message == "hello") + }) + t.Run("echo-client", func(t *testing.T) { + cli := abcservice.MustNewStreamClient("service", streamclient.WithHostPorts(addr)) + stream, err := cli.EchoClient(context.Background()) + test.Assert(t, err == nil, err) + err = stream.Send(&c.Request{Message: "hello"}) + test.Assert(t, err == nil, err) + rsp, err := stream.CloseAndRecv() + test.Assert(t, err == nil, err) + test.Assert(t, rsp.Message == "hello") + }) +} From 7d8d4b8d6dd1b34ee70492a120ddcf63bc52ac97 Mon Sep 17 00:00:00 2001 From: "qiheng.zhou" Date: Thu, 11 Jan 2024 15:49:36 +0800 Subject: [PATCH 7/7] test: add grpc tls test --- go.mod | 55 +++++++++++++ grpc/tls/cert/gen.sh | 43 ++++++++++ grpc/tls/grpc_server.go | 130 ++++++++++++++++++++++++++++++ grpc/tls/kitex_client.go | 169 +++++++++++++++++++++++++++++++++++++++ grpc/tls/tls_test.go | 91 +++++++++++++++++++++ 5 files changed, 488 insertions(+) create mode 100644 go.mod create mode 100644 grpc/tls/cert/gen.sh create mode 100644 grpc/tls/grpc_server.go create mode 100644 grpc/tls/kitex_client.go create mode 100644 grpc/tls/tls_test.go diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..d72de94 --- /dev/null +++ b/go.mod @@ -0,0 +1,55 @@ +module github.com/cloudwego/kitex-tests + +go 1.17 + +require ( + github.com/apache/thrift v0.13.0 + github.com/bytedance/gopkg v0.0.0-20230728082804-614d0af6619b + github.com/cloudwego/fastpb v0.0.4 + github.com/cloudwego/kitex v0.8.1-0.20240108100713-a6d5d904434d + github.com/cloudwego/netpoll v0.5.1 + google.golang.org/grpc v1.36.1 + google.golang.org/protobuf v1.28.1 +) + +require ( + github.com/bytedance/sonic v1.10.2 // indirect + github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect + github.com/chenzhuoyu/iasm v0.9.1 // indirect + github.com/choleraehyq/pid v0.0.17 // indirect + github.com/cloudwego/configmanager v0.2.0 // indirect + github.com/cloudwego/dynamicgo v0.1.6 // indirect + github.com/cloudwego/frugal v0.1.12 // indirect + github.com/cloudwego/localsession v0.0.2 // indirect + github.com/cloudwego/thriftgo v0.3.5 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/fatih/structtag v1.2.0 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/pprof v0.0.0-20220608213341-c488b8fa1db3 // indirect + github.com/iancoleman/strcase v0.2.0 // indirect + github.com/jhump/protoreflect v1.8.2 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/cpuid/v2 v2.2.4 // indirect + github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect + github.com/modern-go/gls v0.0.0-20220109145502-612d0167dce5 // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/oleiade/lane v1.0.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/stretchr/testify v1.8.2 // indirect + github.com/tidwall/gjson v1.9.3 // indirect + github.com/tidwall/match v1.1.1 // indirect + github.com/tidwall/pretty v1.2.0 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + golang.org/x/arch v0.2.0 // indirect + golang.org/x/net v0.0.0-20221014081412-f15817d10f9b // indirect + golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect + golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2 // indirect + golang.org/x/text v0.6.0 // indirect + google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) + +replace ( + github.com/apache/thrift => github.com/apache/thrift v0.13.0 + github.com/cloudwego/kitex => github.com/felix021/kitex v0.8.1-0.20240111074411-c4fd7c65edf8 +) diff --git a/grpc/tls/cert/gen.sh b/grpc/tls/cert/gen.sh new file mode 100644 index 0000000..69104a0 --- /dev/null +++ b/grpc/tls/cert/gen.sh @@ -0,0 +1,43 @@ +#! /bin/bash +# Copyright 2024 CloudWeGo Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +rm -f *.pem +rm -f *.srl + +# 1. Generate CA's private key and self-signed certificate +openssl req -x509 -newkey rsa:4096 -days 365 -nodes -keyout ca-key.pem -out ca-cert.pem -subj "/C=FR/ST=Occitanie/L=Toulouse/O=Tech School/OU=Education/CN=*.techschool.guru/emailAddress=techschool.guru@gmail.com" + +echo "CA's self-signed certificate" +openssl x509 -in ca-cert.pem -noout -text + +# 2. Generate web server's private key and certificate signing request (CSR) +openssl req -newkey rsa:4096 -nodes -keyout server-key.pem -out server-req.pem -subj "/C=FR/ST=Ile de France/L=Paris/O=PC Book/OU=Computer/CN=*.pcbook.com/emailAddress=pcbook@gmail.com" + +# 3. Use CA's private key to sign web server's CSR and get back the signed certificate +openssl x509 -req -in server-req.pem -days 60 -CA ca-cert.pem -CAkey ca-key.pem -CAcreateserial -out server-cert.pem + +echo "Server's signed certificate" +openssl x509 -in server-cert.pem -noout -text + +# 4. Generate client's private key and certificate signing request (CSR) +openssl req -newkey rsa:4096 -nodes -keyout client-key.pem -out client-req.pem -subj "/C=FR/ST=Alsace/L=Strasbourg/O=PC Client/OU=Computer/CN=*.pcclient.com/emailAddress=pcclient@gmail.com" + +# 5. Use CA's private key to sign client's CSR and get back the signed certificate +openssl x509 -req -in client-req.pem -days 60 -CA ca-cert.pem -CAkey ca-key.pem -CAcreateserial -out client-cert.pem + +echo "Client's signed certificate" +openssl x509 -in client-cert.pem -noout -text \ No newline at end of file diff --git a/grpc/tls/grpc_server.go b/grpc/tls/grpc_server.go new file mode 100644 index 0000000..08494e7 --- /dev/null +++ b/grpc/tls/grpc_server.go @@ -0,0 +1,130 @@ +// Copyright 2024 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package tls + +import ( + "context" + "crypto/tls" + "crypto/x509" + "fmt" + "io" + "io/ioutil" + "net" + "strings" + + "google.golang.org/grpc" + "google.golang.org/grpc/credentials" + + grpc_demo "github.com/cloudwego/kitex-tests/grpc_gen/protobuf/grpc_demo_2" +) + +func RunGRPCTLSServer(hostport string) (*grpc.Server, error) { + tlsCredentials, err := serverLoadTLSCredentials() + if err != nil { + return nil, err + } + cred := grpc.Creds(tlsCredentials) + + svr := grpc.NewServer(cred) + ms := &GrpcServiceA{} + grpc_demo.RegisterServiceAServer(svr, ms) + listener, err := net.Listen("tcp", hostport) + if err != nil { + return nil, err + } + go svr.Serve(listener) + return svr, nil +} + +type GrpcServiceA struct { + grpc_demo.UnimplementedServiceAServer +} + +func (s *GrpcServiceA) CallUnary(ctx context.Context, req *grpc_demo.Request) (*grpc_demo.Reply, error) { + res := &grpc_demo.Reply{Message: req.Name + " Hello!"} + return res, nil +} + +func (s *GrpcServiceA) CallClientStream(stream grpc_demo.ServiceA_CallClientStreamServer) error { + var msgs []string + for { + req, err := stream.Recv() + if err != nil { + if err == io.EOF { + break + } + return err + } + msgs = append(msgs, req.Name) + } + return stream.SendAndClose(&grpc_demo.Reply{Message: "all message: " + strings.Join(msgs, ", ")}) +} +func (s *GrpcServiceA) CallServerStream(req *grpc_demo.Request, stream grpc_demo.ServiceA_CallServerStreamServer) error { + resp := &grpc_demo.Reply{} + for i := 0; i < 3; i++ { + resp.Message = fmt.Sprintf("%v-%d", req.Name, i) + err := stream.Send(resp) + if err != nil { + return err + } + } + return nil +} +func (s *GrpcServiceA) CallBidiStream(stream grpc_demo.ServiceA_CallBidiStreamServer) error { + for { + recv, err := stream.Recv() + if err != nil { + if err == io.EOF { + break + } + return err + } + resp := &grpc_demo.Reply{} + resp.Message = recv.Name + err = stream.Send(resp) + if err != nil { + return err + } + } + return nil +} + +func serverLoadTLSCredentials() (credentials.TransportCredentials, error) { + // Load certificate of the CA who signed client's certificate + pemClientCA, err := ioutil.ReadFile("cert/ca-cert.pem") + if err != nil { + return nil, err + } + + certPool := x509.NewCertPool() + if !certPool.AppendCertsFromPEM(pemClientCA) { + return nil, fmt.Errorf("failed to add client CA's certificate") + } + + // Load server's certificate and private key + serverCert, err := tls.LoadX509KeyPair("cert/server-cert.pem", "cert/server-key.pem") + if err != nil { + return nil, err + } + + // Create the credentials and return it + config := &tls.Config{ + Certificates: []tls.Certificate{serverCert}, + ClientAuth: tls.RequireAndVerifyClientCert, // mTLS + ClientCAs: certPool, + } + + return credentials.NewTLS(config), nil +} diff --git a/grpc/tls/kitex_client.go b/grpc/tls/kitex_client.go new file mode 100644 index 0000000..c6d27bf --- /dev/null +++ b/grpc/tls/kitex_client.go @@ -0,0 +1,169 @@ +// Copyright 2024 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package tls + +import ( + "context" + "crypto/tls" + "crypto/x509" + "fmt" + "io" + "io/ioutil" + "strconv" + + "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt" + "github.com/cloudwego/kitex/transport" + + "github.com/cloudwego/kitex-tests/kitex_gen/protobuf/grpc_demo" + "github.com/cloudwego/kitex-tests/kitex_gen/protobuf/grpc_demo/servicea" +) + +type ClientWrapper struct { + client servicea.Client +} + +func GetClient(hostport string, clientOptions ...client.Option) (*ClientWrapper, error) { + opts := append(clientOptions, client.WithTransportProtocol(transport.GRPC), client.WithHostPorts(hostport)) + client, err := servicea.NewClient("kitex-test", opts...) + if err != nil { + return nil, err + } + return &ClientWrapper{client: client}, nil +} + +func (c *ClientWrapper) RunUnary(callOptions ...callopt.Option) (*grpc_demo.Reply, error) { + req := &grpc_demo.Request{Name: "Kitex"} + ctx := context.Background() + return c.client.CallUnary(ctx, req, callOptions...) +} + +func (c *ClientWrapper) RunClientStream(callOptions ...callopt.Option) (*grpc_demo.Reply, error) { + + ctx := context.Background() + streamCli, err := c.client.CallClientStream(ctx) + if err != nil { + return nil, err + } + for i := 0; i < 3; i++ { + req := &grpc_demo.Request{Name: "kitex-" + strconv.Itoa(i)} + err = streamCli.SendMsg(req) + if err != nil { + return nil, err + } + } + return streamCli.CloseAndRecv() +} + +func (c *ClientWrapper) RunServerStream(callOptions ...callopt.Option) ([]*grpc_demo.Reply, error) { + ctx := context.Background() + req := &grpc_demo.Request{Name: "kitex"} + streamCli, err := c.client.CallServerStream(ctx, req) + if err != nil { + return nil, err + } + replies := []*grpc_demo.Reply{} + for { + reply, er := streamCli.Recv() + if er != nil { + if er != io.EOF { + return nil, er + } + break + } + replies = append(replies, reply) + } + return replies, nil +} + +func (c *ClientWrapper) RunBidiStream(callOptions ...callopt.Option) ([]*grpc_demo.Reply, error) { + + ctx := context.Background() + stream, err := c.client.CallBidiStream(ctx) + if err != nil { + return nil, err + } + errChan := make(chan error) + go func() { + for i := 0; i < 3; i++ { + req := &grpc_demo.Request{Name: "kitex-" + strconv.Itoa(i)} + err = stream.Send(req) + if err != nil { + errChan <- err + return + } + } + er := stream.Close() + if er != nil { + errChan <- er + return + } + errChan <- nil + }() + repliesChan := make(chan []*grpc_demo.Reply) + errRecvChan := make(chan error) + go func() { + replies := []*grpc_demo.Reply{} + for { + reply, err := stream.Recv() + if err == io.EOF { + break + } + if err != nil { + errRecvChan <- err + return + } + replies = append(replies, reply) + } + repliesChan <- replies + }() + err = <-errChan + if err != nil { + return nil, err + } + select { + case replies := <-repliesChan: + return replies, nil + case err = <-errRecvChan: + return nil, err + } +} + +func clientLoadTLSCredentials() (*tls.Config, error) { + // Load certificate of the CA who signed server's certificate + pemServerCA, err := ioutil.ReadFile("cert/ca-cert.pem") + if err != nil { + return nil, err + } + + certPool := x509.NewCertPool() + if !certPool.AppendCertsFromPEM(pemServerCA) { + return nil, fmt.Errorf("failed to add server CA's certificate") + } + + // Load client's certificate and private key + clientCert, err := tls.LoadX509KeyPair("cert/client-cert.pem", "cert/client-key.pem") + if err != nil { + return nil, err + } + + // Create the credentials and return it + config := &tls.Config{ + Certificates: []tls.Certificate{clientCert}, + RootCAs: certPool, + InsecureSkipVerify: true, + } + return config, nil +} diff --git a/grpc/tls/tls_test.go b/grpc/tls/tls_test.go new file mode 100644 index 0000000..02aeff2 --- /dev/null +++ b/grpc/tls/tls_test.go @@ -0,0 +1,91 @@ +// Copyright 2024 CloudWeGo Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package tls + +import ( + "context" + "errors" + "log" + "os/exec" + "path/filepath" + "testing" + "time" + + client_opt "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/pkg/endpoint" + "github.com/cloudwego/kitex/pkg/rpcinfo" + + "github.com/cloudwego/kitex-tests/pkg/test" +) + +func TestMain(m *testing.M) { + err := generateCert() + if err != nil { + log.Printf("TLS test failed, error: %v", err) + return + } + m.Run() +} + +// Only Kitex gPRC client support TLS now. +func TestKitexClientGRPCTLSWithGRPCServer(t *testing.T) { + hostport := "localhost:9020" + svr, err := RunGRPCTLSServer(hostport) + test.Assert(t, err == nil, err) + defer svr.Stop() + + time.Sleep(time.Second) + cfg, err := clientLoadTLSCredentials() + test.Assert(t, err == nil, err) + client, err := GetClient(hostport, client_opt.WithMiddleware(ServiceNameMW), client_opt.WithGRPCTLSConfig(cfg)) + test.Assert(t, err == nil, err) + resp, err := client.RunUnary() + test.Assert(t, err == nil, err) + test.Assert(t, resp != nil && resp.Message == "Kitex Hello!") + resp, err = client.RunClientStream() + test.Assert(t, err == nil, err) + test.Assert(t, resp != nil && resp.Message == "all message: kitex-0, kitex-1, kitex-2") + respArr, err := client.RunServerStream() + test.Assert(t, err == nil, err) + test.Assert(t, len(respArr) == 3 && respArr[0].Message == "kitex-0" && respArr[1].Message == "kitex-1" && respArr[2].Message == "kitex-2") + respArr, err = client.RunBidiStream() + test.Assert(t, err == nil, err) + test.Assert(t, len(respArr) == 3 && respArr[0].Message == "kitex-0" && respArr[1].Message == "kitex-1" && respArr[2].Message == "kitex-2") +} + +// For modifying package name to avoid collision +func ServiceNameMW(next endpoint.Endpoint) endpoint.Endpoint { + return func(ctx context.Context, request, response interface{}) error { + + ri := rpcinfo.GetRPCInfo(ctx) + ink := ri.Invocation() + if ink, ok := ink.(rpcinfo.InvocationSetter); ok { + ink.SetPackageName("grpc_demo_2") + } else { + return errors.New("the interface Invocation doesn't implement InvocationSetter") + } + return next(ctx, request, response) + } +} + +func generateCert() error { + cmd := exec.Command("/bin/bash", "gen.sh") + path, err := filepath.Abs("cert") + if err != nil { + return err + } + cmd.Dir = path + return cmd.Run() +}