diff --git a/.travis/install-thrift.sh b/.travis/install-thrift.sh index 4a4fd2b..4615c07 100755 --- a/.travis/install-thrift.sh +++ b/.travis/install-thrift.sh @@ -11,16 +11,16 @@ BUILD="$HOME/.thrift-build" mkdir -p "$BUILD" cd "$BUILD" -rm -rf thrift-0.11.0 +rm -rf thrift-0.9.3 ls -if [ ! -d thrift-0.11.0 ]; then - wget http://archive.apache.org/dist/thrift/0.11.0/thrift-0.11.0.tar.gz - tar -xzf thrift-0.11.0.tar.gz - cd thrift-0.11.0 +if [ ! -d thrift-0.9.3 ]; then + wget http://archive.apache.org/dist/thrift/0.9.3/thrift-0.9.3.tar.gz + tar -xzf thrift-0.9.3.tar.gz + cd thrift-0.9.3 ./configure --enable-libs=no --enable-tests=no --enable-tutorial=no --without-haskell --without-java --without-python --without-ruby --without-perl --without-php --without-erlang else - cd thrift-0.11.0 + cd thrift-0.9.3 fi sudo make -j2 diff --git a/README.md b/README.md index 46ce958..4835a59 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,14 @@ # Turbo  [![Build Status](https://travis-ci.org/vaporz/turbo.svg?branch=master)](https://travis-ci.org/vaporz/turbo) [![Coverage Status](https://coveralls.io/repos/github/vaporz/turbo/badge.svg?branch=master)](https://coveralls.io/github/vaporz/turbo?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/vaporz/turbo)](https://goreportcard.com/report/github.com/vaporz/turbo) [![codebeat badge](https://codebeat.co/badges/7a166e48-dae1-454c-b925-4fbcd3f1f461)](https://codebeat.co/projects/github-com-vaporz-turbo-master) +本分支使用 Thrift v0.9.3版本。 -最新版本 | Latest Release: v0.3.0-thrift0.9 +最新版本 | Latest Release: v0.3.0-thrift0.9.3 文档地址 | Documentation: https://vaporz.github.io ## Requirements -Golang version: >= 1.9.x -Thrift version: 0.9.0 +Golang version: >= 1.9.1 +Thrift version: 0.9.3 ------------------------- diff --git a/creator.go b/creator.go index 401e899..71ddcbf 100644 --- a/creator.go +++ b/creator.go @@ -182,7 +182,7 @@ func (c *Creator) createThrift(serviceName string) { struct { ServiceName string }{serviceName}, - `namespace go gen + `namespace go services struct SayHelloResponse { 1: string message, @@ -315,15 +315,14 @@ func (c *Creator) generateThriftServiceImpl() { `package impl import ( - "context" - "{{.PkgPath}}/gen/thrift/gen-go/gen" + "{{.PkgPath}}/gen/thrift/gen-go/services" "git.apache.org/thrift.git/lib/go/thrift" ) // TProcessor returns TProcessor func TProcessor() map[string]thrift.TProcessor { return map[string]thrift.TProcessor{ - "{{.ServiceName}}": gen.New{{.ServiceName}}Processor({{.ServiceName}}{}), + "{{.ServiceName}}": services.New{{.ServiceName}}Processor({{.ServiceName}}{}), } } @@ -332,8 +331,8 @@ type {{.ServiceName}} struct { } // SayHello is an example entry point -func (s {{.ServiceName}}) SayHello(ctx context.Context, yourName string) (r *gen.SayHelloResponse, err error) { - return &gen.SayHelloResponse{Message: "[thrift server]Hello, " + yourName}, nil +func (s {{.ServiceName}}) SayHello(yourName string) (r *services.SayHelloResponse, err error) { + return &services.SayHelloResponse{Message: "[thrift server]Hello, " + yourName}, nil } `, ) @@ -434,7 +433,7 @@ func (c *Creator) generateThriftHTTPComponent() { `package component import ( - t "{{.PkgPath}}/gen/thrift/gen-go/gen" + t "{{.PkgPath}}/gen/thrift/gen-go/services" "git.apache.org/thrift.git/lib/go/thrift" "github.com/vaporz/turbo" ) diff --git a/generator.go b/generator.go index 5758e92..dd5df74 100644 --- a/generator.go +++ b/generator.go @@ -177,7 +177,7 @@ var buildThriftParameters = `package main import ( "flag" "fmt" - g "{{.PkgPath}}/gen/thrift/gen-go/gen" + g "{{.PkgPath}}/gen/thrift/gen-go/services" "io" "os" "reflect" @@ -212,11 +212,8 @@ func buildFields() { numIn := method.Type.NumIn() for j := 0; j < numIn; j++ { argType := method.Type.In(j) - argStr := argType.String() if argType.Kind() == reflect.Ptr && argType.Elem().Kind() == reflect.Struct { - arr := strings.Split(argStr, ".") - name := arr[len(arr)-1:][0] - items = findItem(items, name, argType) + items = findItem(items, argType.Elem().PkgPath()+"."+argType.Elem().Name(), argType) } } } @@ -237,11 +234,9 @@ func findItem(items []string, name string, structType reflect.Type) []string { for i := 0; i < numField; i++ { fieldType := structType.Elem().Field(i) if fieldType.Type.Kind() == reflect.Ptr && fieldType.Type.Elem().Kind() == reflect.Struct { - arr := strings.Split(fieldType.Type.String(), ".") - typeName := arr[len(arr)-1:][0] argName := fieldType.Name - item += fmt.Sprintf("%s %s,", typeName, argName) - items = findItem(items, typeName, fieldType.Type) + item += fmt.Sprintf("%s %s,", fieldType.Type.Elem().PkgPath()+"."+"."+fieldType.Type.Elem().Name(), argName) + items = findItem(items, fieldType.Type.Elem().PkgPath()+"."+"."+fieldType.Type.Elem().Name(), fieldType.Type) } } item += "]" @@ -315,8 +310,22 @@ func (g *Generator) GenerateThriftSwitcher() { var argCasesStr string fields := make([]string, 0, len(g.c.fieldMappings)) structNames := make([]string, 0, len(g.c.fieldMappings)) + structPrefixes := make([]string, 0, len(g.c.fieldMappings)) + importPackages := make(map[string]int) + importPackages[g.PkgPath+"/gen/thrift/gen-go/services"] = 1 for k := range g.c.fieldMappings { - structNames = append(structNames, k) + s := strings.Split(k, ".") + var importPackage string + for i, v := range s { + if i != len(s)-1 { + importPackage += v + "." + } + } + importPackage = importPackage[0 : len(importPackage)-1] + importPackages[importPackage] = 1 + packagePath := strings.Split(s[len(s)-2], "/") + structPrefixes = append(structPrefixes, packagePath[len(packagePath)-1]) + structNames = append(structNames, s[len(s)-1]) fields = append(fields, g.structFields(k)) } writeFileWithTemplate( @@ -328,8 +337,10 @@ func (g *Generator) GenerateThriftSwitcher() { ServiceMethodMap map[string][]string Parameters map[string][]string NotEmptyParameters map[string][]bool + StructPrefixes []string StructNames []string StructFields []string + ImportPackages map[string]int }{ g.PkgPath, argCasesStr, @@ -337,8 +348,10 @@ func (g *Generator) GenerateThriftSwitcher() { serviceMethodMap, parameters, notEmptyParameters, + structPrefixes, structNames, - fields}, + fields, + importPackages}, thriftSwitcherFunc, ) } @@ -377,10 +390,9 @@ var thriftSwitcherFunc = `// Code generated by turbo. DO NOT EDIT. package gen import ( - "context" "errors" - "github.com/vaporz/turbo" - "{{.PkgPath}}/gen/thrift/gen-go/gen" + "github.com/vaporz/turbo"{{range $p, $i := $.ImportPackages}} + "{{$p}}"{{end}} "net/http" "reflect" ) @@ -388,15 +400,14 @@ import ( // ThriftSwitcher is a runtime func with which a server starts. var ThriftSwitcher = func(s turbo.Servable, serviceName, methodName string, resp http.ResponseWriter, req *http.Request) (serviceResponse interface{}, err error) { {{range $Service, $Methods := .ServiceMethodMap}} if serviceName == "{{$Service}}" { - ctx := context.Background() switch methodName { {{range $i, $MethodName := $Methods}} case "{{$MethodName}}":{{if index $.NotEmptyParameters $Service $i }} - params, err := turbo.BuildThriftRequest(s, gen.{{$Service}}{{$MethodName}}Args{}, req, buildStructArg) + params, err := turbo.BuildThriftRequest(s, services.{{$Service}}{{$MethodName}}Args{}, req, buildStructArg) if err != nil { return nil, err }{{end}} - return s.Service("{{$Service}}").(*gen.{{$Service}}Client).{{$MethodName}}( - ctx,{{index $.Parameters $Service $i}}){{end}} + return s.Service("{{$Service}}").(*services.{{$Service}}Client).{{$MethodName}}( + {{index $.Parameters $Service $i}}){{end}} default: return nil, errors.New("No such method[" + methodName + "]") } @@ -412,7 +423,7 @@ func buildStructArg(s turbo.Servable, typeName string, req *http.Request) (v ref switch typeName { {{range $i, $StructName := .StructNames}} case "{{$StructName}}": - request := &gen.{{$StructName}}{ {{index $.StructFields $i}} } + request := &{{index $.StructPrefixes $i}}.{{$StructName}}{ {{index $.StructFields $i}} } turbo.BuildStruct(s, reflect.TypeOf(request).Elem(), reflect.ValueOf(request).Elem(), req) return reflect.ValueOf(request), nil {{end}} @@ -430,7 +441,12 @@ func (g *Generator) GenerateThriftStub() { nameLower := strings.ToLower(g.c.ThriftServiceNames()[0]) // todo change a thrift file name cmd := "thrift " + g.Options + " -r --gen go:package_prefix=" + g.PkgPath + "/gen/thrift/gen-go/ -o" + " " + g.c.ServiceRootPathAbsolute() + "/" + "gen/thrift " + g.c.ServiceRootPathAbsolute() + "/" + nameLower + ".thrift" + executeCmd("bash", "-c", cmd) + + // remove generated folder "*-remote", + // there're compiling errors in this folder, when importing a thrift file with a different package name. + executeCmd("bash", "-c", "find "+g.c.ServiceRootPathAbsolute()+"/"+"gen/thrift -name \"*-remote\" -exec rm -rf {} +") } func executeCmd(cmd string, args ...string) { diff --git a/go.mod b/go.mod index 739578e..b5d13f7 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/vaporz/turbo go 1.12 require ( - git.apache.org/thrift.git v0.0.0-20171203172758-327ebb6c2b6d + git.apache.org/thrift.git v0.0.0-20151001171628-53dd39833a08 github.com/bitly/go-simplejson v0.5.0 github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect github.com/fsnotify/fsnotify v1.4.7 diff --git a/go.sum b/go.sum index 15474cf..6df07f7 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -git.apache.org/thrift.git v0.0.0-20171203172758-327ebb6c2b6d h1:RsHq5kCWkxgbqyQPWB8OWNU/CRStjE/vusovT2bGKOw= -git.apache.org/thrift.git v0.0.0-20171203172758-327ebb6c2b6d/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= +git.apache.org/thrift.git v0.0.0-20151001171628-53dd39833a08 h1:goxS3HZARSCj217iYEtwVahA/7WJ9MbZR2QJMeMDmxM= +git.apache.org/thrift.git v0.0.0-20151001171628-53dd39833a08/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= diff --git a/test/integration_test.go b/test/integration_test.go index b1e4df9..0d106bb 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -10,7 +10,8 @@ import ( "github.com/vaporz/turbo" "github.com/vaporz/turbo/test/testservice/gen" "github.com/vaporz/turbo/test/testservice/gen/proto" - tgen "github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/gen" + "github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/services" + tgen "github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/shared" gcomponent "github.com/vaporz/turbo/test/testservice/grpcapi/component" gimpl "github.com/vaporz/turbo/test/testservice/grpcservice/impl" tcompoent "github.com/vaporz/turbo/test/testservice/thriftapi/component" @@ -291,7 +292,7 @@ message CommonValues { func overwriteThrift() { writeFileWithTemplate( turbo.GOPATH()+"/src/github.com/vaporz/turbo/test/testcreateservice/shared.thrift", - `namespace go gen + `namespace go shared struct CommonValues { 1: i64 transactionId, @@ -305,7 +306,7 @@ struct HelloValues { ) writeFileWithTemplate( turbo.GOPATH()+"/src/github.com/vaporz/turbo/test/testcreateservice/testcreateservice.thrift", - `namespace go gen + `namespace go services include "shared.thrift" struct SayHelloResponse { @@ -324,14 +325,14 @@ service TestCreateService { `package impl import ( - "context" - "github.com/vaporz/turbo/test/testcreateservice/gen/thrift/gen-go/gen" + "github.com/vaporz/turbo/test/testcreateservice/gen/thrift/gen-go/shared" + "github.com/vaporz/turbo/test/testcreateservice/gen/thrift/gen-go/services" "git.apache.org/thrift.git/lib/go/thrift" ) func TProcessor() map[string]thrift.TProcessor { return map[string]thrift.TProcessor{ - "TestCreateService": gen.NewTestCreateServiceProcessor(TestCreateService{}), + "TestCreateService": services.NewTestCreateServiceProcessor(TestCreateService{}), } } @@ -339,8 +340,8 @@ func TProcessor() map[string]thrift.TProcessor { type TestCreateService struct { } -func (s TestCreateService) SayHello(ctx context.Context, values *gen.CommonValues, yourName string, int64Value int64, boolValue bool, float64Value float64, uint64Value int64) (r *gen.SayHelloResponse, err error) { - return &gen.SayHelloResponse{Message: "[thrift server]Hello, " + yourName}, nil +func (s TestCreateService) SayHello(values *shared.CommonValues, yourName string, int64Value int64, boolValue bool, float64Value float64, uint64Value int64) (r *services.SayHelloResponse, err error) { + return &services.SayHelloResponse{Message: "[thrift server]Hello, " + yourName}, nil } `, nil, @@ -634,7 +635,7 @@ var postProcessor turbo.Postprocessor = func(resp http.ResponseWriter, req *http } var thriftPostProcessor turbo.Postprocessor = func(resp http.ResponseWriter, req *http.Request, serviceResp interface{}, err error) { - r := serviceResp.(*tgen.SayHelloResponse) + r := serviceResp.(*services.SayHelloResponse) resp.Write([]byte("postprocessor:" + r.Message)) } diff --git a/test/testservice/gen/grpcswitcher.go b/test/testservice/gen/grpcswitcher.go index c30511e..6e72758 100644 --- a/test/testservice/gen/grpcswitcher.go +++ b/test/testservice/gen/grpcswitcher.go @@ -26,20 +26,20 @@ var GrpcSwitcher = func(s turbo.Servable, serviceName, methodName string, resp h } if serviceName == "TestService" { switch methodName { - case "SayHello": - request := &g.SayHelloRequest{ Values: &g.CommonValues{}, } + case "TestJson": + request := &g.TestJsonRequest{ } err = turbo.BuildRequest(s, request, req) if err != nil { return nil, err } - rpcResponse, err = s.Service("TestService").(g.TestServiceClient).SayHello(req.Context(), request, callOptions...) - case "TestJson": - request := &g.TestJsonRequest{ } + rpcResponse, err = s.Service("TestService").(g.TestServiceClient).TestJson(req.Context(), request, callOptions...) + case "SayHello": + request := &g.SayHelloRequest{ Values: &g.CommonValues{}, } err = turbo.BuildRequest(s, request, req) if err != nil { return nil, err } - rpcResponse, err = s.Service("TestService").(g.TestServiceClient).TestJson(req.Context(), request, callOptions...) + rpcResponse, err = s.Service("TestService").(g.TestServiceClient).SayHello(req.Context(), request, callOptions...) default: return nil, errors.New("No such method[" + methodName + "]") } diff --git a/test/testservice/gen/proto/shared.pb.go b/test/testservice/gen/proto/shared.pb.go index 92c2efc..a1df96d 100644 --- a/test/testservice/gen/proto/shared.pb.go +++ b/test/testservice/gen/proto/shared.pb.go @@ -1,30 +1,16 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // source: shared.proto -/* -Package proto is a generated protocol buffer package. - -It is generated from these files: - shared.proto - testservice.proto - -It has these top-level messages: - CommonValues - SayHelloRequest - SayHelloResponse - TestJsonRequest - TestJsonResponse - EatRequest - EatResponse -*/ package proto -import proto1 "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto1.Marshal +var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf @@ -32,16 +18,39 @@ var _ = math.Inf // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. -const _ = proto1.ProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package type CommonValues struct { - SomeId int64 `protobuf:"varint,1,opt,name=someId" json:"someId,omitempty"` + SomeId int64 `protobuf:"varint,1,opt,name=someId,proto3" json:"someId,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *CommonValues) Reset() { *m = CommonValues{} } +func (m *CommonValues) String() string { return proto.CompactTextString(m) } +func (*CommonValues) ProtoMessage() {} +func (*CommonValues) Descriptor() ([]byte, []int) { + return fileDescriptor_d8a4e87e678c5ced, []int{0} +} + +func (m *CommonValues) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_CommonValues.Unmarshal(m, b) +} +func (m *CommonValues) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_CommonValues.Marshal(b, m, deterministic) +} +func (m *CommonValues) XXX_Merge(src proto.Message) { + xxx_messageInfo_CommonValues.Merge(m, src) +} +func (m *CommonValues) XXX_Size() int { + return xxx_messageInfo_CommonValues.Size(m) +} +func (m *CommonValues) XXX_DiscardUnknown() { + xxx_messageInfo_CommonValues.DiscardUnknown(m) } -func (m *CommonValues) Reset() { *m = CommonValues{} } -func (m *CommonValues) String() string { return proto1.CompactTextString(m) } -func (*CommonValues) ProtoMessage() {} -func (*CommonValues) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } +var xxx_messageInfo_CommonValues proto.InternalMessageInfo func (m *CommonValues) GetSomeId() int64 { if m != nil { @@ -51,12 +60,12 @@ func (m *CommonValues) GetSomeId() int64 { } func init() { - proto1.RegisterType((*CommonValues)(nil), "proto.CommonValues") + proto.RegisterType((*CommonValues)(nil), "proto.CommonValues") } -func init() { proto1.RegisterFile("shared.proto", fileDescriptor0) } +func init() { proto.RegisterFile("shared.proto", fileDescriptor_d8a4e87e678c5ced) } -var fileDescriptor0 = []byte{ +var fileDescriptor_d8a4e87e678c5ced = []byte{ // 81 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x29, 0xce, 0x48, 0x2c, 0x4a, 0x4d, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, 0x53, 0x4a, 0x6a, 0x5c, 0x3c, diff --git a/test/testservice/gen/proto/testservice.pb.go b/test/testservice/gen/proto/testservice.pb.go index 335a7de..ec28afd 100644 --- a/test/testservice/gen/proto/testservice.pb.go +++ b/test/testservice/gen/proto/testservice.pb.go @@ -3,38 +3,66 @@ package proto -import proto1 "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - import ( - context "golang.org/x/net/context" + context "context" + fmt "fmt" + proto "github.com/golang/protobuf/proto" grpc "google.golang.org/grpc" + math "math" ) // Reference imports to suppress errors if they are not otherwise used. -var _ = proto1.Marshal +var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package + type SayHelloRequest struct { - Values *CommonValues `protobuf:"bytes,1,opt,name=values" json:"values,omitempty"` - YourName string `protobuf:"bytes,2,opt,name=yourName" json:"yourName,omitempty"` - Int64Value int64 `protobuf:"varint,3,opt,name=int64Value" json:"int64Value,omitempty"` - BoolValue bool `protobuf:"varint,4,opt,name=boolValue" json:"boolValue,omitempty"` - Float64Value float64 `protobuf:"fixed64,5,opt,name=float64Value" json:"float64Value,omitempty"` - Uint64Value uint64 `protobuf:"varint,6,opt,name=uint64Value" json:"uint64Value,omitempty"` - StringList []string `protobuf:"bytes,7,rep,name=stringList" json:"stringList,omitempty"` - Int64List []int64 `protobuf:"varint,8,rep,packed,name=int64List" json:"int64List,omitempty"` - BoolList []bool `protobuf:"varint,9,rep,packed,name=boolList" json:"boolList,omitempty"` - DoubleList []float64 `protobuf:"fixed64,10,rep,packed,name=doubleList" json:"doubleList,omitempty"` - Uint64List []uint64 `protobuf:"varint,11,rep,packed,name=uint64List" json:"uint64List,omitempty"` -} - -func (m *SayHelloRequest) Reset() { *m = SayHelloRequest{} } -func (m *SayHelloRequest) String() string { return proto1.CompactTextString(m) } -func (*SayHelloRequest) ProtoMessage() {} -func (*SayHelloRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{0} } + Values *CommonValues `protobuf:"bytes,1,opt,name=values,proto3" json:"values,omitempty"` + YourName string `protobuf:"bytes,2,opt,name=yourName,proto3" json:"yourName,omitempty"` + Int64Value int64 `protobuf:"varint,3,opt,name=int64Value,proto3" json:"int64Value,omitempty"` + BoolValue bool `protobuf:"varint,4,opt,name=boolValue,proto3" json:"boolValue,omitempty"` + Float64Value float64 `protobuf:"fixed64,5,opt,name=float64Value,proto3" json:"float64Value,omitempty"` + Uint64Value uint64 `protobuf:"varint,6,opt,name=uint64Value,proto3" json:"uint64Value,omitempty"` + StringList []string `protobuf:"bytes,7,rep,name=stringList,proto3" json:"stringList,omitempty"` + Int64List []int64 `protobuf:"varint,8,rep,packed,name=int64List,proto3" json:"int64List,omitempty"` + BoolList []bool `protobuf:"varint,9,rep,packed,name=boolList,proto3" json:"boolList,omitempty"` + DoubleList []float64 `protobuf:"fixed64,10,rep,packed,name=doubleList,proto3" json:"doubleList,omitempty"` + Uint64List []uint64 `protobuf:"varint,11,rep,packed,name=uint64List,proto3" json:"uint64List,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SayHelloRequest) Reset() { *m = SayHelloRequest{} } +func (m *SayHelloRequest) String() string { return proto.CompactTextString(m) } +func (*SayHelloRequest) ProtoMessage() {} +func (*SayHelloRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_26bc9cfb0d6b6ad9, []int{0} +} + +func (m *SayHelloRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SayHelloRequest.Unmarshal(m, b) +} +func (m *SayHelloRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SayHelloRequest.Marshal(b, m, deterministic) +} +func (m *SayHelloRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SayHelloRequest.Merge(m, src) +} +func (m *SayHelloRequest) XXX_Size() int { + return xxx_messageInfo_SayHelloRequest.Size(m) +} +func (m *SayHelloRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SayHelloRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SayHelloRequest proto.InternalMessageInfo func (m *SayHelloRequest) GetValues() *CommonValues { if m != nil { @@ -114,13 +142,36 @@ func (m *SayHelloRequest) GetUint64List() []uint64 { } type SayHelloResponse struct { - Message string `protobuf:"bytes,1,opt,name=message" json:"message,omitempty"` + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SayHelloResponse) Reset() { *m = SayHelloResponse{} } +func (m *SayHelloResponse) String() string { return proto.CompactTextString(m) } +func (*SayHelloResponse) ProtoMessage() {} +func (*SayHelloResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_26bc9cfb0d6b6ad9, []int{1} } -func (m *SayHelloResponse) Reset() { *m = SayHelloResponse{} } -func (m *SayHelloResponse) String() string { return proto1.CompactTextString(m) } -func (*SayHelloResponse) ProtoMessage() {} -func (*SayHelloResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{1} } +func (m *SayHelloResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SayHelloResponse.Unmarshal(m, b) +} +func (m *SayHelloResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SayHelloResponse.Marshal(b, m, deterministic) +} +func (m *SayHelloResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_SayHelloResponse.Merge(m, src) +} +func (m *SayHelloResponse) XXX_Size() int { + return xxx_messageInfo_SayHelloResponse.Size(m) +} +func (m *SayHelloResponse) XXX_DiscardUnknown() { + xxx_messageInfo_SayHelloResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_SayHelloResponse proto.InternalMessageInfo func (m *SayHelloResponse) GetMessage() string { if m != nil { @@ -130,29 +181,98 @@ func (m *SayHelloResponse) GetMessage() string { } type TestJsonRequest struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *TestJsonRequest) Reset() { *m = TestJsonRequest{} } -func (m *TestJsonRequest) String() string { return proto1.CompactTextString(m) } -func (*TestJsonRequest) ProtoMessage() {} -func (*TestJsonRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{2} } +func (m *TestJsonRequest) Reset() { *m = TestJsonRequest{} } +func (m *TestJsonRequest) String() string { return proto.CompactTextString(m) } +func (*TestJsonRequest) ProtoMessage() {} +func (*TestJsonRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_26bc9cfb0d6b6ad9, []int{2} +} + +func (m *TestJsonRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_TestJsonRequest.Unmarshal(m, b) +} +func (m *TestJsonRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_TestJsonRequest.Marshal(b, m, deterministic) +} +func (m *TestJsonRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_TestJsonRequest.Merge(m, src) +} +func (m *TestJsonRequest) XXX_Size() int { + return xxx_messageInfo_TestJsonRequest.Size(m) +} +func (m *TestJsonRequest) XXX_DiscardUnknown() { + xxx_messageInfo_TestJsonRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_TestJsonRequest proto.InternalMessageInfo type TestJsonResponse struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *TestJsonResponse) Reset() { *m = TestJsonResponse{} } -func (m *TestJsonResponse) String() string { return proto1.CompactTextString(m) } -func (*TestJsonResponse) ProtoMessage() {} -func (*TestJsonResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{3} } +func (m *TestJsonResponse) Reset() { *m = TestJsonResponse{} } +func (m *TestJsonResponse) String() string { return proto.CompactTextString(m) } +func (*TestJsonResponse) ProtoMessage() {} +func (*TestJsonResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_26bc9cfb0d6b6ad9, []int{3} +} + +func (m *TestJsonResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_TestJsonResponse.Unmarshal(m, b) +} +func (m *TestJsonResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_TestJsonResponse.Marshal(b, m, deterministic) +} +func (m *TestJsonResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_TestJsonResponse.Merge(m, src) +} +func (m *TestJsonResponse) XXX_Size() int { + return xxx_messageInfo_TestJsonResponse.Size(m) +} +func (m *TestJsonResponse) XXX_DiscardUnknown() { + xxx_messageInfo_TestJsonResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_TestJsonResponse proto.InternalMessageInfo type EatRequest struct { - Food string `protobuf:"bytes,1,opt,name=food" json:"food,omitempty"` + Food string `protobuf:"bytes,1,opt,name=food,proto3" json:"food,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *EatRequest) Reset() { *m = EatRequest{} } +func (m *EatRequest) String() string { return proto.CompactTextString(m) } +func (*EatRequest) ProtoMessage() {} +func (*EatRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_26bc9cfb0d6b6ad9, []int{4} +} + +func (m *EatRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_EatRequest.Unmarshal(m, b) +} +func (m *EatRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_EatRequest.Marshal(b, m, deterministic) +} +func (m *EatRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_EatRequest.Merge(m, src) +} +func (m *EatRequest) XXX_Size() int { + return xxx_messageInfo_EatRequest.Size(m) +} +func (m *EatRequest) XXX_DiscardUnknown() { + xxx_messageInfo_EatRequest.DiscardUnknown(m) } -func (m *EatRequest) Reset() { *m = EatRequest{} } -func (m *EatRequest) String() string { return proto1.CompactTextString(m) } -func (*EatRequest) ProtoMessage() {} -func (*EatRequest) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{4} } +var xxx_messageInfo_EatRequest proto.InternalMessageInfo func (m *EatRequest) GetFood() string { if m != nil { @@ -162,13 +282,36 @@ func (m *EatRequest) GetFood() string { } type EatResponse struct { - Message string `protobuf:"bytes,1,opt,name=message" json:"message,omitempty"` + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (m *EatResponse) Reset() { *m = EatResponse{} } -func (m *EatResponse) String() string { return proto1.CompactTextString(m) } -func (*EatResponse) ProtoMessage() {} -func (*EatResponse) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{5} } +func (m *EatResponse) Reset() { *m = EatResponse{} } +func (m *EatResponse) String() string { return proto.CompactTextString(m) } +func (*EatResponse) ProtoMessage() {} +func (*EatResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_26bc9cfb0d6b6ad9, []int{5} +} + +func (m *EatResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_EatResponse.Unmarshal(m, b) +} +func (m *EatResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_EatResponse.Marshal(b, m, deterministic) +} +func (m *EatResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_EatResponse.Merge(m, src) +} +func (m *EatResponse) XXX_Size() int { + return xxx_messageInfo_EatResponse.Size(m) +} +func (m *EatResponse) XXX_DiscardUnknown() { + xxx_messageInfo_EatResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_EatResponse proto.InternalMessageInfo func (m *EatResponse) GetMessage() string { if m != nil { @@ -178,12 +321,44 @@ func (m *EatResponse) GetMessage() string { } func init() { - proto1.RegisterType((*SayHelloRequest)(nil), "proto.SayHelloRequest") - proto1.RegisterType((*SayHelloResponse)(nil), "proto.SayHelloResponse") - proto1.RegisterType((*TestJsonRequest)(nil), "proto.TestJsonRequest") - proto1.RegisterType((*TestJsonResponse)(nil), "proto.TestJsonResponse") - proto1.RegisterType((*EatRequest)(nil), "proto.EatRequest") - proto1.RegisterType((*EatResponse)(nil), "proto.EatResponse") + proto.RegisterType((*SayHelloRequest)(nil), "proto.SayHelloRequest") + proto.RegisterType((*SayHelloResponse)(nil), "proto.SayHelloResponse") + proto.RegisterType((*TestJsonRequest)(nil), "proto.TestJsonRequest") + proto.RegisterType((*TestJsonResponse)(nil), "proto.TestJsonResponse") + proto.RegisterType((*EatRequest)(nil), "proto.EatRequest") + proto.RegisterType((*EatResponse)(nil), "proto.EatResponse") +} + +func init() { proto.RegisterFile("testservice.proto", fileDescriptor_26bc9cfb0d6b6ad9) } + +var fileDescriptor_26bc9cfb0d6b6ad9 = []byte{ + // 408 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0x5f, 0xcb, 0xd3, 0x30, + 0x14, 0xc6, 0xdf, 0xbc, 0xe9, 0xb6, 0xf6, 0x74, 0xb8, 0x2d, 0x82, 0x96, 0x22, 0x12, 0x7a, 0x63, + 0x40, 0xd9, 0xc5, 0x14, 0xef, 0x04, 0x41, 0x04, 0x11, 0xf5, 0x22, 0x13, 0xef, 0x33, 0x97, 0xcd, + 0x42, 0xdb, 0xcc, 0x26, 0x1d, 0xec, 0x33, 0xf8, 0x85, 0xbd, 0x94, 0xa4, 0xe9, 0x1f, 0xb7, 0x8b, + 0xf7, 0xaa, 0xcd, 0xef, 0x9c, 0xe7, 0xc9, 0x73, 0x92, 0xc0, 0xca, 0x48, 0x6d, 0xb4, 0xac, 0xcf, + 0xf9, 0x4f, 0xb9, 0x3e, 0xd5, 0xca, 0x28, 0x32, 0x71, 0x9f, 0x74, 0xae, 0x7f, 0x89, 0x5a, 0xee, + 0x5b, 0x98, 0xfd, 0xbd, 0x87, 0xc5, 0x56, 0x5c, 0x3e, 0xc9, 0xa2, 0x50, 0x5c, 0xfe, 0x6e, 0xa4, + 0x36, 0xe4, 0x25, 0x4c, 0xcf, 0xa2, 0x68, 0xa4, 0x4e, 0x10, 0x45, 0x2c, 0xde, 0x3c, 0x6e, 0x7b, + 0xd7, 0x1f, 0x54, 0x59, 0xaa, 0xea, 0x87, 0x2b, 0x71, 0xdf, 0x42, 0x52, 0x08, 0x2f, 0xaa, 0xa9, + 0xbf, 0x89, 0x52, 0x26, 0xf7, 0x14, 0xb1, 0x88, 0xf7, 0x6b, 0xf2, 0x1c, 0x20, 0xaf, 0xcc, 0xdb, + 0x37, 0x4e, 0x92, 0x60, 0x8a, 0x18, 0xe6, 0x23, 0x42, 0x9e, 0x41, 0xb4, 0x53, 0xaa, 0x68, 0xcb, + 0x01, 0x45, 0x2c, 0xe4, 0x03, 0x20, 0x19, 0xcc, 0x0f, 0x85, 0x12, 0xbd, 0x7e, 0x42, 0x11, 0x43, + 0xfc, 0x3f, 0x46, 0x28, 0xc4, 0xcd, 0x68, 0x8b, 0x29, 0x45, 0x2c, 0xe0, 0x63, 0x64, 0x33, 0x68, + 0x53, 0xe7, 0xd5, 0xf1, 0x4b, 0xae, 0x4d, 0x32, 0xa3, 0x98, 0x45, 0x7c, 0x44, 0x6c, 0x06, 0xd7, + 0xed, 0xca, 0x21, 0xc5, 0x0c, 0xf3, 0x01, 0xd8, 0xe9, 0x6c, 0x20, 0x57, 0x8c, 0x28, 0x66, 0x21, + 0xef, 0xd7, 0xd6, 0x79, 0xaf, 0x9a, 0x5d, 0x21, 0x5d, 0x15, 0x28, 0x66, 0x88, 0x8f, 0x88, 0xad, + 0x37, 0x83, 0x75, 0x4c, 0x31, 0x0b, 0xf8, 0x88, 0x64, 0xaf, 0x60, 0x39, 0x9c, 0xbc, 0x3e, 0xa9, + 0x4a, 0x4b, 0x92, 0xc0, 0xac, 0x94, 0x5a, 0x8b, 0xa3, 0x74, 0x67, 0x1f, 0xf1, 0x6e, 0x99, 0xad, + 0x60, 0xf1, 0x5d, 0x6a, 0xf3, 0x59, 0xab, 0xca, 0xdf, 0x53, 0x46, 0x60, 0x39, 0xa0, 0xd6, 0x20, + 0xa3, 0x00, 0x1f, 0x85, 0xe9, 0x6e, 0x92, 0x40, 0x70, 0x50, 0x6a, 0xef, 0xbd, 0xdc, 0x7f, 0xf6, + 0x02, 0x62, 0xd7, 0xf1, 0xd0, 0x8e, 0x9b, 0x3f, 0x08, 0x62, 0xeb, 0xbf, 0x6d, 0x5f, 0x11, 0x79, + 0x07, 0xa1, 0xf6, 0x79, 0xc9, 0x13, 0xff, 0x24, 0xae, 0x9e, 0x4e, 0xfa, 0xf4, 0x86, 0xfb, 0x5c, + 0x77, 0x56, 0x6e, 0x7c, 0xda, 0x5e, 0x7e, 0x35, 0x51, 0x2f, 0xbf, 0x19, 0xeb, 0x6e, 0xf3, 0x1e, + 0x1e, 0x7d, 0xcd, 0xab, 0x5c, 0x55, 0xba, 0xcb, 0xb3, 0x06, 0x2c, 0x85, 0x21, 0x2b, 0xaf, 0x19, + 0xc6, 0x4e, 0xc9, 0x18, 0x75, 0x0e, 0xbb, 0xa9, 0x83, 0xaf, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, + 0xf1, 0x59, 0x4f, 0x63, 0x1b, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -194,8 +369,9 @@ var _ grpc.ClientConn // is compatible with the grpc package it is being compiled against. const _ = grpc.SupportPackageIsVersion4 -// Client API for TestService service - +// TestServiceClient is the client API for TestService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type TestServiceClient interface { SayHello(ctx context.Context, in *SayHelloRequest, opts ...grpc.CallOption) (*SayHelloResponse, error) TestJson(ctx context.Context, in *TestJsonRequest, opts ...grpc.CallOption) (*TestJsonResponse, error) @@ -211,7 +387,7 @@ func NewTestServiceClient(cc *grpc.ClientConn) TestServiceClient { func (c *testServiceClient) SayHello(ctx context.Context, in *SayHelloRequest, opts ...grpc.CallOption) (*SayHelloResponse, error) { out := new(SayHelloResponse) - err := grpc.Invoke(ctx, "/proto.TestService/sayHello", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/proto.TestService/sayHello", in, out, opts...) if err != nil { return nil, err } @@ -220,15 +396,14 @@ func (c *testServiceClient) SayHello(ctx context.Context, in *SayHelloRequest, o func (c *testServiceClient) TestJson(ctx context.Context, in *TestJsonRequest, opts ...grpc.CallOption) (*TestJsonResponse, error) { out := new(TestJsonResponse) - err := grpc.Invoke(ctx, "/proto.TestService/testJson", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/proto.TestService/testJson", in, out, opts...) if err != nil { return nil, err } return out, nil } -// Server API for TestService service - +// TestServiceServer is the server API for TestService service. type TestServiceServer interface { SayHello(context.Context, *SayHelloRequest) (*SayHelloResponse, error) TestJson(context.Context, *TestJsonRequest) (*TestJsonResponse, error) @@ -291,8 +466,9 @@ var _TestService_serviceDesc = grpc.ServiceDesc{ Metadata: "testservice.proto", } -// Client API for MinionsService service - +// MinionsServiceClient is the client API for MinionsService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MinionsServiceClient interface { Eat(ctx context.Context, in *EatRequest, opts ...grpc.CallOption) (*EatResponse, error) } @@ -307,15 +483,14 @@ func NewMinionsServiceClient(cc *grpc.ClientConn) MinionsServiceClient { func (c *minionsServiceClient) Eat(ctx context.Context, in *EatRequest, opts ...grpc.CallOption) (*EatResponse, error) { out := new(EatResponse) - err := grpc.Invoke(ctx, "/proto.MinionsService/eat", in, out, c.cc, opts...) + err := c.cc.Invoke(ctx, "/proto.MinionsService/eat", in, out, opts...) if err != nil { return nil, err } return out, nil } -// Server API for MinionsService service - +// MinionsServiceServer is the server API for MinionsService service. type MinionsServiceServer interface { Eat(context.Context, *EatRequest) (*EatResponse, error) } @@ -354,35 +529,3 @@ var _MinionsService_serviceDesc = grpc.ServiceDesc{ Streams: []grpc.StreamDesc{}, Metadata: "testservice.proto", } - -func init() { proto1.RegisterFile("testservice.proto", fileDescriptor1) } - -var fileDescriptor1 = []byte{ - // 408 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0x5f, 0xcb, 0xd3, 0x30, - 0x14, 0xc6, 0xdf, 0xbc, 0xe9, 0xb6, 0xf6, 0x74, 0xb8, 0x2d, 0x82, 0x96, 0x22, 0x12, 0x7a, 0x63, - 0x40, 0xd9, 0xc5, 0x14, 0xef, 0x04, 0x41, 0x04, 0x11, 0xf5, 0x22, 0x13, 0xef, 0x33, 0x97, 0xcd, - 0x42, 0xdb, 0xcc, 0x26, 0x1d, 0xec, 0x33, 0xf8, 0x85, 0xbd, 0x94, 0xa4, 0xe9, 0x1f, 0xb7, 0x8b, - 0xf7, 0xaa, 0xcd, 0xef, 0x9c, 0xe7, 0xc9, 0x73, 0x92, 0xc0, 0xca, 0x48, 0x6d, 0xb4, 0xac, 0xcf, - 0xf9, 0x4f, 0xb9, 0x3e, 0xd5, 0xca, 0x28, 0x32, 0x71, 0x9f, 0x74, 0xae, 0x7f, 0x89, 0x5a, 0xee, - 0x5b, 0x98, 0xfd, 0xbd, 0x87, 0xc5, 0x56, 0x5c, 0x3e, 0xc9, 0xa2, 0x50, 0x5c, 0xfe, 0x6e, 0xa4, - 0x36, 0xe4, 0x25, 0x4c, 0xcf, 0xa2, 0x68, 0xa4, 0x4e, 0x10, 0x45, 0x2c, 0xde, 0x3c, 0x6e, 0x7b, - 0xd7, 0x1f, 0x54, 0x59, 0xaa, 0xea, 0x87, 0x2b, 0x71, 0xdf, 0x42, 0x52, 0x08, 0x2f, 0xaa, 0xa9, - 0xbf, 0x89, 0x52, 0x26, 0xf7, 0x14, 0xb1, 0x88, 0xf7, 0x6b, 0xf2, 0x1c, 0x20, 0xaf, 0xcc, 0xdb, - 0x37, 0x4e, 0x92, 0x60, 0x8a, 0x18, 0xe6, 0x23, 0x42, 0x9e, 0x41, 0xb4, 0x53, 0xaa, 0x68, 0xcb, - 0x01, 0x45, 0x2c, 0xe4, 0x03, 0x20, 0x19, 0xcc, 0x0f, 0x85, 0x12, 0xbd, 0x7e, 0x42, 0x11, 0x43, - 0xfc, 0x3f, 0x46, 0x28, 0xc4, 0xcd, 0x68, 0x8b, 0x29, 0x45, 0x2c, 0xe0, 0x63, 0x64, 0x33, 0x68, - 0x53, 0xe7, 0xd5, 0xf1, 0x4b, 0xae, 0x4d, 0x32, 0xa3, 0x98, 0x45, 0x7c, 0x44, 0x6c, 0x06, 0xd7, - 0xed, 0xca, 0x21, 0xc5, 0x0c, 0xf3, 0x01, 0xd8, 0xe9, 0x6c, 0x20, 0x57, 0x8c, 0x28, 0x66, 0x21, - 0xef, 0xd7, 0xd6, 0x79, 0xaf, 0x9a, 0x5d, 0x21, 0x5d, 0x15, 0x28, 0x66, 0x88, 0x8f, 0x88, 0xad, - 0x37, 0x83, 0x75, 0x4c, 0x31, 0x0b, 0xf8, 0x88, 0x64, 0xaf, 0x60, 0x39, 0x9c, 0xbc, 0x3e, 0xa9, - 0x4a, 0x4b, 0x92, 0xc0, 0xac, 0x94, 0x5a, 0x8b, 0xa3, 0x74, 0x67, 0x1f, 0xf1, 0x6e, 0x99, 0xad, - 0x60, 0xf1, 0x5d, 0x6a, 0xf3, 0x59, 0xab, 0xca, 0xdf, 0x53, 0x46, 0x60, 0x39, 0xa0, 0xd6, 0x20, - 0xa3, 0x00, 0x1f, 0x85, 0xe9, 0x6e, 0x92, 0x40, 0x70, 0x50, 0x6a, 0xef, 0xbd, 0xdc, 0x7f, 0xf6, - 0x02, 0x62, 0xd7, 0xf1, 0xd0, 0x8e, 0x9b, 0x3f, 0x08, 0x62, 0xeb, 0xbf, 0x6d, 0x5f, 0x11, 0x79, - 0x07, 0xa1, 0xf6, 0x79, 0xc9, 0x13, 0xff, 0x24, 0xae, 0x9e, 0x4e, 0xfa, 0xf4, 0x86, 0xfb, 0x5c, - 0x77, 0x56, 0x6e, 0x7c, 0xda, 0x5e, 0x7e, 0x35, 0x51, 0x2f, 0xbf, 0x19, 0xeb, 0x6e, 0xf3, 0x1e, - 0x1e, 0x7d, 0xcd, 0xab, 0x5c, 0x55, 0xba, 0xcb, 0xb3, 0x06, 0x2c, 0x85, 0x21, 0x2b, 0xaf, 0x19, - 0xc6, 0x4e, 0xc9, 0x18, 0x75, 0x0e, 0xbb, 0xa9, 0x83, 0xaf, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, - 0xf1, 0x59, 0x4f, 0x63, 0x1b, 0x03, 0x00, 0x00, -} diff --git a/test/testservice/gen/thrift/build.go b/test/testservice/gen/thrift/build.go index c9de9b6..75bd7a5 100644 --- a/test/testservice/gen/thrift/build.go +++ b/test/testservice/gen/thrift/build.go @@ -3,7 +3,7 @@ package main import ( "flag" "fmt" - g "github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/gen" + g "github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/services" "io" "os" "reflect" @@ -39,11 +39,8 @@ func buildFields() { numIn := method.Type.NumIn() for j := 0; j < numIn; j++ { argType := method.Type.In(j) - argStr := argType.String() if argType.Kind() == reflect.Ptr && argType.Elem().Kind() == reflect.Struct { - arr := strings.Split(argStr, ".") - name := arr[len(arr)-1:][0] - items = findItem(items, name, argType) + items = findItem(items, argType.Elem().PkgPath()+"."+argType.Elem().Name(), argType) } } } @@ -64,11 +61,9 @@ func findItem(items []string, name string, structType reflect.Type) []string { for i := 0; i < numField; i++ { fieldType := structType.Elem().Field(i) if fieldType.Type.Kind() == reflect.Ptr && fieldType.Type.Elem().Kind() == reflect.Struct { - arr := strings.Split(fieldType.Type.String(), ".") - typeName := arr[len(arr)-1:][0] argName := fieldType.Name - item += fmt.Sprintf("%s %s,", typeName, argName) - items = findItem(items, typeName, fieldType.Type) + item += fmt.Sprintf("%s %s,", fieldType.Type.Elem().PkgPath()+"."+"."+fieldType.Type.Elem().Name(), argName) + items = findItem(items, fieldType.Type.Elem().PkgPath()+"."+"."+fieldType.Type.Elem().Name(), fieldType.Type) } } item += "]" diff --git a/test/testservice/gen/thrift/gen-go/gen/GoUnusedProtection__.go b/test/testservice/gen/thrift/gen-go/gen/GoUnusedProtection__.go deleted file mode 100644 index b8624e5..0000000 --- a/test/testservice/gen/thrift/gen-go/gen/GoUnusedProtection__.go +++ /dev/null @@ -1,7 +0,0 @@ -// Autogenerated by Thrift Compiler (0.11.0) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - -package gen - -var GoUnusedProtection__ int; - diff --git a/test/testservice/gen/thrift/gen-go/gen/minions_service-remote/minions_service-remote.go b/test/testservice/gen/thrift/gen-go/gen/minions_service-remote/minions_service-remote.go deleted file mode 100755 index b3b5abf..0000000 --- a/test/testservice/gen/thrift/gen-go/gen/minions_service-remote/minions_service-remote.go +++ /dev/null @@ -1,139 +0,0 @@ -// Autogenerated by Thrift Compiler (0.11.0) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - -package main - -import ( - "context" - "flag" - "fmt" - "math" - "net" - "net/url" - "os" - "strconv" - "strings" - "git.apache.org/thrift.git/lib/go/thrift" - "github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/gen" -) - - -func Usage() { - fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:") - flag.PrintDefaults() - fmt.Fprintln(os.Stderr, "\nFunctions:") - fmt.Fprintln(os.Stderr, " EatResponse Eat(string food)") - fmt.Fprintln(os.Stderr) - os.Exit(0) -} - -func main() { - flag.Usage = Usage - var host string - var port int - var protocol string - var urlString string - var framed bool - var useHttp bool - var parsedUrl *url.URL - var trans thrift.TTransport - _ = strconv.Atoi - _ = math.Abs - flag.Usage = Usage - flag.StringVar(&host, "h", "localhost", "Specify host and port") - flag.IntVar(&port, "p", 9090, "Specify port") - flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)") - flag.StringVar(&urlString, "u", "", "Specify the url") - flag.BoolVar(&framed, "framed", false, "Use framed transport") - flag.BoolVar(&useHttp, "http", false, "Use http") - flag.Parse() - - if len(urlString) > 0 { - var err error - parsedUrl, err = url.Parse(urlString) - if err != nil { - fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) - flag.Usage() - } - host = parsedUrl.Host - useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http" - } else if useHttp { - _, err := url.Parse(fmt.Sprint("http://", host, ":", port)) - if err != nil { - fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) - flag.Usage() - } - } - - cmd := flag.Arg(0) - var err error - if useHttp { - trans, err = thrift.NewTHttpClient(parsedUrl.String()) - } else { - portStr := fmt.Sprint(port) - if strings.Contains(host, ":") { - host, portStr, err = net.SplitHostPort(host) - if err != nil { - fmt.Fprintln(os.Stderr, "error with host:", err) - os.Exit(1) - } - } - trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr)) - if err != nil { - fmt.Fprintln(os.Stderr, "error resolving address:", err) - os.Exit(1) - } - if framed { - trans = thrift.NewTFramedTransport(trans) - } - } - if err != nil { - fmt.Fprintln(os.Stderr, "Error creating transport", err) - os.Exit(1) - } - defer trans.Close() - var protocolFactory thrift.TProtocolFactory - switch protocol { - case "compact": - protocolFactory = thrift.NewTCompactProtocolFactory() - break - case "simplejson": - protocolFactory = thrift.NewTSimpleJSONProtocolFactory() - break - case "json": - protocolFactory = thrift.NewTJSONProtocolFactory() - break - case "binary", "": - protocolFactory = thrift.NewTBinaryProtocolFactoryDefault() - break - default: - fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol) - Usage() - os.Exit(1) - } - iprot := protocolFactory.GetProtocol(trans) - oprot := protocolFactory.GetProtocol(trans) - client := gen.NewMinionsServiceClient(thrift.NewTStandardClient(iprot, oprot)) - if err := trans.Open(); err != nil { - fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err) - os.Exit(1) - } - - switch cmd { - case "Eat": - if flag.NArg() - 1 != 1 { - fmt.Fprintln(os.Stderr, "Eat requires 1 args") - flag.Usage() - } - argvalue0 := flag.Arg(1) - value0 := argvalue0 - fmt.Print(client.Eat(context.Background(), value0)) - fmt.Print("\n") - break - case "": - Usage() - break - default: - fmt.Fprintln(os.Stderr, "Invalid function ", cmd) - } -} diff --git a/test/testservice/gen/thrift/gen-go/gen/shared.go b/test/testservice/gen/thrift/gen-go/gen/shared.go deleted file mode 100644 index 524db34..0000000 --- a/test/testservice/gen/thrift/gen-go/gen/shared.go +++ /dev/null @@ -1,202 +0,0 @@ -// Autogenerated by Thrift Compiler (0.11.0) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - -package gen - -import ( - "bytes" - "reflect" - "context" - "fmt" - "git.apache.org/thrift.git/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = context.Background -var _ = reflect.DeepEqual -var _ = bytes.Equal - -// Attributes: -// - TransactionId -type CommonValues struct { - TransactionId int64 `thrift:"transactionId,1" db:"transactionId" json:"transactionId"` -} - -func NewCommonValues() *CommonValues { - return &CommonValues{} -} - - -func (p *CommonValues) GetTransactionId() int64 { - return p.TransactionId -} -func (p *CommonValues) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if fieldTypeId == thrift.I64 { - if err := p.ReadField1(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *CommonValues) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) -} else { - p.TransactionId = v -} - return nil -} - -func (p *CommonValues) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("CommonValues"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *CommonValues) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("transactionId", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:transactionId: ", p), err) } - if err := oprot.WriteI64(int64(p.TransactionId)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.transactionId (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:transactionId: ", p), err) } - return err -} - -func (p *CommonValues) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("CommonValues(%+v)", *p) -} - -// Attributes: -// - Message -type HelloValues struct { - Message string `thrift:"message,1" db:"message" json:"message"` -} - -func NewHelloValues() *HelloValues { - return &HelloValues{} -} - - -func (p *HelloValues) GetMessage() string { - return p.Message -} -func (p *HelloValues) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *HelloValues) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) -} else { - p.Message = v -} - return nil -} - -func (p *HelloValues) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("HelloValues"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *HelloValues) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:message: ", p), err) } - if err := oprot.WriteString(string(p.Message)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.message (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:message: ", p), err) } - return err -} - -func (p *HelloValues) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("HelloValues(%+v)", *p) -} - diff --git a/test/testservice/gen/thrift/gen-go/gen/test_service-remote/test_service-remote.go b/test/testservice/gen/thrift/gen-go/gen/test_service-remote/test_service-remote.go deleted file mode 100755 index 365e947..0000000 --- a/test/testservice/gen/thrift/gen-go/gen/test_service-remote/test_service-remote.go +++ /dev/null @@ -1,288 +0,0 @@ -// Autogenerated by Thrift Compiler (0.11.0) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - -package main - -import ( - "context" - "flag" - "fmt" - "math" - "net" - "net/url" - "os" - "strconv" - "strings" - "git.apache.org/thrift.git/lib/go/thrift" - "github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/gen" -) - - -func Usage() { - fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:") - flag.PrintDefaults() - fmt.Fprintln(os.Stderr, "\nFunctions:") - fmt.Fprintln(os.Stderr, " SayHelloResponse sayHello(CommonValues values, string yourName, i64 int64Value, bool boolValue, double float64Value, i64 uint64Value, i32 int32Value, i16 int16Value, stringList, i32List, boolList, doubleList)") - fmt.Fprintln(os.Stderr, " TestJsonResponse testJson(TestJsonRequest request)") - fmt.Fprintln(os.Stderr) - os.Exit(0) -} - -func main() { - flag.Usage = Usage - var host string - var port int - var protocol string - var urlString string - var framed bool - var useHttp bool - var parsedUrl *url.URL - var trans thrift.TTransport - _ = strconv.Atoi - _ = math.Abs - flag.Usage = Usage - flag.StringVar(&host, "h", "localhost", "Specify host and port") - flag.IntVar(&port, "p", 9090, "Specify port") - flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)") - flag.StringVar(&urlString, "u", "", "Specify the url") - flag.BoolVar(&framed, "framed", false, "Use framed transport") - flag.BoolVar(&useHttp, "http", false, "Use http") - flag.Parse() - - if len(urlString) > 0 { - var err error - parsedUrl, err = url.Parse(urlString) - if err != nil { - fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) - flag.Usage() - } - host = parsedUrl.Host - useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http" - } else if useHttp { - _, err := url.Parse(fmt.Sprint("http://", host, ":", port)) - if err != nil { - fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) - flag.Usage() - } - } - - cmd := flag.Arg(0) - var err error - if useHttp { - trans, err = thrift.NewTHttpClient(parsedUrl.String()) - } else { - portStr := fmt.Sprint(port) - if strings.Contains(host, ":") { - host, portStr, err = net.SplitHostPort(host) - if err != nil { - fmt.Fprintln(os.Stderr, "error with host:", err) - os.Exit(1) - } - } - trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr)) - if err != nil { - fmt.Fprintln(os.Stderr, "error resolving address:", err) - os.Exit(1) - } - if framed { - trans = thrift.NewTFramedTransport(trans) - } - } - if err != nil { - fmt.Fprintln(os.Stderr, "Error creating transport", err) - os.Exit(1) - } - defer trans.Close() - var protocolFactory thrift.TProtocolFactory - switch protocol { - case "compact": - protocolFactory = thrift.NewTCompactProtocolFactory() - break - case "simplejson": - protocolFactory = thrift.NewTSimpleJSONProtocolFactory() - break - case "json": - protocolFactory = thrift.NewTJSONProtocolFactory() - break - case "binary", "": - protocolFactory = thrift.NewTBinaryProtocolFactoryDefault() - break - default: - fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol) - Usage() - os.Exit(1) - } - iprot := protocolFactory.GetProtocol(trans) - oprot := protocolFactory.GetProtocol(trans) - client := gen.NewTestServiceClient(thrift.NewTStandardClient(iprot, oprot)) - if err := trans.Open(); err != nil { - fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err) - os.Exit(1) - } - - switch cmd { - case "sayHello": - if flag.NArg() - 1 != 12 { - fmt.Fprintln(os.Stderr, "SayHello requires 12 args") - flag.Usage() - } - arg10 := flag.Arg(1) - mbTrans11 := thrift.NewTMemoryBufferLen(len(arg10)) - defer mbTrans11.Close() - _, err12 := mbTrans11.WriteString(arg10) - if err12 != nil { - Usage() - return - } - factory13 := thrift.NewTSimpleJSONProtocolFactory() - jsProt14 := factory13.GetProtocol(mbTrans11) - argvalue0 := gen.NewCommonValues() - err15 := argvalue0.Read(jsProt14) - if err15 != nil { - Usage() - return - } - value0 := argvalue0 - argvalue1 := flag.Arg(2) - value1 := argvalue1 - argvalue2, err17 := (strconv.ParseInt(flag.Arg(3), 10, 64)) - if err17 != nil { - Usage() - return - } - value2 := argvalue2 - argvalue3 := flag.Arg(4) == "true" - value3 := argvalue3 - argvalue4, err19 := (strconv.ParseFloat(flag.Arg(5), 64)) - if err19 != nil { - Usage() - return - } - value4 := argvalue4 - argvalue5, err20 := (strconv.ParseInt(flag.Arg(6), 10, 64)) - if err20 != nil { - Usage() - return - } - value5 := argvalue5 - tmp6, err21 := (strconv.Atoi(flag.Arg(7))) - if err21 != nil { - Usage() - return - } - argvalue6 := int32(tmp6) - value6 := argvalue6 - tmp7, err22 := (strconv.Atoi(flag.Arg(8))) - if err22 != nil { - Usage() - return - } - argvalue7 := int16(tmp7) - value7 := argvalue7 - arg23 := flag.Arg(9) - mbTrans24 := thrift.NewTMemoryBufferLen(len(arg23)) - defer mbTrans24.Close() - _, err25 := mbTrans24.WriteString(arg23) - if err25 != nil { - Usage() - return - } - factory26 := thrift.NewTSimpleJSONProtocolFactory() - jsProt27 := factory26.GetProtocol(mbTrans24) - containerStruct8 := gen.NewTestServiceSayHelloArgs() - err28 := containerStruct8.ReadField9(jsProt27) - if err28 != nil { - Usage() - return - } - argvalue8 := containerStruct8.StringList - value8 := argvalue8 - arg29 := flag.Arg(10) - mbTrans30 := thrift.NewTMemoryBufferLen(len(arg29)) - defer mbTrans30.Close() - _, err31 := mbTrans30.WriteString(arg29) - if err31 != nil { - Usage() - return - } - factory32 := thrift.NewTSimpleJSONProtocolFactory() - jsProt33 := factory32.GetProtocol(mbTrans30) - containerStruct9 := gen.NewTestServiceSayHelloArgs() - err34 := containerStruct9.ReadField10(jsProt33) - if err34 != nil { - Usage() - return - } - argvalue9 := containerStruct9.I32List - value9 := argvalue9 - arg35 := flag.Arg(11) - mbTrans36 := thrift.NewTMemoryBufferLen(len(arg35)) - defer mbTrans36.Close() - _, err37 := mbTrans36.WriteString(arg35) - if err37 != nil { - Usage() - return - } - factory38 := thrift.NewTSimpleJSONProtocolFactory() - jsProt39 := factory38.GetProtocol(mbTrans36) - containerStruct10 := gen.NewTestServiceSayHelloArgs() - err40 := containerStruct10.ReadField11(jsProt39) - if err40 != nil { - Usage() - return - } - argvalue10 := containerStruct10.BoolList - value10 := argvalue10 - arg41 := flag.Arg(12) - mbTrans42 := thrift.NewTMemoryBufferLen(len(arg41)) - defer mbTrans42.Close() - _, err43 := mbTrans42.WriteString(arg41) - if err43 != nil { - Usage() - return - } - factory44 := thrift.NewTSimpleJSONProtocolFactory() - jsProt45 := factory44.GetProtocol(mbTrans42) - containerStruct11 := gen.NewTestServiceSayHelloArgs() - err46 := containerStruct11.ReadField12(jsProt45) - if err46 != nil { - Usage() - return - } - argvalue11 := containerStruct11.DoubleList - value11 := argvalue11 - fmt.Print(client.SayHello(context.Background(), value0, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10, value11)) - fmt.Print("\n") - break - case "testJson": - if flag.NArg() - 1 != 1 { - fmt.Fprintln(os.Stderr, "TestJson requires 1 args") - flag.Usage() - } - arg47 := flag.Arg(1) - mbTrans48 := thrift.NewTMemoryBufferLen(len(arg47)) - defer mbTrans48.Close() - _, err49 := mbTrans48.WriteString(arg47) - if err49 != nil { - Usage() - return - } - factory50 := thrift.NewTSimpleJSONProtocolFactory() - jsProt51 := factory50.GetProtocol(mbTrans48) - argvalue0 := gen.NewTestJsonRequest() - err52 := argvalue0.Read(jsProt51) - if err52 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.TestJson(context.Background(), value0)) - fmt.Print("\n") - break - case "": - Usage() - break - default: - fmt.Fprintln(os.Stderr, "Invalid function ", cmd) - } -} diff --git a/test/testservice/gen/thrift/gen-go/gen/testservice.go b/test/testservice/gen/thrift/gen-go/gen/testservice.go deleted file mode 100644 index 953c80a..0000000 --- a/test/testservice/gen/thrift/gen-go/gen/testservice.go +++ /dev/null @@ -1,1893 +0,0 @@ -// Autogenerated by Thrift Compiler (0.11.0) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - -package gen - -import ( - "bytes" - "reflect" - "context" - "fmt" - "git.apache.org/thrift.git/lib/go/thrift" - -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = context.Background -var _ = reflect.DeepEqual -var _ = bytes.Equal - -// Attributes: -// - Message -type SayHelloResponse struct { - Message string `thrift:"message,1" db:"message" json:"message"` -} - -func NewSayHelloResponse() *SayHelloResponse { - return &SayHelloResponse{} -} - - -func (p *SayHelloResponse) GetMessage() string { - return p.Message -} -func (p *SayHelloResponse) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SayHelloResponse) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) -} else { - p.Message = v -} - return nil -} - -func (p *SayHelloResponse) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("SayHelloResponse"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *SayHelloResponse) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:message: ", p), err) } - if err := oprot.WriteString(string(p.Message)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.message (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:message: ", p), err) } - return err -} - -func (p *SayHelloResponse) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("SayHelloResponse(%+v)", *p) -} - -// Attributes: -// - StringValue -// - Int32Value -// - BoolValue -type TestJsonRequest struct { - StringValue string `thrift:"stringValue,1" db:"stringValue" json:"stringValue"` - Int32Value int32 `thrift:"int32Value,2" db:"int32Value" json:"int32Value"` - BoolValue bool `thrift:"boolValue,3" db:"boolValue" json:"boolValue"` -} - -func NewTestJsonRequest() *TestJsonRequest { - return &TestJsonRequest{} -} - - -func (p *TestJsonRequest) GetStringValue() string { - return p.StringValue -} - -func (p *TestJsonRequest) GetInt32Value() int32 { - return p.Int32Value -} - -func (p *TestJsonRequest) GetBoolValue() bool { - return p.BoolValue -} -func (p *TestJsonRequest) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - case 2: - if fieldTypeId == thrift.I32 { - if err := p.ReadField2(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - case 3: - if fieldTypeId == thrift.BOOL { - if err := p.ReadField3(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TestJsonRequest) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) -} else { - p.StringValue = v -} - return nil -} - -func (p *TestJsonRequest) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) -} else { - p.Int32Value = v -} - return nil -} - -func (p *TestJsonRequest) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 3: ", err) -} else { - p.BoolValue = v -} - return nil -} - -func (p *TestJsonRequest) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("TestJsonRequest"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TestJsonRequest) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("stringValue", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:stringValue: ", p), err) } - if err := oprot.WriteString(string(p.StringValue)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.stringValue (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:stringValue: ", p), err) } - return err -} - -func (p *TestJsonRequest) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("int32Value", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:int32Value: ", p), err) } - if err := oprot.WriteI32(int32(p.Int32Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.int32Value (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:int32Value: ", p), err) } - return err -} - -func (p *TestJsonRequest) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("boolValue", thrift.BOOL, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:boolValue: ", p), err) } - if err := oprot.WriteBool(bool(p.BoolValue)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.boolValue (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:boolValue: ", p), err) } - return err -} - -func (p *TestJsonRequest) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("TestJsonRequest(%+v)", *p) -} - -// Attributes: -// - Message -type TestJsonResponse struct { - Message string `thrift:"message,1" db:"message" json:"message"` -} - -func NewTestJsonResponse() *TestJsonResponse { - return &TestJsonResponse{} -} - - -func (p *TestJsonResponse) GetMessage() string { - return p.Message -} -func (p *TestJsonResponse) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TestJsonResponse) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) -} else { - p.Message = v -} - return nil -} - -func (p *TestJsonResponse) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("TestJsonResponse"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TestJsonResponse) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:message: ", p), err) } - if err := oprot.WriteString(string(p.Message)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.message (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:message: ", p), err) } - return err -} - -func (p *TestJsonResponse) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("TestJsonResponse(%+v)", *p) -} - -// Attributes: -// - Message -type EatResponse struct { - Message string `thrift:"message,1" db:"message" json:"message"` -} - -func NewEatResponse() *EatResponse { - return &EatResponse{} -} - - -func (p *EatResponse) GetMessage() string { - return p.Message -} -func (p *EatResponse) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *EatResponse) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) -} else { - p.Message = v -} - return nil -} - -func (p *EatResponse) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("EatResponse"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *EatResponse) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:message: ", p), err) } - if err := oprot.WriteString(string(p.Message)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.message (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:message: ", p), err) } - return err -} - -func (p *EatResponse) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("EatResponse(%+v)", *p) -} - -type TestService interface { - // Parameters: - // - Values - // - YourName - // - Int64Value - // - BoolValue - // - Float64Value - // - Uint64Value - // - Int32Value - // - Int16Value - // - StringList - // - I32List - // - BoolList - // - DoubleList - SayHello(ctx context.Context, values *CommonValues, yourName string, int64Value int64, boolValue bool, float64Value float64, uint64Value int64, int32Value int32, int16Value int16, stringList []string, i32List []int32, boolList []bool, doubleList []float64) (r *SayHelloResponse, err error) - // Parameters: - // - Request - TestJson(ctx context.Context, request *TestJsonRequest) (r *TestJsonResponse, err error) -} - -type TestServiceClient struct { - c thrift.TClient -} - -// Deprecated: Use NewTestService instead -func NewTestServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *TestServiceClient { - return &TestServiceClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -// Deprecated: Use NewTestService instead -func NewTestServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *TestServiceClient { - return &TestServiceClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewTestServiceClient(c thrift.TClient) *TestServiceClient { - return &TestServiceClient{ - c: c, - } -} - -// Parameters: -// - Values -// - YourName -// - Int64Value -// - BoolValue -// - Float64Value -// - Uint64Value -// - Int32Value -// - Int16Value -// - StringList -// - I32List -// - BoolList -// - DoubleList -func (p *TestServiceClient) SayHello(ctx context.Context, values *CommonValues, yourName string, int64Value int64, boolValue bool, float64Value float64, uint64Value int64, int32Value int32, int16Value int16, stringList []string, i32List []int32, boolList []bool, doubleList []float64) (r *SayHelloResponse, err error) { - var _args0 TestServiceSayHelloArgs - _args0.Values = values - _args0.YourName = yourName - _args0.Int64Value = int64Value - _args0.BoolValue = boolValue - _args0.Float64Value = float64Value - _args0.Uint64Value = uint64Value - _args0.Int32Value = int32Value - _args0.Int16Value = int16Value - _args0.StringList = stringList - _args0.I32List = i32List - _args0.BoolList = boolList - _args0.DoubleList = doubleList - var _result1 TestServiceSayHelloResult - if err = p.c.Call(ctx, "sayHello", &_args0, &_result1); err != nil { - return - } - return _result1.GetSuccess(), nil -} - -// Parameters: -// - Request -func (p *TestServiceClient) TestJson(ctx context.Context, request *TestJsonRequest) (r *TestJsonResponse, err error) { - var _args2 TestServiceTestJsonArgs - _args2.Request = request - var _result3 TestServiceTestJsonResult - if err = p.c.Call(ctx, "testJson", &_args2, &_result3); err != nil { - return - } - return _result3.GetSuccess(), nil -} - -type TestServiceProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler TestService -} - -func (p *TestServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *TestServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *TestServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewTestServiceProcessor(handler TestService) *TestServiceProcessor { - - self4 := &TestServiceProcessor{handler:handler, processorMap:make(map[string]thrift.TProcessorFunction)} - self4.processorMap["sayHello"] = &testServiceProcessorSayHello{handler:handler} - self4.processorMap["testJson"] = &testServiceProcessorTestJson{handler:handler} -return self4 -} - -func (p *TestServiceProcessor) 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() - x5 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function " + name) - oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) - x5.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, x5 - -} - -type testServiceProcessorSayHello struct { - handler TestService -} - -func (p *testServiceProcessorSayHello) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := TestServiceSayHelloArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("sayHello", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := TestServiceSayHelloResult{} -var retval *SayHelloResponse - var err2 error - if retval, err2 = p.handler.SayHello(ctx, args.Values, args.YourName, args.Int64Value, args.BoolValue, args.Float64Value, args.Uint64Value, args.Int32Value, args.Int16Value, args.StringList, args.I32List, args.BoolList, args.DoubleList); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing sayHello: " + err2.Error()) - oprot.WriteMessageBegin("sayHello", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval -} - if err2 = oprot.WriteMessageBegin("sayHello", 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(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type testServiceProcessorTestJson struct { - handler TestService -} - -func (p *testServiceProcessorTestJson) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := TestServiceTestJsonArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("testJson", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := TestServiceTestJsonResult{} -var retval *TestJsonResponse - var err2 error - if retval, err2 = p.handler.TestJson(ctx, args.Request); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing testJson: " + err2.Error()) - oprot.WriteMessageBegin("testJson", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval -} - if err2 = oprot.WriteMessageBegin("testJson", 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(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - - -// HELPER FUNCTIONS AND STRUCTURES - -// Attributes: -// - Values -// - YourName -// - Int64Value -// - BoolValue -// - Float64Value -// - Uint64Value -// - Int32Value -// - Int16Value -// - StringList -// - I32List -// - BoolList -// - DoubleList -type TestServiceSayHelloArgs struct { - Values *CommonValues `thrift:"values,1" db:"values" json:"values"` - YourName string `thrift:"yourName,2" db:"yourName" json:"yourName"` - Int64Value int64 `thrift:"int64Value,3" db:"int64Value" json:"int64Value"` - BoolValue bool `thrift:"boolValue,4" db:"boolValue" json:"boolValue"` - Float64Value float64 `thrift:"float64Value,5" db:"float64Value" json:"float64Value"` - Uint64Value int64 `thrift:"uint64Value,6" db:"uint64Value" json:"uint64Value"` - Int32Value int32 `thrift:"int32Value,7" db:"int32Value" json:"int32Value"` - Int16Value int16 `thrift:"int16Value,8" db:"int16Value" json:"int16Value"` - StringList []string `thrift:"stringList,9" db:"stringList" json:"stringList"` - I32List []int32 `thrift:"i32List,10" db:"i32List" json:"i32List"` - BoolList []bool `thrift:"boolList,11" db:"boolList" json:"boolList"` - DoubleList []float64 `thrift:"doubleList,12" db:"doubleList" json:"doubleList"` -} - -func NewTestServiceSayHelloArgs() *TestServiceSayHelloArgs { - return &TestServiceSayHelloArgs{} -} - -var TestServiceSayHelloArgs_Values_DEFAULT *CommonValues -func (p *TestServiceSayHelloArgs) GetValues() *CommonValues { - if !p.IsSetValues() { - return TestServiceSayHelloArgs_Values_DEFAULT - } -return p.Values -} - -func (p *TestServiceSayHelloArgs) GetYourName() string { - return p.YourName -} - -func (p *TestServiceSayHelloArgs) GetInt64Value() int64 { - return p.Int64Value -} - -func (p *TestServiceSayHelloArgs) GetBoolValue() bool { - return p.BoolValue -} - -func (p *TestServiceSayHelloArgs) GetFloat64Value() float64 { - return p.Float64Value -} - -func (p *TestServiceSayHelloArgs) GetUint64Value() int64 { - return p.Uint64Value -} - -func (p *TestServiceSayHelloArgs) GetInt32Value() int32 { - return p.Int32Value -} - -func (p *TestServiceSayHelloArgs) GetInt16Value() int16 { - return p.Int16Value -} - -func (p *TestServiceSayHelloArgs) GetStringList() []string { - return p.StringList -} - -func (p *TestServiceSayHelloArgs) GetI32List() []int32 { - return p.I32List -} - -func (p *TestServiceSayHelloArgs) GetBoolList() []bool { - return p.BoolList -} - -func (p *TestServiceSayHelloArgs) GetDoubleList() []float64 { - return p.DoubleList -} -func (p *TestServiceSayHelloArgs) IsSetValues() bool { - return p.Values != nil -} - -func (p *TestServiceSayHelloArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - case 2: - if fieldTypeId == thrift.STRING { - if err := p.ReadField2(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - case 3: - if fieldTypeId == thrift.I64 { - if err := p.ReadField3(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - case 4: - if fieldTypeId == thrift.BOOL { - if err := p.ReadField4(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - case 5: - if fieldTypeId == thrift.DOUBLE { - if err := p.ReadField5(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - case 6: - if fieldTypeId == thrift.I64 { - if err := p.ReadField6(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - case 7: - if fieldTypeId == thrift.I32 { - if err := p.ReadField7(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - case 8: - if fieldTypeId == thrift.I16 { - if err := p.ReadField8(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - case 9: - if fieldTypeId == thrift.LIST { - if err := p.ReadField9(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - case 10: - if fieldTypeId == thrift.LIST { - if err := p.ReadField10(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - case 11: - if fieldTypeId == thrift.LIST { - if err := p.ReadField11(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - case 12: - if fieldTypeId == thrift.LIST { - if err := p.ReadField12(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TestServiceSayHelloArgs) ReadField1(iprot thrift.TProtocol) error { - p.Values = &CommonValues{} - if err := p.Values.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Values), err) - } - return nil -} - -func (p *TestServiceSayHelloArgs) ReadField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) -} else { - p.YourName = v -} - return nil -} - -func (p *TestServiceSayHelloArgs) ReadField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 3: ", err) -} else { - p.Int64Value = v -} - return nil -} - -func (p *TestServiceSayHelloArgs) ReadField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 4: ", err) -} else { - p.BoolValue = v -} - return nil -} - -func (p *TestServiceSayHelloArgs) ReadField5(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 5: ", err) -} else { - p.Float64Value = v -} - return nil -} - -func (p *TestServiceSayHelloArgs) ReadField6(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 6: ", err) -} else { - p.Uint64Value = v -} - return nil -} - -func (p *TestServiceSayHelloArgs) ReadField7(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 7: ", err) -} else { - p.Int32Value = v -} - return nil -} - -func (p *TestServiceSayHelloArgs) ReadField8(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI16(); err != nil { - return thrift.PrependError("error reading field 8: ", err) -} else { - p.Int16Value = v -} - return nil -} - -func (p *TestServiceSayHelloArgs) ReadField9(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]string, 0, size) - p.StringList = tSlice - for i := 0; i < size; i ++ { -var _elem6 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) -} else { - _elem6 = v -} - p.StringList = append(p.StringList, _elem6) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *TestServiceSayHelloArgs) ReadField10(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]int32, 0, size) - p.I32List = tSlice - for i := 0; i < size; i ++ { -var _elem7 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) -} else { - _elem7 = v -} - p.I32List = append(p.I32List, _elem7) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *TestServiceSayHelloArgs) ReadField11(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]bool, 0, size) - p.BoolList = tSlice - for i := 0; i < size; i ++ { -var _elem8 bool - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 0: ", err) -} else { - _elem8 = v -} - p.BoolList = append(p.BoolList, _elem8) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *TestServiceSayHelloArgs) ReadField12(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]float64, 0, size) - p.DoubleList = tSlice - for i := 0; i < size; i ++ { -var _elem9 float64 - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 0: ", err) -} else { - _elem9 = v -} - p.DoubleList = append(p.DoubleList, _elem9) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *TestServiceSayHelloArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("sayHello_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - if err := p.writeField2(oprot); err != nil { return err } - if err := p.writeField3(oprot); err != nil { return err } - if err := p.writeField4(oprot); err != nil { return err } - if err := p.writeField5(oprot); err != nil { return err } - if err := p.writeField6(oprot); err != nil { return err } - if err := p.writeField7(oprot); err != nil { return err } - if err := p.writeField8(oprot); err != nil { return err } - if err := p.writeField9(oprot); err != nil { return err } - if err := p.writeField10(oprot); err != nil { return err } - if err := p.writeField11(oprot); err != nil { return err } - if err := p.writeField12(oprot); err != nil { return err } - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TestServiceSayHelloArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("values", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:values: ", p), err) } - if err := p.Values.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Values), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:values: ", p), err) } - return err -} - -func (p *TestServiceSayHelloArgs) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("yourName", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:yourName: ", p), err) } - if err := oprot.WriteString(string(p.YourName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.yourName (2) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:yourName: ", p), err) } - return err -} - -func (p *TestServiceSayHelloArgs) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("int64Value", thrift.I64, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:int64Value: ", p), err) } - if err := oprot.WriteI64(int64(p.Int64Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.int64Value (3) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:int64Value: ", p), err) } - return err -} - -func (p *TestServiceSayHelloArgs) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("boolValue", thrift.BOOL, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:boolValue: ", p), err) } - if err := oprot.WriteBool(bool(p.BoolValue)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.boolValue (4) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:boolValue: ", p), err) } - return err -} - -func (p *TestServiceSayHelloArgs) writeField5(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("float64Value", thrift.DOUBLE, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:float64Value: ", p), err) } - if err := oprot.WriteDouble(float64(p.Float64Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.float64Value (5) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:float64Value: ", p), err) } - return err -} - -func (p *TestServiceSayHelloArgs) writeField6(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("uint64Value", thrift.I64, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:uint64Value: ", p), err) } - if err := oprot.WriteI64(int64(p.Uint64Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.uint64Value (6) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:uint64Value: ", p), err) } - return err -} - -func (p *TestServiceSayHelloArgs) writeField7(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("int32Value", thrift.I32, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:int32Value: ", p), err) } - if err := oprot.WriteI32(int32(p.Int32Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.int32Value (7) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:int32Value: ", p), err) } - return err -} - -func (p *TestServiceSayHelloArgs) writeField8(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("int16Value", thrift.I16, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:int16Value: ", p), err) } - if err := oprot.WriteI16(int16(p.Int16Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.int16Value (8) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:int16Value: ", p), err) } - return err -} - -func (p *TestServiceSayHelloArgs) writeField9(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("stringList", thrift.LIST, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:stringList: ", p), err) } - if err := oprot.WriteListBegin(thrift.STRING, len(p.StringList)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.StringList { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:stringList: ", p), err) } - return err -} - -func (p *TestServiceSayHelloArgs) writeField10(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("i32List", thrift.LIST, 10); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 10:i32List: ", p), err) } - if err := oprot.WriteListBegin(thrift.I32, len(p.I32List)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.I32List { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 10:i32List: ", p), err) } - return err -} - -func (p *TestServiceSayHelloArgs) writeField11(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("boolList", thrift.LIST, 11); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 11:boolList: ", p), err) } - if err := oprot.WriteListBegin(thrift.BOOL, len(p.BoolList)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.BoolList { - if err := oprot.WriteBool(bool(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 11:boolList: ", p), err) } - return err -} - -func (p *TestServiceSayHelloArgs) writeField12(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("doubleList", thrift.LIST, 12); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 12:doubleList: ", p), err) } - if err := oprot.WriteListBegin(thrift.DOUBLE, len(p.DoubleList)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.DoubleList { - if err := oprot.WriteDouble(float64(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 12:doubleList: ", p), err) } - return err -} - -func (p *TestServiceSayHelloArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("TestServiceSayHelloArgs(%+v)", *p) -} - -// Attributes: -// - Success -type TestServiceSayHelloResult struct { - Success *SayHelloResponse `thrift:"success,0" db:"success" json:"success,omitempty"` -} - -func NewTestServiceSayHelloResult() *TestServiceSayHelloResult { - return &TestServiceSayHelloResult{} -} - -var TestServiceSayHelloResult_Success_DEFAULT *SayHelloResponse -func (p *TestServiceSayHelloResult) GetSuccess() *SayHelloResponse { - if !p.IsSetSuccess() { - return TestServiceSayHelloResult_Success_DEFAULT - } -return p.Success -} -func (p *TestServiceSayHelloResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *TestServiceSayHelloResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TestServiceSayHelloResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = &SayHelloResponse{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *TestServiceSayHelloResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("sayHello_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if p != nil { - if err := p.writeField0(oprot); err != nil { return err } - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TestServiceSayHelloResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *TestServiceSayHelloResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("TestServiceSayHelloResult(%+v)", *p) -} - -// Attributes: -// - Request -type TestServiceTestJsonArgs struct { - Request *TestJsonRequest `thrift:"request,1" db:"request" json:"request"` -} - -func NewTestServiceTestJsonArgs() *TestServiceTestJsonArgs { - return &TestServiceTestJsonArgs{} -} - -var TestServiceTestJsonArgs_Request_DEFAULT *TestJsonRequest -func (p *TestServiceTestJsonArgs) GetRequest() *TestJsonRequest { - if !p.IsSetRequest() { - return TestServiceTestJsonArgs_Request_DEFAULT - } -return p.Request -} -func (p *TestServiceTestJsonArgs) IsSetRequest() bool { - return p.Request != nil -} - -func (p *TestServiceTestJsonArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRUCT { - if err := p.ReadField1(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TestServiceTestJsonArgs) ReadField1(iprot thrift.TProtocol) error { - p.Request = &TestJsonRequest{} - if err := p.Request.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Request), err) - } - return nil -} - -func (p *TestServiceTestJsonArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("testJson_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TestServiceTestJsonArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("request", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:request: ", p), err) } - if err := p.Request.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Request), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:request: ", p), err) } - return err -} - -func (p *TestServiceTestJsonArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("TestServiceTestJsonArgs(%+v)", *p) -} - -// Attributes: -// - Success -type TestServiceTestJsonResult struct { - Success *TestJsonResponse `thrift:"success,0" db:"success" json:"success,omitempty"` -} - -func NewTestServiceTestJsonResult() *TestServiceTestJsonResult { - return &TestServiceTestJsonResult{} -} - -var TestServiceTestJsonResult_Success_DEFAULT *TestJsonResponse -func (p *TestServiceTestJsonResult) GetSuccess() *TestJsonResponse { - if !p.IsSetSuccess() { - return TestServiceTestJsonResult_Success_DEFAULT - } -return p.Success -} -func (p *TestServiceTestJsonResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *TestServiceTestJsonResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TestServiceTestJsonResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = &TestJsonResponse{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *TestServiceTestJsonResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("testJson_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if p != nil { - if err := p.writeField0(oprot); err != nil { return err } - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *TestServiceTestJsonResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *TestServiceTestJsonResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("TestServiceTestJsonResult(%+v)", *p) -} - - -type MinionsService interface { - // Parameters: - // - Food - Eat(ctx context.Context, food string) (r *EatResponse, err error) -} - -type MinionsServiceClient struct { - c thrift.TClient -} - -// Deprecated: Use NewMinionsService instead -func NewMinionsServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *MinionsServiceClient { - return &MinionsServiceClient{ - c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), - } -} - -// Deprecated: Use NewMinionsService instead -func NewMinionsServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *MinionsServiceClient { - return &MinionsServiceClient{ - c: thrift.NewTStandardClient(iprot, oprot), - } -} - -func NewMinionsServiceClient(c thrift.TClient) *MinionsServiceClient { - return &MinionsServiceClient{ - c: c, - } -} - -// Parameters: -// - Food -func (p *MinionsServiceClient) Eat(ctx context.Context, food string) (r *EatResponse, err error) { - var _args53 MinionsServiceEatArgs - _args53.Food = food - var _result54 MinionsServiceEatResult - if err = p.c.Call(ctx, "Eat", &_args53, &_result54); err != nil { - return - } - return _result54.GetSuccess(), nil -} - -type MinionsServiceProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler MinionsService -} - -func (p *MinionsServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *MinionsServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *MinionsServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewMinionsServiceProcessor(handler MinionsService) *MinionsServiceProcessor { - - self55 := &MinionsServiceProcessor{handler:handler, processorMap:make(map[string]thrift.TProcessorFunction)} - self55.processorMap["Eat"] = &minionsServiceProcessorEat{handler:handler} -return self55 -} - -func (p *MinionsServiceProcessor) 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() - x56 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function " + name) - oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) - x56.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, x56 - -} - -type minionsServiceProcessorEat struct { - handler MinionsService -} - -func (p *minionsServiceProcessorEat) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := MinionsServiceEatArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("Eat", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := MinionsServiceEatResult{} -var retval *EatResponse - var err2 error - if retval, err2 = p.handler.Eat(ctx, args.Food); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Eat: " + err2.Error()) - oprot.WriteMessageBegin("Eat", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval -} - if err2 = oprot.WriteMessageBegin("Eat", 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(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - - -// HELPER FUNCTIONS AND STRUCTURES - -// Attributes: -// - Food -type MinionsServiceEatArgs struct { - Food string `thrift:"food,1" db:"food" json:"food"` -} - -func NewMinionsServiceEatArgs() *MinionsServiceEatArgs { - return &MinionsServiceEatArgs{} -} - - -func (p *MinionsServiceEatArgs) GetFood() string { - return p.Food -} -func (p *MinionsServiceEatArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 1: - if fieldTypeId == thrift.STRING { - if err := p.ReadField1(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MinionsServiceEatArgs) ReadField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) -} else { - p.Food = v -} - return nil -} - -func (p *MinionsServiceEatArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Eat_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if p != nil { - if err := p.writeField1(oprot); err != nil { return err } - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MinionsServiceEatArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("food", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:food: ", p), err) } - if err := oprot.WriteString(string(p.Food)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.food (1) field write error: ", p), err) } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:food: ", p), err) } - return err -} - -func (p *MinionsServiceEatArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("MinionsServiceEatArgs(%+v)", *p) -} - -// Attributes: -// - Success -type MinionsServiceEatResult struct { - Success *EatResponse `thrift:"success,0" db:"success" json:"success,omitempty"` -} - -func NewMinionsServiceEatResult() *MinionsServiceEatResult { - return &MinionsServiceEatResult{} -} - -var MinionsServiceEatResult_Success_DEFAULT *EatResponse -func (p *MinionsServiceEatResult) GetSuccess() *EatResponse { - if !p.IsSetSuccess() { - return MinionsServiceEatResult_Success_DEFAULT - } -return p.Success -} -func (p *MinionsServiceEatResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *MinionsServiceEatResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { break; } - switch fieldId { - case 0: - if fieldTypeId == thrift.STRUCT { - if err := p.ReadField0(iprot); err != nil { - return err - } - } else { - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MinionsServiceEatResult) ReadField0(iprot thrift.TProtocol) error { - p.Success = &EatResponse{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *MinionsServiceEatResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Eat_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } - if p != nil { - if err := p.writeField0(oprot); err != nil { return err } - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) } - return nil -} - -func (p *MinionsServiceEatResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } - } - return err -} - -func (p *MinionsServiceEatResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("MinionsServiceEatResult(%+v)", *p) -} - - diff --git a/test/testservice/gen/thrift/gen-go/gen/testservice-consts.go b/test/testservice/gen/thrift/gen-go/services/constants.go similarity index 63% rename from test/testservice/gen/thrift/gen-go/gen/testservice-consts.go rename to test/testservice/gen/thrift/gen-go/services/constants.go index 99f4de2..3f59834 100644 --- a/test/testservice/gen/thrift/gen-go/gen/testservice-consts.go +++ b/test/testservice/gen/thrift/gen-go/services/constants.go @@ -1,25 +1,21 @@ -// Autogenerated by Thrift Compiler (0.11.0) +// Autogenerated by Thrift Compiler (0.9.3) // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -package gen +package services import ( "bytes" - "reflect" - "context" "fmt" "git.apache.org/thrift.git/lib/go/thrift" - + "github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/shared" ) // (needed to ensure safety because of naive import list construction.) var _ = thrift.ZERO var _ = fmt.Printf -var _ = context.Background -var _ = reflect.DeepEqual var _ = bytes.Equal +var _ = shared.GoUnusedProtection__ func init() { } - diff --git a/test/testservice/gen/thrift/gen-go/services/minionsservice.go b/test/testservice/gen/thrift/gen-go/services/minionsservice.go new file mode 100644 index 0000000..ba0accc --- /dev/null +++ b/test/testservice/gen/thrift/gen-go/services/minionsservice.go @@ -0,0 +1,413 @@ +// Autogenerated by Thrift Compiler (0.9.3) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package services + +import ( + "bytes" + "fmt" + "git.apache.org/thrift.git/lib/go/thrift" + "github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/shared" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = bytes.Equal + +var _ = shared.GoUnusedProtection__ + +type MinionsService interface { + // Parameters: + // - Food + Eat(food string) (r *EatResponse, err error) +} + +type MinionsServiceClient struct { + Transport thrift.TTransport + ProtocolFactory thrift.TProtocolFactory + InputProtocol thrift.TProtocol + OutputProtocol thrift.TProtocol + SeqId int32 +} + +func NewMinionsServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *MinionsServiceClient { + return &MinionsServiceClient{Transport: t, + ProtocolFactory: f, + InputProtocol: f.GetProtocol(t), + OutputProtocol: f.GetProtocol(t), + SeqId: 0, + } +} + +func NewMinionsServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *MinionsServiceClient { + return &MinionsServiceClient{Transport: t, + ProtocolFactory: nil, + InputProtocol: iprot, + OutputProtocol: oprot, + SeqId: 0, + } +} + +// Parameters: +// - Food +func (p *MinionsServiceClient) Eat(food string) (r *EatResponse, err error) { + if err = p.sendEat(food); err != nil { + return + } + return p.recvEat() +} + +func (p *MinionsServiceClient) sendEat(food string) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("Eat", thrift.CALL, p.SeqId); err != nil { + return + } + args := MinionsServiceEatArgs{ + Food: food, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *MinionsServiceClient) recvEat() (value *EatResponse, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + method, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if method != "Eat" { + err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "Eat failed: wrong method name") + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "Eat failed: out of sequence response") + return + } + if mTypeId == thrift.EXCEPTION { + error53 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error54 error + error54, err = error53.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error54 + return + } + if mTypeId != thrift.REPLY { + err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "Eat failed: invalid message type") + return + } + result := MinionsServiceEatResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + value = result.GetSuccess() + return +} + +type MinionsServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler MinionsService +} + +func (p *MinionsServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *MinionsServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *MinionsServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewMinionsServiceProcessor(handler MinionsService) *MinionsServiceProcessor { + + self55 := &MinionsServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self55.processorMap["Eat"] = &minionsServiceProcessorEat{handler: handler} + return self55 +} + +func (p *MinionsServiceProcessor) Process(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(seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x56 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x56.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, x56 + +} + +type minionsServiceProcessorEat struct { + handler MinionsService +} + +func (p *minionsServiceProcessorEat) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := MinionsServiceEatArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("Eat", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := MinionsServiceEatResult{} + var retval *EatResponse + var err2 error + if retval, err2 = p.handler.Eat(args.Food); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Eat: "+err2.Error()) + oprot.WriteMessageBegin("Eat", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("Eat", 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(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +// HELPER FUNCTIONS AND STRUCTURES + +// Attributes: +// - Food +type MinionsServiceEatArgs struct { + Food string `thrift:"food,1" json:"food"` +} + +func NewMinionsServiceEatArgs() *MinionsServiceEatArgs { + return &MinionsServiceEatArgs{} +} + +func (p *MinionsServiceEatArgs) GetFood() string { + return p.Food +} +func (p *MinionsServiceEatArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.readField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *MinionsServiceEatArgs) readField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return thrift.PrependError("error reading field 1: ", err) + } else { + p.Food = v + } + return nil +} + +func (p *MinionsServiceEatArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("Eat_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return thrift.PrependError("write field stop error: ", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return thrift.PrependError("write struct stop error: ", err) + } + return nil +} + +func (p *MinionsServiceEatArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("food", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:food: ", p), err) + } + if err := oprot.WriteString(string(p.Food)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.food (1) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:food: ", p), err) + } + return err +} + +func (p *MinionsServiceEatArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("MinionsServiceEatArgs(%+v)", *p) +} + +// Attributes: +// - Success +type MinionsServiceEatResult struct { + Success *EatResponse `thrift:"success,0" json:"success,omitempty"` +} + +func NewMinionsServiceEatResult() *MinionsServiceEatResult { + return &MinionsServiceEatResult{} +} + +var MinionsServiceEatResult_Success_DEFAULT *EatResponse + +func (p *MinionsServiceEatResult) GetSuccess() *EatResponse { + if !p.IsSetSuccess() { + return MinionsServiceEatResult_Success_DEFAULT + } + return p.Success +} +func (p *MinionsServiceEatResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *MinionsServiceEatResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.readField0(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *MinionsServiceEatResult) readField0(iprot thrift.TProtocol) error { + p.Success = &EatResponse{} + if err := p.Success.Read(iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *MinionsServiceEatResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("Eat_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return thrift.PrependError("write field stop error: ", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return thrift.PrependError("write struct stop error: ", err) + } + return nil +} + +func (p *MinionsServiceEatResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) + } + if err := p.Success.Write(oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) + } + } + return err +} + +func (p *MinionsServiceEatResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("MinionsServiceEatResult(%+v)", *p) +} diff --git a/test/testservice/gen/thrift/gen-go/services/testservice.go b/test/testservice/gen/thrift/gen-go/services/testservice.go new file mode 100644 index 0000000..0e17f53 --- /dev/null +++ b/test/testservice/gen/thrift/gen-go/services/testservice.go @@ -0,0 +1,1252 @@ +// Autogenerated by Thrift Compiler (0.9.3) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package services + +import ( + "bytes" + "fmt" + "git.apache.org/thrift.git/lib/go/thrift" + "github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/shared" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = bytes.Equal + +var _ = shared.GoUnusedProtection__ + +type TestService interface { + // Parameters: + // - Values + // - YourName + // - Int64Value + // - BoolValue + // - Float64Value + // - Uint64Value + // - Int32Value + // - Int16Value + // - StringList + // - I32List + // - BoolList + // - DoubleList + SayHello(values *shared.CommonValues, yourName string, int64Value int64, boolValue bool, float64Value float64, uint64Value int64, int32Value int32, int16Value int16, stringList []string, i32List []int32, boolList []bool, doubleList []float64) (r *SayHelloResponse, err error) + // Parameters: + // - Request + TestJson(request *TestJsonRequest) (r *TestJsonResponse, err error) +} + +type TestServiceClient struct { + Transport thrift.TTransport + ProtocolFactory thrift.TProtocolFactory + InputProtocol thrift.TProtocol + OutputProtocol thrift.TProtocol + SeqId int32 +} + +func NewTestServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *TestServiceClient { + return &TestServiceClient{Transport: t, + ProtocolFactory: f, + InputProtocol: f.GetProtocol(t), + OutputProtocol: f.GetProtocol(t), + SeqId: 0, + } +} + +func NewTestServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *TestServiceClient { + return &TestServiceClient{Transport: t, + ProtocolFactory: nil, + InputProtocol: iprot, + OutputProtocol: oprot, + SeqId: 0, + } +} + +// Parameters: +// - Values +// - YourName +// - Int64Value +// - BoolValue +// - Float64Value +// - Uint64Value +// - Int32Value +// - Int16Value +// - StringList +// - I32List +// - BoolList +// - DoubleList +func (p *TestServiceClient) SayHello(values *shared.CommonValues, yourName string, int64Value int64, boolValue bool, float64Value float64, uint64Value int64, int32Value int32, int16Value int16, stringList []string, i32List []int32, boolList []bool, doubleList []float64) (r *SayHelloResponse, err error) { + if err = p.sendSayHello(values, yourName, int64Value, boolValue, float64Value, uint64Value, int32Value, int16Value, stringList, i32List, boolList, doubleList); err != nil { + return + } + return p.recvSayHello() +} + +func (p *TestServiceClient) sendSayHello(values *shared.CommonValues, yourName string, int64Value int64, boolValue bool, float64Value float64, uint64Value int64, int32Value int32, int16Value int16, stringList []string, i32List []int32, boolList []bool, doubleList []float64) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("sayHello", thrift.CALL, p.SeqId); err != nil { + return + } + args := TestServiceSayHelloArgs{ + Values: values, + YourName: yourName, + Int64Value: int64Value, + BoolValue: boolValue, + Float64Value: float64Value, + Uint64Value: uint64Value, + Int32Value: int32Value, + Int16Value: int16Value, + StringList: stringList, + I32List: i32List, + BoolList: boolList, + DoubleList: doubleList, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *TestServiceClient) recvSayHello() (value *SayHelloResponse, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + method, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if method != "sayHello" { + err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "sayHello failed: wrong method name") + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "sayHello failed: out of sequence response") + return + } + if mTypeId == thrift.EXCEPTION { + error0 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error1 error + error1, err = error0.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error1 + return + } + if mTypeId != thrift.REPLY { + err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "sayHello failed: invalid message type") + return + } + result := TestServiceSayHelloResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + value = result.GetSuccess() + return +} + +// Parameters: +// - Request +func (p *TestServiceClient) TestJson(request *TestJsonRequest) (r *TestJsonResponse, err error) { + if err = p.sendTestJson(request); err != nil { + return + } + return p.recvTestJson() +} + +func (p *TestServiceClient) sendTestJson(request *TestJsonRequest) (err error) { + oprot := p.OutputProtocol + if oprot == nil { + oprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.OutputProtocol = oprot + } + p.SeqId++ + if err = oprot.WriteMessageBegin("testJson", thrift.CALL, p.SeqId); err != nil { + return + } + args := TestServiceTestJsonArgs{ + Request: request, + } + if err = args.Write(oprot); err != nil { + return + } + if err = oprot.WriteMessageEnd(); err != nil { + return + } + return oprot.Flush() +} + +func (p *TestServiceClient) recvTestJson() (value *TestJsonResponse, err error) { + iprot := p.InputProtocol + if iprot == nil { + iprot = p.ProtocolFactory.GetProtocol(p.Transport) + p.InputProtocol = iprot + } + method, mTypeId, seqId, err := iprot.ReadMessageBegin() + if err != nil { + return + } + if method != "testJson" { + err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "testJson failed: wrong method name") + return + } + if p.SeqId != seqId { + err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "testJson failed: out of sequence response") + return + } + if mTypeId == thrift.EXCEPTION { + error2 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") + var error3 error + error3, err = error2.Read(iprot) + if err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + err = error3 + return + } + if mTypeId != thrift.REPLY { + err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "testJson failed: invalid message type") + return + } + result := TestServiceTestJsonResult{} + if err = result.Read(iprot); err != nil { + return + } + if err = iprot.ReadMessageEnd(); err != nil { + return + } + value = result.GetSuccess() + return +} + +type TestServiceProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler TestService +} + +func (p *TestServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *TestServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *TestServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewTestServiceProcessor(handler TestService) *TestServiceProcessor { + + self4 := &TestServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} + self4.processorMap["sayHello"] = &testServiceProcessorSayHello{handler: handler} + self4.processorMap["testJson"] = &testServiceProcessorTestJson{handler: handler} + return self4 +} + +func (p *TestServiceProcessor) Process(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(seqId, iprot, oprot) + } + iprot.Skip(thrift.STRUCT) + iprot.ReadMessageEnd() + x5 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) + oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) + x5.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, x5 + +} + +type testServiceProcessorSayHello struct { + handler TestService +} + +func (p *testServiceProcessorSayHello) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := TestServiceSayHelloArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("sayHello", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := TestServiceSayHelloResult{} + var retval *SayHelloResponse + var err2 error + if retval, err2 = p.handler.SayHello(args.Values, args.YourName, args.Int64Value, args.BoolValue, args.Float64Value, args.Uint64Value, args.Int32Value, args.Int16Value, args.StringList, args.I32List, args.BoolList, args.DoubleList); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing sayHello: "+err2.Error()) + oprot.WriteMessageBegin("sayHello", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("sayHello", 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(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +type testServiceProcessorTestJson struct { + handler TestService +} + +func (p *testServiceProcessorTestJson) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := TestServiceTestJsonArgs{} + if err = args.Read(iprot); err != nil { + iprot.ReadMessageEnd() + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) + oprot.WriteMessageBegin("testJson", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return false, err + } + + iprot.ReadMessageEnd() + result := TestServiceTestJsonResult{} + var retval *TestJsonResponse + var err2 error + if retval, err2 = p.handler.TestJson(args.Request); err2 != nil { + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing testJson: "+err2.Error()) + oprot.WriteMessageBegin("testJson", thrift.EXCEPTION, seqId) + x.Write(oprot) + oprot.WriteMessageEnd() + oprot.Flush() + return true, err2 + } else { + result.Success = retval + } + if err2 = oprot.WriteMessageBegin("testJson", 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(); err == nil && err2 != nil { + err = err2 + } + if err != nil { + return + } + return true, err +} + +// HELPER FUNCTIONS AND STRUCTURES + +// Attributes: +// - Values +// - YourName +// - Int64Value +// - BoolValue +// - Float64Value +// - Uint64Value +// - Int32Value +// - Int16Value +// - StringList +// - I32List +// - BoolList +// - DoubleList +type TestServiceSayHelloArgs struct { + Values *shared.CommonValues `thrift:"values,1" json:"values"` + YourName string `thrift:"yourName,2" json:"yourName"` + Int64Value int64 `thrift:"int64Value,3" json:"int64Value"` + BoolValue bool `thrift:"boolValue,4" json:"boolValue"` + Float64Value float64 `thrift:"float64Value,5" json:"float64Value"` + Uint64Value int64 `thrift:"uint64Value,6" json:"uint64Value"` + Int32Value int32 `thrift:"int32Value,7" json:"int32Value"` + Int16Value int16 `thrift:"int16Value,8" json:"int16Value"` + StringList []string `thrift:"stringList,9" json:"stringList"` + I32List []int32 `thrift:"i32List,10" json:"i32List"` + BoolList []bool `thrift:"boolList,11" json:"boolList"` + DoubleList []float64 `thrift:"doubleList,12" json:"doubleList"` +} + +func NewTestServiceSayHelloArgs() *TestServiceSayHelloArgs { + return &TestServiceSayHelloArgs{} +} + +var TestServiceSayHelloArgs_Values_DEFAULT *shared.CommonValues + +func (p *TestServiceSayHelloArgs) GetValues() *shared.CommonValues { + if !p.IsSetValues() { + return TestServiceSayHelloArgs_Values_DEFAULT + } + return p.Values +} + +func (p *TestServiceSayHelloArgs) GetYourName() string { + return p.YourName +} + +func (p *TestServiceSayHelloArgs) GetInt64Value() int64 { + return p.Int64Value +} + +func (p *TestServiceSayHelloArgs) GetBoolValue() bool { + return p.BoolValue +} + +func (p *TestServiceSayHelloArgs) GetFloat64Value() float64 { + return p.Float64Value +} + +func (p *TestServiceSayHelloArgs) GetUint64Value() int64 { + return p.Uint64Value +} + +func (p *TestServiceSayHelloArgs) GetInt32Value() int32 { + return p.Int32Value +} + +func (p *TestServiceSayHelloArgs) GetInt16Value() int16 { + return p.Int16Value +} + +func (p *TestServiceSayHelloArgs) GetStringList() []string { + return p.StringList +} + +func (p *TestServiceSayHelloArgs) GetI32List() []int32 { + return p.I32List +} + +func (p *TestServiceSayHelloArgs) GetBoolList() []bool { + return p.BoolList +} + +func (p *TestServiceSayHelloArgs) GetDoubleList() []float64 { + return p.DoubleList +} +func (p *TestServiceSayHelloArgs) IsSetValues() bool { + return p.Values != nil +} + +func (p *TestServiceSayHelloArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.readField1(iprot); err != nil { + return err + } + case 2: + if err := p.readField2(iprot); err != nil { + return err + } + case 3: + if err := p.readField3(iprot); err != nil { + return err + } + case 4: + if err := p.readField4(iprot); err != nil { + return err + } + case 5: + if err := p.readField5(iprot); err != nil { + return err + } + case 6: + if err := p.readField6(iprot); err != nil { + return err + } + case 7: + if err := p.readField7(iprot); err != nil { + return err + } + case 8: + if err := p.readField8(iprot); err != nil { + return err + } + case 9: + if err := p.readField9(iprot); err != nil { + return err + } + case 10: + if err := p.readField10(iprot); err != nil { + return err + } + case 11: + if err := p.readField11(iprot); err != nil { + return err + } + case 12: + if err := p.readField12(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TestServiceSayHelloArgs) readField1(iprot thrift.TProtocol) error { + p.Values = &shared.CommonValues{} + if err := p.Values.Read(iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Values), err) + } + return nil +} + +func (p *TestServiceSayHelloArgs) readField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return thrift.PrependError("error reading field 2: ", err) + } else { + p.YourName = v + } + return nil +} + +func (p *TestServiceSayHelloArgs) readField3(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return thrift.PrependError("error reading field 3: ", err) + } else { + p.Int64Value = v + } + return nil +} + +func (p *TestServiceSayHelloArgs) readField4(iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(); err != nil { + return thrift.PrependError("error reading field 4: ", err) + } else { + p.BoolValue = v + } + return nil +} + +func (p *TestServiceSayHelloArgs) readField5(iprot thrift.TProtocol) error { + if v, err := iprot.ReadDouble(); err != nil { + return thrift.PrependError("error reading field 5: ", err) + } else { + p.Float64Value = v + } + return nil +} + +func (p *TestServiceSayHelloArgs) readField6(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return thrift.PrependError("error reading field 6: ", err) + } else { + p.Uint64Value = v + } + return nil +} + +func (p *TestServiceSayHelloArgs) readField7(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(); err != nil { + return thrift.PrependError("error reading field 7: ", err) + } else { + p.Int32Value = v + } + return nil +} + +func (p *TestServiceSayHelloArgs) readField8(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI16(); err != nil { + return thrift.PrependError("error reading field 8: ", err) + } else { + p.Int16Value = v + } + return nil +} + +func (p *TestServiceSayHelloArgs) readField9(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + tSlice := make([]string, 0, size) + p.StringList = tSlice + for i := 0; i < size; i++ { + var _elem6 string + if v, err := iprot.ReadString(); err != nil { + return thrift.PrependError("error reading field 0: ", err) + } else { + _elem6 = v + } + p.StringList = append(p.StringList, _elem6) + } + if err := iprot.ReadListEnd(); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + return nil +} + +func (p *TestServiceSayHelloArgs) readField10(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + tSlice := make([]int32, 0, size) + p.I32List = tSlice + for i := 0; i < size; i++ { + var _elem7 int32 + if v, err := iprot.ReadI32(); err != nil { + return thrift.PrependError("error reading field 0: ", err) + } else { + _elem7 = v + } + p.I32List = append(p.I32List, _elem7) + } + if err := iprot.ReadListEnd(); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + return nil +} + +func (p *TestServiceSayHelloArgs) readField11(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + tSlice := make([]bool, 0, size) + p.BoolList = tSlice + for i := 0; i < size; i++ { + var _elem8 bool + if v, err := iprot.ReadBool(); err != nil { + return thrift.PrependError("error reading field 0: ", err) + } else { + _elem8 = v + } + p.BoolList = append(p.BoolList, _elem8) + } + if err := iprot.ReadListEnd(); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + return nil +} + +func (p *TestServiceSayHelloArgs) readField12(iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + tSlice := make([]float64, 0, size) + p.DoubleList = tSlice + for i := 0; i < size; i++ { + var _elem9 float64 + if v, err := iprot.ReadDouble(); err != nil { + return thrift.PrependError("error reading field 0: ", err) + } else { + _elem9 = v + } + p.DoubleList = append(p.DoubleList, _elem9) + } + if err := iprot.ReadListEnd(); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + return nil +} + +func (p *TestServiceSayHelloArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("sayHello_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := p.writeField3(oprot); err != nil { + return err + } + if err := p.writeField4(oprot); err != nil { + return err + } + if err := p.writeField5(oprot); err != nil { + return err + } + if err := p.writeField6(oprot); err != nil { + return err + } + if err := p.writeField7(oprot); err != nil { + return err + } + if err := p.writeField8(oprot); err != nil { + return err + } + if err := p.writeField9(oprot); err != nil { + return err + } + if err := p.writeField10(oprot); err != nil { + return err + } + if err := p.writeField11(oprot); err != nil { + return err + } + if err := p.writeField12(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return thrift.PrependError("write field stop error: ", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return thrift.PrependError("write struct stop error: ", err) + } + return nil +} + +func (p *TestServiceSayHelloArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("values", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:values: ", p), err) + } + if err := p.Values.Write(oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Values), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:values: ", p), err) + } + return err +} + +func (p *TestServiceSayHelloArgs) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("yourName", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:yourName: ", p), err) + } + if err := oprot.WriteString(string(p.YourName)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.yourName (2) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:yourName: ", p), err) + } + return err +} + +func (p *TestServiceSayHelloArgs) writeField3(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("int64Value", thrift.I64, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:int64Value: ", p), err) + } + if err := oprot.WriteI64(int64(p.Int64Value)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.int64Value (3) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:int64Value: ", p), err) + } + return err +} + +func (p *TestServiceSayHelloArgs) writeField4(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("boolValue", thrift.BOOL, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:boolValue: ", p), err) + } + if err := oprot.WriteBool(bool(p.BoolValue)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.boolValue (4) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:boolValue: ", p), err) + } + return err +} + +func (p *TestServiceSayHelloArgs) writeField5(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("float64Value", thrift.DOUBLE, 5); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:float64Value: ", p), err) + } + if err := oprot.WriteDouble(float64(p.Float64Value)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.float64Value (5) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 5:float64Value: ", p), err) + } + return err +} + +func (p *TestServiceSayHelloArgs) writeField6(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("uint64Value", thrift.I64, 6); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:uint64Value: ", p), err) + } + if err := oprot.WriteI64(int64(p.Uint64Value)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.uint64Value (6) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 6:uint64Value: ", p), err) + } + return err +} + +func (p *TestServiceSayHelloArgs) writeField7(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("int32Value", thrift.I32, 7); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:int32Value: ", p), err) + } + if err := oprot.WriteI32(int32(p.Int32Value)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.int32Value (7) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 7:int32Value: ", p), err) + } + return err +} + +func (p *TestServiceSayHelloArgs) writeField8(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("int16Value", thrift.I16, 8); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:int16Value: ", p), err) + } + if err := oprot.WriteI16(int16(p.Int16Value)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.int16Value (8) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 8:int16Value: ", p), err) + } + return err +} + +func (p *TestServiceSayHelloArgs) writeField9(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("stringList", thrift.LIST, 9); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:stringList: ", p), err) + } + if err := oprot.WriteListBegin(thrift.STRING, len(p.StringList)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range p.StringList { + if err := oprot.WriteString(string(v)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 9:stringList: ", p), err) + } + return err +} + +func (p *TestServiceSayHelloArgs) writeField10(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("i32List", thrift.LIST, 10); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 10:i32List: ", p), err) + } + if err := oprot.WriteListBegin(thrift.I32, len(p.I32List)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range p.I32List { + if err := oprot.WriteI32(int32(v)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 10:i32List: ", p), err) + } + return err +} + +func (p *TestServiceSayHelloArgs) writeField11(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("boolList", thrift.LIST, 11); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 11:boolList: ", p), err) + } + if err := oprot.WriteListBegin(thrift.BOOL, len(p.BoolList)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range p.BoolList { + if err := oprot.WriteBool(bool(v)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 11:boolList: ", p), err) + } + return err +} + +func (p *TestServiceSayHelloArgs) writeField12(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("doubleList", thrift.LIST, 12); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 12:doubleList: ", p), err) + } + if err := oprot.WriteListBegin(thrift.DOUBLE, len(p.DoubleList)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range p.DoubleList { + if err := oprot.WriteDouble(float64(v)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 12:doubleList: ", p), err) + } + return err +} + +func (p *TestServiceSayHelloArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TestServiceSayHelloArgs(%+v)", *p) +} + +// Attributes: +// - Success +type TestServiceSayHelloResult struct { + Success *SayHelloResponse `thrift:"success,0" json:"success,omitempty"` +} + +func NewTestServiceSayHelloResult() *TestServiceSayHelloResult { + return &TestServiceSayHelloResult{} +} + +var TestServiceSayHelloResult_Success_DEFAULT *SayHelloResponse + +func (p *TestServiceSayHelloResult) GetSuccess() *SayHelloResponse { + if !p.IsSetSuccess() { + return TestServiceSayHelloResult_Success_DEFAULT + } + return p.Success +} +func (p *TestServiceSayHelloResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *TestServiceSayHelloResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.readField0(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TestServiceSayHelloResult) readField0(iprot thrift.TProtocol) error { + p.Success = &SayHelloResponse{} + if err := p.Success.Read(iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *TestServiceSayHelloResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("sayHello_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return thrift.PrependError("write field stop error: ", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return thrift.PrependError("write struct stop error: ", err) + } + return nil +} + +func (p *TestServiceSayHelloResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) + } + if err := p.Success.Write(oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) + } + } + return err +} + +func (p *TestServiceSayHelloResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TestServiceSayHelloResult(%+v)", *p) +} + +// Attributes: +// - Request +type TestServiceTestJsonArgs struct { + Request *TestJsonRequest `thrift:"request,1" json:"request"` +} + +func NewTestServiceTestJsonArgs() *TestServiceTestJsonArgs { + return &TestServiceTestJsonArgs{} +} + +var TestServiceTestJsonArgs_Request_DEFAULT *TestJsonRequest + +func (p *TestServiceTestJsonArgs) GetRequest() *TestJsonRequest { + if !p.IsSetRequest() { + return TestServiceTestJsonArgs_Request_DEFAULT + } + return p.Request +} +func (p *TestServiceTestJsonArgs) IsSetRequest() bool { + return p.Request != nil +} + +func (p *TestServiceTestJsonArgs) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.readField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TestServiceTestJsonArgs) readField1(iprot thrift.TProtocol) error { + p.Request = &TestJsonRequest{} + if err := p.Request.Read(iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Request), err) + } + return nil +} + +func (p *TestServiceTestJsonArgs) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("testJson_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return thrift.PrependError("write field stop error: ", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return thrift.PrependError("write struct stop error: ", err) + } + return nil +} + +func (p *TestServiceTestJsonArgs) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("request", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:request: ", p), err) + } + if err := p.Request.Write(oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Request), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:request: ", p), err) + } + return err +} + +func (p *TestServiceTestJsonArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TestServiceTestJsonArgs(%+v)", *p) +} + +// Attributes: +// - Success +type TestServiceTestJsonResult struct { + Success *TestJsonResponse `thrift:"success,0" json:"success,omitempty"` +} + +func NewTestServiceTestJsonResult() *TestServiceTestJsonResult { + return &TestServiceTestJsonResult{} +} + +var TestServiceTestJsonResult_Success_DEFAULT *TestJsonResponse + +func (p *TestServiceTestJsonResult) GetSuccess() *TestJsonResponse { + if !p.IsSetSuccess() { + return TestServiceTestJsonResult_Success_DEFAULT + } + return p.Success +} +func (p *TestServiceTestJsonResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *TestServiceTestJsonResult) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 0: + if err := p.readField0(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TestServiceTestJsonResult) readField0(iprot thrift.TProtocol) error { + p.Success = &TestJsonResponse{} + if err := p.Success.Read(iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *TestServiceTestJsonResult) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("testJson_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) + } + if err := p.writeField0(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return thrift.PrependError("write field stop error: ", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return thrift.PrependError("write struct stop error: ", err) + } + return nil +} + +func (p *TestServiceTestJsonResult) writeField0(oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) + } + if err := p.Success.Write(oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) + } + } + return err +} + +func (p *TestServiceTestJsonResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TestServiceTestJsonResult(%+v)", *p) +} diff --git a/test/testservice/gen/thrift/gen-go/services/ttypes.go b/test/testservice/gen/thrift/gen-go/services/ttypes.go new file mode 100644 index 0000000..072ace9 --- /dev/null +++ b/test/testservice/gen/thrift/gen-go/services/ttypes.go @@ -0,0 +1,453 @@ +// Autogenerated by Thrift Compiler (0.9.3) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package services + +import ( + "bytes" + "fmt" + "git.apache.org/thrift.git/lib/go/thrift" + "github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/shared" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = bytes.Equal + +var _ = shared.GoUnusedProtection__ +var GoUnusedProtection__ int + +// Attributes: +// - Message +type SayHelloResponse struct { + Message string `thrift:"message,1" json:"message"` +} + +func NewSayHelloResponse() *SayHelloResponse { + return &SayHelloResponse{} +} + +func (p *SayHelloResponse) GetMessage() string { + return p.Message +} +func (p *SayHelloResponse) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.readField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *SayHelloResponse) readField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return thrift.PrependError("error reading field 1: ", err) + } else { + p.Message = v + } + return nil +} + +func (p *SayHelloResponse) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("SayHelloResponse"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return thrift.PrependError("write field stop error: ", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return thrift.PrependError("write struct stop error: ", err) + } + return nil +} + +func (p *SayHelloResponse) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:message: ", p), err) + } + if err := oprot.WriteString(string(p.Message)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.message (1) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:message: ", p), err) + } + return err +} + +func (p *SayHelloResponse) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("SayHelloResponse(%+v)", *p) +} + +// Attributes: +// - StringValue +// - Int32Value +// - BoolValue +type TestJsonRequest struct { + StringValue string `thrift:"stringValue,1" json:"stringValue"` + Int32Value int32 `thrift:"int32Value,2" json:"int32Value"` + BoolValue bool `thrift:"boolValue,3" json:"boolValue"` +} + +func NewTestJsonRequest() *TestJsonRequest { + return &TestJsonRequest{} +} + +func (p *TestJsonRequest) GetStringValue() string { + return p.StringValue +} + +func (p *TestJsonRequest) GetInt32Value() int32 { + return p.Int32Value +} + +func (p *TestJsonRequest) GetBoolValue() bool { + return p.BoolValue +} +func (p *TestJsonRequest) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.readField1(iprot); err != nil { + return err + } + case 2: + if err := p.readField2(iprot); err != nil { + return err + } + case 3: + if err := p.readField3(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TestJsonRequest) readField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return thrift.PrependError("error reading field 1: ", err) + } else { + p.StringValue = v + } + return nil +} + +func (p *TestJsonRequest) readField2(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(); err != nil { + return thrift.PrependError("error reading field 2: ", err) + } else { + p.Int32Value = v + } + return nil +} + +func (p *TestJsonRequest) readField3(iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(); err != nil { + return thrift.PrependError("error reading field 3: ", err) + } else { + p.BoolValue = v + } + return nil +} + +func (p *TestJsonRequest) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("TestJsonRequest"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := p.writeField3(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return thrift.PrependError("write field stop error: ", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return thrift.PrependError("write struct stop error: ", err) + } + return nil +} + +func (p *TestJsonRequest) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("stringValue", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:stringValue: ", p), err) + } + if err := oprot.WriteString(string(p.StringValue)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.stringValue (1) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:stringValue: ", p), err) + } + return err +} + +func (p *TestJsonRequest) writeField2(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("int32Value", thrift.I32, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:int32Value: ", p), err) + } + if err := oprot.WriteI32(int32(p.Int32Value)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.int32Value (2) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:int32Value: ", p), err) + } + return err +} + +func (p *TestJsonRequest) writeField3(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("boolValue", thrift.BOOL, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:boolValue: ", p), err) + } + if err := oprot.WriteBool(bool(p.BoolValue)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.boolValue (3) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:boolValue: ", p), err) + } + return err +} + +func (p *TestJsonRequest) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TestJsonRequest(%+v)", *p) +} + +// Attributes: +// - Message +type TestJsonResponse struct { + Message string `thrift:"message,1" json:"message"` +} + +func NewTestJsonResponse() *TestJsonResponse { + return &TestJsonResponse{} +} + +func (p *TestJsonResponse) GetMessage() string { + return p.Message +} +func (p *TestJsonResponse) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.readField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TestJsonResponse) readField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return thrift.PrependError("error reading field 1: ", err) + } else { + p.Message = v + } + return nil +} + +func (p *TestJsonResponse) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("TestJsonResponse"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return thrift.PrependError("write field stop error: ", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return thrift.PrependError("write struct stop error: ", err) + } + return nil +} + +func (p *TestJsonResponse) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:message: ", p), err) + } + if err := oprot.WriteString(string(p.Message)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.message (1) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:message: ", p), err) + } + return err +} + +func (p *TestJsonResponse) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TestJsonResponse(%+v)", *p) +} + +// Attributes: +// - Message +type EatResponse struct { + Message string `thrift:"message,1" json:"message"` +} + +func NewEatResponse() *EatResponse { + return &EatResponse{} +} + +func (p *EatResponse) GetMessage() string { + return p.Message +} +func (p *EatResponse) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.readField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *EatResponse) readField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return thrift.PrependError("error reading field 1: ", err) + } else { + p.Message = v + } + return nil +} + +func (p *EatResponse) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("EatResponse"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return thrift.PrependError("write field stop error: ", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return thrift.PrependError("write struct stop error: ", err) + } + return nil +} + +func (p *EatResponse) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:message: ", p), err) + } + if err := oprot.WriteString(string(p.Message)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.message (1) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:message: ", p), err) + } + return err +} + +func (p *EatResponse) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("EatResponse(%+v)", *p) +} diff --git a/test/testservice/gen/thrift/gen-go/gen/shared-consts.go b/test/testservice/gen/thrift/gen-go/shared/constants.go similarity index 68% rename from test/testservice/gen/thrift/gen-go/gen/shared-consts.go rename to test/testservice/gen/thrift/gen-go/shared/constants.go index eb0146f..ab3e8fb 100644 --- a/test/testservice/gen/thrift/gen-go/gen/shared-consts.go +++ b/test/testservice/gen/thrift/gen-go/shared/constants.go @@ -1,12 +1,10 @@ -// Autogenerated by Thrift Compiler (0.11.0) +// Autogenerated by Thrift Compiler (0.9.3) // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING -package gen +package shared import ( "bytes" - "reflect" - "context" "fmt" "git.apache.org/thrift.git/lib/go/thrift" ) @@ -14,11 +12,7 @@ import ( // (needed to ensure safety because of naive import list construction.) var _ = thrift.ZERO var _ = fmt.Printf -var _ = context.Background -var _ = reflect.DeepEqual var _ = bytes.Equal - func init() { } - diff --git a/test/testservice/gen/thrift/gen-go/shared/ttypes.go b/test/testservice/gen/thrift/gen-go/shared/ttypes.go new file mode 100644 index 0000000..2589962 --- /dev/null +++ b/test/testservice/gen/thrift/gen-go/shared/ttypes.go @@ -0,0 +1,199 @@ +// Autogenerated by Thrift Compiler (0.9.3) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +package shared + +import ( + "bytes" + "fmt" + "git.apache.org/thrift.git/lib/go/thrift" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = bytes.Equal + +var GoUnusedProtection__ int + +// Attributes: +// - TransactionId +type CommonValues struct { + TransactionId int64 `thrift:"transactionId,1" json:"transactionId"` +} + +func NewCommonValues() *CommonValues { + return &CommonValues{} +} + +func (p *CommonValues) GetTransactionId() int64 { + return p.TransactionId +} +func (p *CommonValues) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.readField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *CommonValues) readField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return thrift.PrependError("error reading field 1: ", err) + } else { + p.TransactionId = v + } + return nil +} + +func (p *CommonValues) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("CommonValues"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return thrift.PrependError("write field stop error: ", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return thrift.PrependError("write struct stop error: ", err) + } + return nil +} + +func (p *CommonValues) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("transactionId", thrift.I64, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:transactionId: ", p), err) + } + if err := oprot.WriteI64(int64(p.TransactionId)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.transactionId (1) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:transactionId: ", p), err) + } + return err +} + +func (p *CommonValues) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("CommonValues(%+v)", *p) +} + +// Attributes: +// - Message +type HelloValues struct { + Message string `thrift:"message,1" json:"message"` +} + +func NewHelloValues() *HelloValues { + return &HelloValues{} +} + +func (p *HelloValues) GetMessage() string { + return p.Message +} +func (p *HelloValues) Read(iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { + break + } + switch fieldId { + case 1: + if err := p.readField1(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *HelloValues) readField1(iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return thrift.PrependError("error reading field 1: ", err) + } else { + p.Message = v + } + return nil +} + +func (p *HelloValues) Write(oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin("HelloValues"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return thrift.PrependError("write field stop error: ", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return thrift.PrependError("write struct stop error: ", err) + } + return nil +} + +func (p *HelloValues) writeField1(oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:message: ", p), err) + } + if err := oprot.WriteString(string(p.Message)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.message (1) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:message: ", p), err) + } + return err +} + +func (p *HelloValues) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("HelloValues(%+v)", *p) +} diff --git a/test/testservice/gen/thriftfields.yaml b/test/testservice/gen/thriftfields.yaml index 33e4ac1..3570caf 100644 --- a/test/testservice/gen/thriftfields.yaml +++ b/test/testservice/gen/thriftfields.yaml @@ -1,4 +1,4 @@ thrift-fieldmapping: - - CommonValues[] - - TestJsonRequest[] + - github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/shared.CommonValues[] + - github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/services.TestJsonRequest[] diff --git a/test/testservice/gen/thriftswitcher.go b/test/testservice/gen/thriftswitcher.go index 67affd4..25c713e 100644 --- a/test/testservice/gen/thriftswitcher.go +++ b/test/testservice/gen/thriftswitcher.go @@ -2,10 +2,10 @@ package gen import ( - "context" "errors" "github.com/vaporz/turbo" - "github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/gen" + "github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/services" + "github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/shared" "net/http" "reflect" ) @@ -13,15 +13,14 @@ import ( // ThriftSwitcher is a runtime func with which a server starts. var ThriftSwitcher = func(s turbo.Servable, serviceName, methodName string, resp http.ResponseWriter, req *http.Request) (serviceResponse interface{}, err error) { if serviceName == "MinionsService" { - ctx := context.Background() switch methodName { case "Eat": - params, err := turbo.BuildThriftRequest(s, gen.MinionsServiceEatArgs{}, req, buildStructArg) + params, err := turbo.BuildThriftRequest(s, services.MinionsServiceEatArgs{}, req, buildStructArg) if err != nil { return nil, err } - return s.Service("MinionsService").(*gen.MinionsServiceClient).Eat( - ctx, + return s.Service("MinionsService").(*services.MinionsServiceClient).Eat( + params[0].Interface().(string), ) default: return nil, errors.New("No such method[" + methodName + "]") @@ -29,16 +28,15 @@ var ThriftSwitcher = func(s turbo.Servable, serviceName, methodName string, resp } if serviceName == "TestService" { - ctx := context.Background() switch methodName { case "SayHello": - params, err := turbo.BuildThriftRequest(s, gen.TestServiceSayHelloArgs{}, req, buildStructArg) + params, err := turbo.BuildThriftRequest(s, services.TestServiceSayHelloArgs{}, req, buildStructArg) if err != nil { return nil, err } - return s.Service("TestService").(*gen.TestServiceClient).SayHello( - ctx, - params[0].Interface().(*gen.CommonValues), + return s.Service("TestService").(*services.TestServiceClient).SayHello( + + params[0].Interface().(*shared.CommonValues), params[1].Interface().(string), params[2].Interface().(int64), params[3].Interface().(bool), @@ -51,13 +49,13 @@ var ThriftSwitcher = func(s turbo.Servable, serviceName, methodName string, resp params[10].Interface().([]bool), params[11].Interface().([]float64), ) case "TestJson": - params, err := turbo.BuildThriftRequest(s, gen.TestServiceTestJsonArgs{}, req, buildStructArg) + params, err := turbo.BuildThriftRequest(s, services.TestServiceTestJsonArgs{}, req, buildStructArg) if err != nil { return nil, err } - return s.Service("TestService").(*gen.TestServiceClient).TestJson( - ctx, - params[0].Interface().(*gen.TestJsonRequest), ) + return s.Service("TestService").(*services.TestServiceClient).TestJson( + + params[0].Interface().(*services.TestJsonRequest), ) default: return nil, errors.New("No such method[" + methodName + "]") } @@ -73,12 +71,12 @@ func buildStructArg(s turbo.Servable, typeName string, req *http.Request) (v ref switch typeName { case "CommonValues": - request := &gen.CommonValues{ } + request := &shared.CommonValues{ } turbo.BuildStruct(s, reflect.TypeOf(request).Elem(), reflect.ValueOf(request).Elem(), req) return reflect.ValueOf(request), nil case "TestJsonRequest": - request := &gen.TestJsonRequest{ } + request := &services.TestJsonRequest{ } turbo.BuildStruct(s, reflect.TypeOf(request).Elem(), reflect.ValueOf(request).Elem(), req) return reflect.ValueOf(request), nil diff --git a/test/testservice/shared.thrift b/test/testservice/shared.thrift index 16c6054..0b1f68f 100644 --- a/test/testservice/shared.thrift +++ b/test/testservice/shared.thrift @@ -1,4 +1,4 @@ -namespace go gen +namespace go shared struct CommonValues { 1: i64 transactionId, diff --git a/test/testservice/testservice.thrift b/test/testservice/testservice.thrift index 2aad491..2fdd05d 100644 --- a/test/testservice/testservice.thrift +++ b/test/testservice/testservice.thrift @@ -1,4 +1,4 @@ -namespace go gen +namespace go services include "shared.thrift" struct SayHelloResponse { diff --git a/test/testservice/thriftapi/component/components.go b/test/testservice/thriftapi/component/components.go index 8154ab5..c79413b 100644 --- a/test/testservice/thriftapi/component/components.go +++ b/test/testservice/thriftapi/component/components.go @@ -3,7 +3,7 @@ package component import ( "git.apache.org/thrift.git/lib/go/thrift" "github.com/vaporz/turbo" - t "github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/gen" + t "github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/services" ) func ThriftClient(trans thrift.TTransport, f thrift.TProtocolFactory) map[string]interface{} { diff --git a/test/testservice/thriftservice/impl/minionsserviceimpl.go b/test/testservice/thriftservice/impl/minionsserviceimpl.go index f6e7541..a9ed8ae 100644 --- a/test/testservice/thriftservice/impl/minionsserviceimpl.go +++ b/test/testservice/thriftservice/impl/minionsserviceimpl.go @@ -1,17 +1,16 @@ package impl import ( - "context" - "github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/gen" + "github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/services" ) type MinionsService struct { } // SayHello is an example entry point -func (m MinionsService) Eat(ctx context.Context, food string) (r *gen.EatResponse, err error) { +func (m MinionsService) Eat(food string) (r *services.EatResponse, err error) { if food != "banana" { - return &gen.EatResponse{Message: "Uh..."}, nil + return &services.EatResponse{Message: "Uh..."}, nil } - return &gen.EatResponse{Message: "Yummy!"}, nil + return &services.EatResponse{Message: "Yummy!"}, nil } diff --git a/test/testservice/thriftservice/impl/testserviceimpl.go b/test/testservice/thriftservice/impl/testserviceimpl.go index 6fededf..8341078 100644 --- a/test/testservice/thriftservice/impl/testserviceimpl.go +++ b/test/testservice/thriftservice/impl/testserviceimpl.go @@ -1,18 +1,18 @@ package impl import ( - "context" "errors" "fmt" "git.apache.org/thrift.git/lib/go/thrift" - "github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/gen" + "github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/services" + "github.com/vaporz/turbo/test/testservice/gen/thrift/gen-go/shared" ) // TProcessor returns TProcessor func TProcessor() map[string]thrift.TProcessor { return map[string]thrift.TProcessor{ - "TestService": gen.NewTestServiceProcessor(TestService{}), - "MinionsService": gen.NewMinionsServiceProcessor(MinionsService{}), + "TestService": services.NewTestServiceProcessor(TestService{}), + "MinionsService": services.NewMinionsServiceProcessor(MinionsService{}), } } @@ -21,21 +21,21 @@ type TestService struct { } // SayHello is an example entry point -func (s TestService) SayHello(ctx context.Context, values *gen.CommonValues, yourName string, int64Value int64, boolValue bool, float64Value float64, - uint64Value int64, int32Value int32, int16Value int16, stringList []string, i32List []int32, boolList []bool, doubleList []float64) (r *gen.SayHelloResponse, err error) { +func (s TestService) SayHello(values *shared.CommonValues, yourName string, int64Value int64, boolValue bool, float64Value float64, + uint64Value int64, int32Value int32, int16Value int16, stringList []string, i32List []int32, boolList []bool, doubleList []float64) (r *services.SayHelloResponse, err error) { if boolValue { result := fmt.Sprintf("values.TransactionId=%d, yourName=%s,int64Value=%d, boolValue=%t, float64Value=%f, "+ "uint64Value=%d, int32Value=%d, int16Value=%d, stringList=%v, i32List=%v, boolList=%v, doubleList=%v", values.TransactionId, yourName, int64Value, boolValue, float64Value, uint64Value, int32Value, int16Value, stringList, i32List, boolList, doubleList) - return &gen.SayHelloResponse{Message: "[thrift server]" + result}, nil + return &services.SayHelloResponse{Message: "[thrift server]" + result}, nil } if yourName == "error" { - return &gen.SayHelloResponse{}, errors.New("thrift error") + return &services.SayHelloResponse{}, errors.New("thrift error") } - return &gen.SayHelloResponse{Message: "[thrift server]Hello, " + yourName}, nil + return &services.SayHelloResponse{Message: "[thrift server]Hello, " + yourName}, nil } -func (s TestService) TestJson(ctx context.Context, request *gen.TestJsonRequest) (r *gen.TestJsonResponse, err error) { - return &gen.TestJsonResponse{Message: "[thrift server]json= " + request.String()}, nil +func (s TestService) TestJson(request *services.TestJsonRequest) (r *services.TestJsonResponse, err error) { + return &services.TestJsonResponse{Message: "[thrift server]json= " + request.String()}, nil } diff --git a/thriftclient.go b/thriftclient.go index 27378b2..33cc6eb 100644 --- a/thriftclient.go +++ b/thriftclient.go @@ -28,8 +28,7 @@ func (t *thriftClient) connect(hostPort string) { tSocket, err := thrift.NewTSocket(hostPort) logPanicIf(err) - t.transport, err = thrift.NewTTransportFactory().GetTransport(tSocket) - logPanicIf(err) + t.transport = thrift.NewTTransportFactory().GetTransport(tSocket) err = t.transport.Open() logPanicIf(err)