Package list golang-github-go-kit-kit / d41a209
updated thrift to latest Go library adding support for context Bas van Beek 4 years ago
9 changed file(s) with 1251 addition(s) and 1249 deletion(s). Raw diff Collapse all Expand all
00 package main
11
22 import (
3 "context"
43 "flag"
54 "fmt"
65 "net"
139138 endpoints = addendpoint.New(service, logger, duration, tracer)
140139 httpHandler = addtransport.NewHTTPHandler(endpoints, tracer, logger)
141140 grpcServer = addtransport.NewGRPCServer(endpoints, tracer, logger)
142 thriftServer = addtransport.NewThriftServer(context.Background(), endpoints)
141 thriftServer = addtransport.NewThriftServer(endpoints)
143142 )
144143
145144 // Now we're to the part of the func main where we want to start actually
2121 }
2222
2323 // NewThriftServer makes a set of endpoints available as a Thrift service.
24 func NewThriftServer(ctx context.Context, endpoints addendpoint.Set) addthrift.AddService {
24 func NewThriftServer(endpoints addendpoint.Set) addthrift.AddService {
2525 return &thriftServer{
26 ctx: ctx,
2726 endpoints: endpoints,
2827 }
2928 }
3029
31 func (s *thriftServer) Sum(a int64, b int64) (*addthrift.SumReply, error) {
30 func (s *thriftServer) Sum(ctx context.Context, a int64, b int64) (*addthrift.SumReply, error) {
3231 request := addendpoint.SumRequest{A: int(a), B: int(b)}
33 response, err := s.endpoints.SumEndpoint(s.ctx, request)
32 response, err := s.endpoints.SumEndpoint(ctx, request)
3433 if err != nil {
3534 return nil, err
3635 }
3837 return &addthrift.SumReply{Value: int64(resp.V), Err: err2str(resp.Err)}, nil
3938 }
4039
41 func (s *thriftServer) Concat(a string, b string) (*addthrift.ConcatReply, error) {
40 func (s *thriftServer) Concat(ctx context.Context, a string, b string) (*addthrift.ConcatReply, error) {
4241 request := addendpoint.ConcatRequest{A: a, B: b}
43 response, err := s.endpoints.ConcatEndpoint(s.ctx, request)
42 response, err := s.endpoints.ConcatEndpoint(ctx, request)
4443 if err != nil {
4544 return nil, err
4645 }
9998 func MakeThriftSumEndpoint(client *addthrift.AddServiceClient) endpoint.Endpoint {
10099 return func(ctx context.Context, request interface{}) (interface{}, error) {
101100 req := request.(addendpoint.SumRequest)
102 reply, err := client.Sum(int64(req.A), int64(req.B))
101 reply, err := client.Sum(ctx, int64(req.A), int64(req.B))
103102 if err == addservice.ErrIntOverflow {
104103 return nil, err // special case; see comment on ErrIntOverflow
105104 }
113112 func MakeThriftConcatEndpoint(client *addthrift.AddServiceClient) endpoint.Endpoint {
114113 return func(ctx context.Context, request interface{}) (interface{}, error) {
115114 req := request.(addendpoint.ConcatRequest)
116 reply, err := client.Concat(req.A, req.B)
115 reply, err := client.Concat(ctx, req.A, req.B)
117116 return addendpoint.ConcatResponse{V: reply.Value, Err: err}, nil
118117 }
119118 }
0 // Autogenerated by Thrift Compiler (1.0.0-dev)
1 // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
2
3 package addsvc
4
5 var GoUnusedProtection__ int;
6
0 // Autogenerated by Thrift Compiler (0.9.3)
0 // Autogenerated by Thrift Compiler (1.0.0-dev)
11 // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
22
33 package main
44
55 import (
6 "flag"
7 "fmt"
8 "github.com/apache/thrift/lib/go/thrift"
9 "github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc"
10 "math"
11 "net"
12 "net/url"
13 "os"
14 "strconv"
15 "strings"
6 "context"
7 "flag"
8 "fmt"
9 "math"
10 "net"
11 "net/url"
12 "os"
13 "strconv"
14 "strings"
15 "github.com/apache/thrift/lib/go/thrift"
16 "github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc"
1617 )
1718
19
1820 func Usage() {
19 fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:")
20 flag.PrintDefaults()
21 fmt.Fprintln(os.Stderr, "\nFunctions:")
22 fmt.Fprintln(os.Stderr, " SumReply Sum(i64 a, i64 b)")
23 fmt.Fprintln(os.Stderr, " ConcatReply Concat(string a, string b)")
24 fmt.Fprintln(os.Stderr)
25 os.Exit(0)
21 fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:")
22 flag.PrintDefaults()
23 fmt.Fprintln(os.Stderr, "\nFunctions:")
24 fmt.Fprintln(os.Stderr, " SumReply Sum(i64 a, i64 b)")
25 fmt.Fprintln(os.Stderr, " ConcatReply Concat(string a, string b)")
26 fmt.Fprintln(os.Stderr)
27 os.Exit(0)
2628 }
2729
2830 func main() {
29 flag.Usage = Usage
30 var host string
31 var port int
32 var protocol string
33 var urlString string
34 var framed bool
35 var useHttp bool
36 var parsedUrl url.URL
37 var trans thrift.TTransport
38 _ = strconv.Atoi
39 _ = math.Abs
40 flag.Usage = Usage
41 flag.StringVar(&host, "h", "localhost", "Specify host and port")
42 flag.IntVar(&port, "p", 9090, "Specify port")
43 flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
44 flag.StringVar(&urlString, "u", "", "Specify the url")
45 flag.BoolVar(&framed, "framed", false, "Use framed transport")
46 flag.BoolVar(&useHttp, "http", false, "Use http")
47 flag.Parse()
48
49 if len(urlString) > 0 {
50 parsedUrl, err := url.Parse(urlString)
51 if err != nil {
52 fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
53 flag.Usage()
54 }
55 host = parsedUrl.Host
56 useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
57 } else if useHttp {
58 _, err := url.Parse(fmt.Sprint("http://", host, ":", port))
59 if err != nil {
60 fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
61 flag.Usage()
62 }
63 }
64
65 cmd := flag.Arg(0)
66 var err error
67 if useHttp {
68 trans, err = thrift.NewTHttpClient(parsedUrl.String())
69 } else {
70 portStr := fmt.Sprint(port)
71 if strings.Contains(host, ":") {
72 host, portStr, err = net.SplitHostPort(host)
73 if err != nil {
74 fmt.Fprintln(os.Stderr, "error with host:", err)
75 os.Exit(1)
76 }
77 }
78 trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
79 if err != nil {
80 fmt.Fprintln(os.Stderr, "error resolving address:", err)
81 os.Exit(1)
82 }
83 if framed {
84 trans = thrift.NewTFramedTransport(trans)
85 }
86 }
87 if err != nil {
88 fmt.Fprintln(os.Stderr, "Error creating transport", err)
89 os.Exit(1)
90 }
91 defer trans.Close()
92 var protocolFactory thrift.TProtocolFactory
93 switch protocol {
94 case "compact":
95 protocolFactory = thrift.NewTCompactProtocolFactory()
96 break
97 case "simplejson":
98 protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
99 break
100 case "json":
101 protocolFactory = thrift.NewTJSONProtocolFactory()
102 break
103 case "binary", "":
104 protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
105 break
106 default:
107 fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
108 Usage()
109 os.Exit(1)
110 }
111 client := addsvc.NewAddServiceClientFactory(trans, protocolFactory)
112 if err := trans.Open(); err != nil {
113 fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
114 os.Exit(1)
115 }
116
117 switch cmd {
118 case "Sum":
119 if flag.NArg()-1 != 2 {
120 fmt.Fprintln(os.Stderr, "Sum requires 2 args")
121 flag.Usage()
122 }
123 argvalue0, err6 := (strconv.ParseInt(flag.Arg(1), 10, 64))
124 if err6 != nil {
125 Usage()
126 return
127 }
128 value0 := argvalue0
129 argvalue1, err7 := (strconv.ParseInt(flag.Arg(2), 10, 64))
130 if err7 != nil {
131 Usage()
132 return
133 }
134 value1 := argvalue1
135 fmt.Print(client.Sum(value0, value1))
136 fmt.Print("\n")
137 break
138 case "Concat":
139 if flag.NArg()-1 != 2 {
140 fmt.Fprintln(os.Stderr, "Concat requires 2 args")
141 flag.Usage()
142 }
143 argvalue0 := flag.Arg(1)
144 value0 := argvalue0
145 argvalue1 := flag.Arg(2)
146 value1 := argvalue1
147 fmt.Print(client.Concat(value0, value1))
148 fmt.Print("\n")
149 break
150 case "":
151 Usage()
152 break
153 default:
154 fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
155 }
31 flag.Usage = Usage
32 var host string
33 var port int
34 var protocol string
35 var urlString string
36 var framed bool
37 var useHttp bool
38 var parsedUrl url.URL
39 var trans thrift.TTransport
40 _ = strconv.Atoi
41 _ = math.Abs
42 flag.Usage = Usage
43 flag.StringVar(&host, "h", "localhost", "Specify host and port")
44 flag.IntVar(&port, "p", 9090, "Specify port")
45 flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
46 flag.StringVar(&urlString, "u", "", "Specify the url")
47 flag.BoolVar(&framed, "framed", false, "Use framed transport")
48 flag.BoolVar(&useHttp, "http", false, "Use http")
49 flag.Parse()
50
51 if len(urlString) > 0 {
52 parsedUrl, err := url.Parse(urlString)
53 if err != nil {
54 fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
55 flag.Usage()
56 }
57 host = parsedUrl.Host
58 useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
59 } else if useHttp {
60 _, err := url.Parse(fmt.Sprint("http://", host, ":", port))
61 if err != nil {
62 fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
63 flag.Usage()
64 }
65 }
66
67 cmd := flag.Arg(0)
68 var err error
69 if useHttp {
70 trans, err = thrift.NewTHttpClient(parsedUrl.String())
71 } else {
72 portStr := fmt.Sprint(port)
73 if strings.Contains(host, ":") {
74 host, portStr, err = net.SplitHostPort(host)
75 if err != nil {
76 fmt.Fprintln(os.Stderr, "error with host:", err)
77 os.Exit(1)
78 }
79 }
80 trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
81 if err != nil {
82 fmt.Fprintln(os.Stderr, "error resolving address:", err)
83 os.Exit(1)
84 }
85 if framed {
86 trans = thrift.NewTFramedTransport(trans)
87 }
88 }
89 if err != nil {
90 fmt.Fprintln(os.Stderr, "Error creating transport", err)
91 os.Exit(1)
92 }
93 defer trans.Close()
94 var protocolFactory thrift.TProtocolFactory
95 switch protocol {
96 case "compact":
97 protocolFactory = thrift.NewTCompactProtocolFactory()
98 break
99 case "simplejson":
100 protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
101 break
102 case "json":
103 protocolFactory = thrift.NewTJSONProtocolFactory()
104 break
105 case "binary", "":
106 protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
107 break
108 default:
109 fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
110 Usage()
111 os.Exit(1)
112 }
113 client := addsvc.NewAddServiceClientFactory(trans, protocolFactory)
114 if err := trans.Open(); err != nil {
115 fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
116 os.Exit(1)
117 }
118
119 switch cmd {
120 case "Sum":
121 if flag.NArg() - 1 != 2 {
122 fmt.Fprintln(os.Stderr, "Sum requires 2 args")
123 flag.Usage()
124 }
125 argvalue0, err6 := (strconv.ParseInt(flag.Arg(1), 10, 64))
126 if err6 != nil {
127 Usage()
128 return
129 }
130 value0 := argvalue0
131 argvalue1, err7 := (strconv.ParseInt(flag.Arg(2), 10, 64))
132 if err7 != nil {
133 Usage()
134 return
135 }
136 value1 := argvalue1
137 fmt.Print(client.Sum(context.Background(), value0, value1))
138 fmt.Print("\n")
139 break
140 case "Concat":
141 if flag.NArg() - 1 != 2 {
142 fmt.Fprintln(os.Stderr, "Concat requires 2 args")
143 flag.Usage()
144 }
145 argvalue0 := flag.Arg(1)
146 value0 := argvalue0
147 argvalue1 := flag.Arg(2)
148 value1 := argvalue1
149 fmt.Print(client.Concat(context.Background(), value0, value1))
150 fmt.Print("\n")
151 break
152 case "":
153 Usage()
154 break
155 default:
156 fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
157 }
156158 }
+0
-807
examples/addsvc/thrift/gen-go/addsvc/addservice.go less more
0 // Autogenerated by Thrift Compiler (0.9.3)
1 // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
2
3 package addsvc
4
5 import (
6 "bytes"
7 "fmt"
8 "github.com/apache/thrift/lib/go/thrift"
9 )
10
11 // (needed to ensure safety because of naive import list construction.)
12 var _ = thrift.ZERO
13 var _ = fmt.Printf
14 var _ = bytes.Equal
15
16 type AddService interface {
17 // Parameters:
18 // - A
19 // - B
20 Sum(a int64, b int64) (r *SumReply, err error)
21 // Parameters:
22 // - A
23 // - B
24 Concat(a string, b string) (r *ConcatReply, err error)
25 }
26
27 type AddServiceClient struct {
28 Transport thrift.TTransport
29 ProtocolFactory thrift.TProtocolFactory
30 InputProtocol thrift.TProtocol
31 OutputProtocol thrift.TProtocol
32 SeqId int32
33 }
34
35 func NewAddServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *AddServiceClient {
36 return &AddServiceClient{Transport: t,
37 ProtocolFactory: f,
38 InputProtocol: f.GetProtocol(t),
39 OutputProtocol: f.GetProtocol(t),
40 SeqId: 0,
41 }
42 }
43
44 func NewAddServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *AddServiceClient {
45 return &AddServiceClient{Transport: t,
46 ProtocolFactory: nil,
47 InputProtocol: iprot,
48 OutputProtocol: oprot,
49 SeqId: 0,
50 }
51 }
52
53 // Parameters:
54 // - A
55 // - B
56 func (p *AddServiceClient) Sum(a int64, b int64) (r *SumReply, err error) {
57 if err = p.sendSum(a, b); err != nil {
58 return
59 }
60 return p.recvSum()
61 }
62
63 func (p *AddServiceClient) sendSum(a int64, b int64) (err error) {
64 oprot := p.OutputProtocol
65 if oprot == nil {
66 oprot = p.ProtocolFactory.GetProtocol(p.Transport)
67 p.OutputProtocol = oprot
68 }
69 p.SeqId++
70 if err = oprot.WriteMessageBegin("Sum", thrift.CALL, p.SeqId); err != nil {
71 return
72 }
73 args := AddServiceSumArgs{
74 A: a,
75 B: b,
76 }
77 if err = args.Write(oprot); err != nil {
78 return
79 }
80 if err = oprot.WriteMessageEnd(); err != nil {
81 return
82 }
83 return oprot.Flush()
84 }
85
86 func (p *AddServiceClient) recvSum() (value *SumReply, err error) {
87 iprot := p.InputProtocol
88 if iprot == nil {
89 iprot = p.ProtocolFactory.GetProtocol(p.Transport)
90 p.InputProtocol = iprot
91 }
92 method, mTypeId, seqId, err := iprot.ReadMessageBegin()
93 if err != nil {
94 return
95 }
96 if method != "Sum" {
97 err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "Sum failed: wrong method name")
98 return
99 }
100 if p.SeqId != seqId {
101 err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "Sum failed: out of sequence response")
102 return
103 }
104 if mTypeId == thrift.EXCEPTION {
105 error0 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
106 var error1 error
107 error1, err = error0.Read(iprot)
108 if err != nil {
109 return
110 }
111 if err = iprot.ReadMessageEnd(); err != nil {
112 return
113 }
114 err = error1
115 return
116 }
117 if mTypeId != thrift.REPLY {
118 err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "Sum failed: invalid message type")
119 return
120 }
121 result := AddServiceSumResult{}
122 if err = result.Read(iprot); err != nil {
123 return
124 }
125 if err = iprot.ReadMessageEnd(); err != nil {
126 return
127 }
128 value = result.GetSuccess()
129 return
130 }
131
132 // Parameters:
133 // - A
134 // - B
135 func (p *AddServiceClient) Concat(a string, b string) (r *ConcatReply, err error) {
136 if err = p.sendConcat(a, b); err != nil {
137 return
138 }
139 return p.recvConcat()
140 }
141
142 func (p *AddServiceClient) sendConcat(a string, b string) (err error) {
143 oprot := p.OutputProtocol
144 if oprot == nil {
145 oprot = p.ProtocolFactory.GetProtocol(p.Transport)
146 p.OutputProtocol = oprot
147 }
148 p.SeqId++
149 if err = oprot.WriteMessageBegin("Concat", thrift.CALL, p.SeqId); err != nil {
150 return
151 }
152 args := AddServiceConcatArgs{
153 A: a,
154 B: b,
155 }
156 if err = args.Write(oprot); err != nil {
157 return
158 }
159 if err = oprot.WriteMessageEnd(); err != nil {
160 return
161 }
162 return oprot.Flush()
163 }
164
165 func (p *AddServiceClient) recvConcat() (value *ConcatReply, err error) {
166 iprot := p.InputProtocol
167 if iprot == nil {
168 iprot = p.ProtocolFactory.GetProtocol(p.Transport)
169 p.InputProtocol = iprot
170 }
171 method, mTypeId, seqId, err := iprot.ReadMessageBegin()
172 if err != nil {
173 return
174 }
175 if method != "Concat" {
176 err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "Concat failed: wrong method name")
177 return
178 }
179 if p.SeqId != seqId {
180 err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "Concat failed: out of sequence response")
181 return
182 }
183 if mTypeId == thrift.EXCEPTION {
184 error2 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
185 var error3 error
186 error3, err = error2.Read(iprot)
187 if err != nil {
188 return
189 }
190 if err = iprot.ReadMessageEnd(); err != nil {
191 return
192 }
193 err = error3
194 return
195 }
196 if mTypeId != thrift.REPLY {
197 err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "Concat failed: invalid message type")
198 return
199 }
200 result := AddServiceConcatResult{}
201 if err = result.Read(iprot); err != nil {
202 return
203 }
204 if err = iprot.ReadMessageEnd(); err != nil {
205 return
206 }
207 value = result.GetSuccess()
208 return
209 }
210
211 type AddServiceProcessor struct {
212 processorMap map[string]thrift.TProcessorFunction
213 handler AddService
214 }
215
216 func (p *AddServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) {
217 p.processorMap[key] = processor
218 }
219
220 func (p *AddServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) {
221 processor, ok = p.processorMap[key]
222 return processor, ok
223 }
224
225 func (p *AddServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction {
226 return p.processorMap
227 }
228
229 func NewAddServiceProcessor(handler AddService) *AddServiceProcessor {
230
231 self4 := &AddServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)}
232 self4.processorMap["Sum"] = &addServiceProcessorSum{handler: handler}
233 self4.processorMap["Concat"] = &addServiceProcessorConcat{handler: handler}
234 return self4
235 }
236
237 func (p *AddServiceProcessor) Process(iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
238 name, _, seqId, err := iprot.ReadMessageBegin()
239 if err != nil {
240 return false, err
241 }
242 if processor, ok := p.GetProcessorFunction(name); ok {
243 return processor.Process(seqId, iprot, oprot)
244 }
245 iprot.Skip(thrift.STRUCT)
246 iprot.ReadMessageEnd()
247 x5 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name)
248 oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId)
249 x5.Write(oprot)
250 oprot.WriteMessageEnd()
251 oprot.Flush()
252 return false, x5
253
254 }
255
256 type addServiceProcessorSum struct {
257 handler AddService
258 }
259
260 func (p *addServiceProcessorSum) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
261 args := AddServiceSumArgs{}
262 if err = args.Read(iprot); err != nil {
263 iprot.ReadMessageEnd()
264 x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
265 oprot.WriteMessageBegin("Sum", thrift.EXCEPTION, seqId)
266 x.Write(oprot)
267 oprot.WriteMessageEnd()
268 oprot.Flush()
269 return false, err
270 }
271
272 iprot.ReadMessageEnd()
273 result := AddServiceSumResult{}
274 var retval *SumReply
275 var err2 error
276 if retval, err2 = p.handler.Sum(args.A, args.B); err2 != nil {
277 x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Sum: "+err2.Error())
278 oprot.WriteMessageBegin("Sum", thrift.EXCEPTION, seqId)
279 x.Write(oprot)
280 oprot.WriteMessageEnd()
281 oprot.Flush()
282 return true, err2
283 } else {
284 result.Success = retval
285 }
286 if err2 = oprot.WriteMessageBegin("Sum", thrift.REPLY, seqId); err2 != nil {
287 err = err2
288 }
289 if err2 = result.Write(oprot); err == nil && err2 != nil {
290 err = err2
291 }
292 if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
293 err = err2
294 }
295 if err2 = oprot.Flush(); err == nil && err2 != nil {
296 err = err2
297 }
298 if err != nil {
299 return
300 }
301 return true, err
302 }
303
304 type addServiceProcessorConcat struct {
305 handler AddService
306 }
307
308 func (p *addServiceProcessorConcat) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
309 args := AddServiceConcatArgs{}
310 if err = args.Read(iprot); err != nil {
311 iprot.ReadMessageEnd()
312 x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
313 oprot.WriteMessageBegin("Concat", thrift.EXCEPTION, seqId)
314 x.Write(oprot)
315 oprot.WriteMessageEnd()
316 oprot.Flush()
317 return false, err
318 }
319
320 iprot.ReadMessageEnd()
321 result := AddServiceConcatResult{}
322 var retval *ConcatReply
323 var err2 error
324 if retval, err2 = p.handler.Concat(args.A, args.B); err2 != nil {
325 x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Concat: "+err2.Error())
326 oprot.WriteMessageBegin("Concat", thrift.EXCEPTION, seqId)
327 x.Write(oprot)
328 oprot.WriteMessageEnd()
329 oprot.Flush()
330 return true, err2
331 } else {
332 result.Success = retval
333 }
334 if err2 = oprot.WriteMessageBegin("Concat", thrift.REPLY, seqId); err2 != nil {
335 err = err2
336 }
337 if err2 = result.Write(oprot); err == nil && err2 != nil {
338 err = err2
339 }
340 if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
341 err = err2
342 }
343 if err2 = oprot.Flush(); err == nil && err2 != nil {
344 err = err2
345 }
346 if err != nil {
347 return
348 }
349 return true, err
350 }
351
352 // HELPER FUNCTIONS AND STRUCTURES
353
354 // Attributes:
355 // - A
356 // - B
357 type AddServiceSumArgs struct {
358 A int64 `thrift:"a,1" json:"a"`
359 B int64 `thrift:"b,2" json:"b"`
360 }
361
362 func NewAddServiceSumArgs() *AddServiceSumArgs {
363 return &AddServiceSumArgs{}
364 }
365
366 func (p *AddServiceSumArgs) GetA() int64 {
367 return p.A
368 }
369
370 func (p *AddServiceSumArgs) GetB() int64 {
371 return p.B
372 }
373 func (p *AddServiceSumArgs) Read(iprot thrift.TProtocol) error {
374 if _, err := iprot.ReadStructBegin(); err != nil {
375 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
376 }
377
378 for {
379 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
380 if err != nil {
381 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
382 }
383 if fieldTypeId == thrift.STOP {
384 break
385 }
386 switch fieldId {
387 case 1:
388 if err := p.readField1(iprot); err != nil {
389 return err
390 }
391 case 2:
392 if err := p.readField2(iprot); err != nil {
393 return err
394 }
395 default:
396 if err := iprot.Skip(fieldTypeId); err != nil {
397 return err
398 }
399 }
400 if err := iprot.ReadFieldEnd(); err != nil {
401 return err
402 }
403 }
404 if err := iprot.ReadStructEnd(); err != nil {
405 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
406 }
407 return nil
408 }
409
410 func (p *AddServiceSumArgs) readField1(iprot thrift.TProtocol) error {
411 if v, err := iprot.ReadI64(); err != nil {
412 return thrift.PrependError("error reading field 1: ", err)
413 } else {
414 p.A = v
415 }
416 return nil
417 }
418
419 func (p *AddServiceSumArgs) readField2(iprot thrift.TProtocol) error {
420 if v, err := iprot.ReadI64(); err != nil {
421 return thrift.PrependError("error reading field 2: ", err)
422 } else {
423 p.B = v
424 }
425 return nil
426 }
427
428 func (p *AddServiceSumArgs) Write(oprot thrift.TProtocol) error {
429 if err := oprot.WriteStructBegin("Sum_args"); err != nil {
430 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
431 }
432 if err := p.writeField1(oprot); err != nil {
433 return err
434 }
435 if err := p.writeField2(oprot); err != nil {
436 return err
437 }
438 if err := oprot.WriteFieldStop(); err != nil {
439 return thrift.PrependError("write field stop error: ", err)
440 }
441 if err := oprot.WriteStructEnd(); err != nil {
442 return thrift.PrependError("write struct stop error: ", err)
443 }
444 return nil
445 }
446
447 func (p *AddServiceSumArgs) writeField1(oprot thrift.TProtocol) (err error) {
448 if err := oprot.WriteFieldBegin("a", thrift.I64, 1); err != nil {
449 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:a: ", p), err)
450 }
451 if err := oprot.WriteI64(int64(p.A)); err != nil {
452 return thrift.PrependError(fmt.Sprintf("%T.a (1) field write error: ", p), err)
453 }
454 if err := oprot.WriteFieldEnd(); err != nil {
455 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:a: ", p), err)
456 }
457 return err
458 }
459
460 func (p *AddServiceSumArgs) writeField2(oprot thrift.TProtocol) (err error) {
461 if err := oprot.WriteFieldBegin("b", thrift.I64, 2); err != nil {
462 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:b: ", p), err)
463 }
464 if err := oprot.WriteI64(int64(p.B)); err != nil {
465 return thrift.PrependError(fmt.Sprintf("%T.b (2) field write error: ", p), err)
466 }
467 if err := oprot.WriteFieldEnd(); err != nil {
468 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:b: ", p), err)
469 }
470 return err
471 }
472
473 func (p *AddServiceSumArgs) String() string {
474 if p == nil {
475 return "<nil>"
476 }
477 return fmt.Sprintf("AddServiceSumArgs(%+v)", *p)
478 }
479
480 // Attributes:
481 // - Success
482 type AddServiceSumResult struct {
483 Success *SumReply `thrift:"success,0" json:"success,omitempty"`
484 }
485
486 func NewAddServiceSumResult() *AddServiceSumResult {
487 return &AddServiceSumResult{}
488 }
489
490 var AddServiceSumResult_Success_DEFAULT *SumReply
491
492 func (p *AddServiceSumResult) GetSuccess() *SumReply {
493 if !p.IsSetSuccess() {
494 return AddServiceSumResult_Success_DEFAULT
495 }
496 return p.Success
497 }
498 func (p *AddServiceSumResult) IsSetSuccess() bool {
499 return p.Success != nil
500 }
501
502 func (p *AddServiceSumResult) Read(iprot thrift.TProtocol) error {
503 if _, err := iprot.ReadStructBegin(); err != nil {
504 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
505 }
506
507 for {
508 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
509 if err != nil {
510 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
511 }
512 if fieldTypeId == thrift.STOP {
513 break
514 }
515 switch fieldId {
516 case 0:
517 if err := p.readField0(iprot); err != nil {
518 return err
519 }
520 default:
521 if err := iprot.Skip(fieldTypeId); err != nil {
522 return err
523 }
524 }
525 if err := iprot.ReadFieldEnd(); err != nil {
526 return err
527 }
528 }
529 if err := iprot.ReadStructEnd(); err != nil {
530 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
531 }
532 return nil
533 }
534
535 func (p *AddServiceSumResult) readField0(iprot thrift.TProtocol) error {
536 p.Success = &SumReply{}
537 if err := p.Success.Read(iprot); err != nil {
538 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err)
539 }
540 return nil
541 }
542
543 func (p *AddServiceSumResult) Write(oprot thrift.TProtocol) error {
544 if err := oprot.WriteStructBegin("Sum_result"); err != nil {
545 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
546 }
547 if err := p.writeField0(oprot); err != nil {
548 return err
549 }
550 if err := oprot.WriteFieldStop(); err != nil {
551 return thrift.PrependError("write field stop error: ", err)
552 }
553 if err := oprot.WriteStructEnd(); err != nil {
554 return thrift.PrependError("write struct stop error: ", err)
555 }
556 return nil
557 }
558
559 func (p *AddServiceSumResult) writeField0(oprot thrift.TProtocol) (err error) {
560 if p.IsSetSuccess() {
561 if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil {
562 return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err)
563 }
564 if err := p.Success.Write(oprot); err != nil {
565 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err)
566 }
567 if err := oprot.WriteFieldEnd(); err != nil {
568 return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err)
569 }
570 }
571 return err
572 }
573
574 func (p *AddServiceSumResult) String() string {
575 if p == nil {
576 return "<nil>"
577 }
578 return fmt.Sprintf("AddServiceSumResult(%+v)", *p)
579 }
580
581 // Attributes:
582 // - A
583 // - B
584 type AddServiceConcatArgs struct {
585 A string `thrift:"a,1" json:"a"`
586 B string `thrift:"b,2" json:"b"`
587 }
588
589 func NewAddServiceConcatArgs() *AddServiceConcatArgs {
590 return &AddServiceConcatArgs{}
591 }
592
593 func (p *AddServiceConcatArgs) GetA() string {
594 return p.A
595 }
596
597 func (p *AddServiceConcatArgs) GetB() string {
598 return p.B
599 }
600 func (p *AddServiceConcatArgs) Read(iprot thrift.TProtocol) error {
601 if _, err := iprot.ReadStructBegin(); err != nil {
602 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
603 }
604
605 for {
606 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
607 if err != nil {
608 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
609 }
610 if fieldTypeId == thrift.STOP {
611 break
612 }
613 switch fieldId {
614 case 1:
615 if err := p.readField1(iprot); err != nil {
616 return err
617 }
618 case 2:
619 if err := p.readField2(iprot); err != nil {
620 return err
621 }
622 default:
623 if err := iprot.Skip(fieldTypeId); err != nil {
624 return err
625 }
626 }
627 if err := iprot.ReadFieldEnd(); err != nil {
628 return err
629 }
630 }
631 if err := iprot.ReadStructEnd(); err != nil {
632 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
633 }
634 return nil
635 }
636
637 func (p *AddServiceConcatArgs) readField1(iprot thrift.TProtocol) error {
638 if v, err := iprot.ReadString(); err != nil {
639 return thrift.PrependError("error reading field 1: ", err)
640 } else {
641 p.A = v
642 }
643 return nil
644 }
645
646 func (p *AddServiceConcatArgs) readField2(iprot thrift.TProtocol) error {
647 if v, err := iprot.ReadString(); err != nil {
648 return thrift.PrependError("error reading field 2: ", err)
649 } else {
650 p.B = v
651 }
652 return nil
653 }
654
655 func (p *AddServiceConcatArgs) Write(oprot thrift.TProtocol) error {
656 if err := oprot.WriteStructBegin("Concat_args"); err != nil {
657 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
658 }
659 if err := p.writeField1(oprot); err != nil {
660 return err
661 }
662 if err := p.writeField2(oprot); err != nil {
663 return err
664 }
665 if err := oprot.WriteFieldStop(); err != nil {
666 return thrift.PrependError("write field stop error: ", err)
667 }
668 if err := oprot.WriteStructEnd(); err != nil {
669 return thrift.PrependError("write struct stop error: ", err)
670 }
671 return nil
672 }
673
674 func (p *AddServiceConcatArgs) writeField1(oprot thrift.TProtocol) (err error) {
675 if err := oprot.WriteFieldBegin("a", thrift.STRING, 1); err != nil {
676 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:a: ", p), err)
677 }
678 if err := oprot.WriteString(string(p.A)); err != nil {
679 return thrift.PrependError(fmt.Sprintf("%T.a (1) field write error: ", p), err)
680 }
681 if err := oprot.WriteFieldEnd(); err != nil {
682 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:a: ", p), err)
683 }
684 return err
685 }
686
687 func (p *AddServiceConcatArgs) writeField2(oprot thrift.TProtocol) (err error) {
688 if err := oprot.WriteFieldBegin("b", thrift.STRING, 2); err != nil {
689 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:b: ", p), err)
690 }
691 if err := oprot.WriteString(string(p.B)); err != nil {
692 return thrift.PrependError(fmt.Sprintf("%T.b (2) field write error: ", p), err)
693 }
694 if err := oprot.WriteFieldEnd(); err != nil {
695 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:b: ", p), err)
696 }
697 return err
698 }
699
700 func (p *AddServiceConcatArgs) String() string {
701 if p == nil {
702 return "<nil>"
703 }
704 return fmt.Sprintf("AddServiceConcatArgs(%+v)", *p)
705 }
706
707 // Attributes:
708 // - Success
709 type AddServiceConcatResult struct {
710 Success *ConcatReply `thrift:"success,0" json:"success,omitempty"`
711 }
712
713 func NewAddServiceConcatResult() *AddServiceConcatResult {
714 return &AddServiceConcatResult{}
715 }
716
717 var AddServiceConcatResult_Success_DEFAULT *ConcatReply
718
719 func (p *AddServiceConcatResult) GetSuccess() *ConcatReply {
720 if !p.IsSetSuccess() {
721 return AddServiceConcatResult_Success_DEFAULT
722 }
723 return p.Success
724 }
725 func (p *AddServiceConcatResult) IsSetSuccess() bool {
726 return p.Success != nil
727 }
728
729 func (p *AddServiceConcatResult) Read(iprot thrift.TProtocol) error {
730 if _, err := iprot.ReadStructBegin(); err != nil {
731 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
732 }
733
734 for {
735 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
736 if err != nil {
737 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
738 }
739 if fieldTypeId == thrift.STOP {
740 break
741 }
742 switch fieldId {
743 case 0:
744 if err := p.readField0(iprot); err != nil {
745 return err
746 }
747 default:
748 if err := iprot.Skip(fieldTypeId); err != nil {
749 return err
750 }
751 }
752 if err := iprot.ReadFieldEnd(); err != nil {
753 return err
754 }
755 }
756 if err := iprot.ReadStructEnd(); err != nil {
757 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
758 }
759 return nil
760 }
761
762 func (p *AddServiceConcatResult) readField0(iprot thrift.TProtocol) error {
763 p.Success = &ConcatReply{}
764 if err := p.Success.Read(iprot); err != nil {
765 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err)
766 }
767 return nil
768 }
769
770 func (p *AddServiceConcatResult) Write(oprot thrift.TProtocol) error {
771 if err := oprot.WriteStructBegin("Concat_result"); err != nil {
772 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
773 }
774 if err := p.writeField0(oprot); err != nil {
775 return err
776 }
777 if err := oprot.WriteFieldStop(); err != nil {
778 return thrift.PrependError("write field stop error: ", err)
779 }
780 if err := oprot.WriteStructEnd(); err != nil {
781 return thrift.PrependError("write struct stop error: ", err)
782 }
783 return nil
784 }
785
786 func (p *AddServiceConcatResult) writeField0(oprot thrift.TProtocol) (err error) {
787 if p.IsSetSuccess() {
788 if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil {
789 return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err)
790 }
791 if err := p.Success.Write(oprot); err != nil {
792 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err)
793 }
794 if err := oprot.WriteFieldEnd(); err != nil {
795 return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err)
796 }
797 }
798 return err
799 }
800
801 func (p *AddServiceConcatResult) String() string {
802 if p == nil {
803 return "<nil>"
804 }
805 return fmt.Sprintf("AddServiceConcatResult(%+v)", *p)
806 }
0 // Autogenerated by Thrift Compiler (1.0.0-dev)
1 // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
2
3 package addsvc
4
5 import (
6 "bytes"
7 "reflect"
8 "context"
9 "fmt"
10 "github.com/apache/thrift/lib/go/thrift"
11 )
12
13 // (needed to ensure safety because of naive import list construction.)
14 var _ = thrift.ZERO
15 var _ = fmt.Printf
16 var _ = context.Background
17 var _ = reflect.DeepEqual
18 var _ = bytes.Equal
19
20
21 func init() {
22 }
23
0 // Autogenerated by Thrift Compiler (1.0.0-dev)
1 // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
2
3 package addsvc
4
5 import (
6 "bytes"
7 "reflect"
8 "context"
9 "fmt"
10 "github.com/apache/thrift/lib/go/thrift"
11 )
12
13 // (needed to ensure safety because of naive import list construction.)
14 var _ = thrift.ZERO
15 var _ = fmt.Printf
16 var _ = context.Background
17 var _ = reflect.DeepEqual
18 var _ = bytes.Equal
19
20 // Attributes:
21 // - Value
22 // - Err
23 type SumReply struct {
24 Value int64 `thrift:"value,1" db:"value" json:"value"`
25 Err string `thrift:"err,2" db:"err" json:"err"`
26 }
27
28 func NewSumReply() *SumReply {
29 return &SumReply{}
30 }
31
32
33 func (p *SumReply) GetValue() int64 {
34 return p.Value
35 }
36
37 func (p *SumReply) GetErr() string {
38 return p.Err
39 }
40 func (p *SumReply) Read(iprot thrift.TProtocol) error {
41 if _, err := iprot.ReadStructBegin(); err != nil {
42 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
43 }
44
45
46 for {
47 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
48 if err != nil {
49 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
50 }
51 if fieldTypeId == thrift.STOP { break; }
52 switch fieldId {
53 case 1:
54 if fieldTypeId == thrift.I64 {
55 if err := p.ReadField1(iprot); err != nil {
56 return err
57 }
58 } else {
59 if err := iprot.Skip(fieldTypeId); err != nil {
60 return err
61 }
62 }
63 case 2:
64 if fieldTypeId == thrift.STRING {
65 if err := p.ReadField2(iprot); err != nil {
66 return err
67 }
68 } else {
69 if err := iprot.Skip(fieldTypeId); err != nil {
70 return err
71 }
72 }
73 default:
74 if err := iprot.Skip(fieldTypeId); err != nil {
75 return err
76 }
77 }
78 if err := iprot.ReadFieldEnd(); err != nil {
79 return err
80 }
81 }
82 if err := iprot.ReadStructEnd(); err != nil {
83 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
84 }
85 return nil
86 }
87
88 func (p *SumReply) ReadField1(iprot thrift.TProtocol) error {
89 if v, err := iprot.ReadI64(); err != nil {
90 return thrift.PrependError("error reading field 1: ", err)
91 } else {
92 p.Value = v
93 }
94 return nil
95 }
96
97 func (p *SumReply) ReadField2(iprot thrift.TProtocol) error {
98 if v, err := iprot.ReadString(); err != nil {
99 return thrift.PrependError("error reading field 2: ", err)
100 } else {
101 p.Err = v
102 }
103 return nil
104 }
105
106 func (p *SumReply) Write(oprot thrift.TProtocol) error {
107 if err := oprot.WriteStructBegin("SumReply"); err != nil {
108 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
109 if p != nil {
110 if err := p.writeField1(oprot); err != nil { return err }
111 if err := p.writeField2(oprot); err != nil { return err }
112 }
113 if err := oprot.WriteFieldStop(); err != nil {
114 return thrift.PrependError("write field stop error: ", err) }
115 if err := oprot.WriteStructEnd(); err != nil {
116 return thrift.PrependError("write struct stop error: ", err) }
117 return nil
118 }
119
120 func (p *SumReply) writeField1(oprot thrift.TProtocol) (err error) {
121 if err := oprot.WriteFieldBegin("value", thrift.I64, 1); err != nil {
122 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) }
123 if err := oprot.WriteI64(int64(p.Value)); err != nil {
124 return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) }
125 if err := oprot.WriteFieldEnd(); err != nil {
126 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) }
127 return err
128 }
129
130 func (p *SumReply) writeField2(oprot thrift.TProtocol) (err error) {
131 if err := oprot.WriteFieldBegin("err", thrift.STRING, 2); err != nil {
132 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:err: ", p), err) }
133 if err := oprot.WriteString(string(p.Err)); err != nil {
134 return thrift.PrependError(fmt.Sprintf("%T.err (2) field write error: ", p), err) }
135 if err := oprot.WriteFieldEnd(); err != nil {
136 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:err: ", p), err) }
137 return err
138 }
139
140 func (p *SumReply) String() string {
141 if p == nil {
142 return "<nil>"
143 }
144 return fmt.Sprintf("SumReply(%+v)", *p)
145 }
146
147 // Attributes:
148 // - Value
149 // - Err
150 type ConcatReply struct {
151 Value string `thrift:"value,1" db:"value" json:"value"`
152 Err string `thrift:"err,2" db:"err" json:"err"`
153 }
154
155 func NewConcatReply() *ConcatReply {
156 return &ConcatReply{}
157 }
158
159
160 func (p *ConcatReply) GetValue() string {
161 return p.Value
162 }
163
164 func (p *ConcatReply) GetErr() string {
165 return p.Err
166 }
167 func (p *ConcatReply) Read(iprot thrift.TProtocol) error {
168 if _, err := iprot.ReadStructBegin(); err != nil {
169 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
170 }
171
172
173 for {
174 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
175 if err != nil {
176 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
177 }
178 if fieldTypeId == thrift.STOP { break; }
179 switch fieldId {
180 case 1:
181 if fieldTypeId == thrift.STRING {
182 if err := p.ReadField1(iprot); err != nil {
183 return err
184 }
185 } else {
186 if err := iprot.Skip(fieldTypeId); err != nil {
187 return err
188 }
189 }
190 case 2:
191 if fieldTypeId == thrift.STRING {
192 if err := p.ReadField2(iprot); err != nil {
193 return err
194 }
195 } else {
196 if err := iprot.Skip(fieldTypeId); err != nil {
197 return err
198 }
199 }
200 default:
201 if err := iprot.Skip(fieldTypeId); err != nil {
202 return err
203 }
204 }
205 if err := iprot.ReadFieldEnd(); err != nil {
206 return err
207 }
208 }
209 if err := iprot.ReadStructEnd(); err != nil {
210 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
211 }
212 return nil
213 }
214
215 func (p *ConcatReply) ReadField1(iprot thrift.TProtocol) error {
216 if v, err := iprot.ReadString(); err != nil {
217 return thrift.PrependError("error reading field 1: ", err)
218 } else {
219 p.Value = v
220 }
221 return nil
222 }
223
224 func (p *ConcatReply) ReadField2(iprot thrift.TProtocol) error {
225 if v, err := iprot.ReadString(); err != nil {
226 return thrift.PrependError("error reading field 2: ", err)
227 } else {
228 p.Err = v
229 }
230 return nil
231 }
232
233 func (p *ConcatReply) Write(oprot thrift.TProtocol) error {
234 if err := oprot.WriteStructBegin("ConcatReply"); err != nil {
235 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
236 if p != nil {
237 if err := p.writeField1(oprot); err != nil { return err }
238 if err := p.writeField2(oprot); err != nil { return err }
239 }
240 if err := oprot.WriteFieldStop(); err != nil {
241 return thrift.PrependError("write field stop error: ", err) }
242 if err := oprot.WriteStructEnd(); err != nil {
243 return thrift.PrependError("write struct stop error: ", err) }
244 return nil
245 }
246
247 func (p *ConcatReply) writeField1(oprot thrift.TProtocol) (err error) {
248 if err := oprot.WriteFieldBegin("value", thrift.STRING, 1); err != nil {
249 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) }
250 if err := oprot.WriteString(string(p.Value)); err != nil {
251 return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) }
252 if err := oprot.WriteFieldEnd(); err != nil {
253 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) }
254 return err
255 }
256
257 func (p *ConcatReply) writeField2(oprot thrift.TProtocol) (err error) {
258 if err := oprot.WriteFieldBegin("err", thrift.STRING, 2); err != nil {
259 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:err: ", p), err) }
260 if err := oprot.WriteString(string(p.Err)); err != nil {
261 return thrift.PrependError(fmt.Sprintf("%T.err (2) field write error: ", p), err) }
262 if err := oprot.WriteFieldEnd(); err != nil {
263 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:err: ", p), err) }
264 return err
265 }
266
267 func (p *ConcatReply) String() string {
268 if p == nil {
269 return "<nil>"
270 }
271 return fmt.Sprintf("ConcatReply(%+v)", *p)
272 }
273
274 type AddService interface {
275 // Parameters:
276 // - A
277 // - B
278 Sum(ctx context.Context, a int64, b int64) (r *SumReply, err error)
279 // Parameters:
280 // - A
281 // - B
282 Concat(ctx context.Context, a string, b string) (r *ConcatReply, err error)
283 }
284
285 type AddServiceClient struct {
286 Transport thrift.TTransport
287 ProtocolFactory thrift.TProtocolFactory
288 InputProtocol thrift.TProtocol
289 OutputProtocol thrift.TProtocol
290 SeqId int32
291 }
292
293 func NewAddServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *AddServiceClient {
294 return &AddServiceClient{Transport: t,
295 ProtocolFactory: f,
296 InputProtocol: f.GetProtocol(t),
297 OutputProtocol: f.GetProtocol(t),
298 SeqId: 0,
299 }
300 }
301
302 func NewAddServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *AddServiceClient {
303 return &AddServiceClient{Transport: t,
304 ProtocolFactory: nil,
305 InputProtocol: iprot,
306 OutputProtocol: oprot,
307 SeqId: 0,
308 }
309 }
310
311 // Parameters:
312 // - A
313 // - B
314 func (p *AddServiceClient) Sum(ctx context.Context, a int64, b int64) (r *SumReply, err error) {
315 if err = p.sendSum(a, b); err != nil { return }
316 return p.recvSum()
317 }
318
319 func (p *AddServiceClient) sendSum(a int64, b int64)(err error) {
320 oprot := p.OutputProtocol
321 if oprot == nil {
322 oprot = p.ProtocolFactory.GetProtocol(p.Transport)
323 p.OutputProtocol = oprot
324 }
325 p.SeqId++
326 if err = oprot.WriteMessageBegin("Sum", thrift.CALL, p.SeqId); err != nil {
327 return
328 }
329 args := AddServiceSumArgs{
330 A : a,
331 B : b,
332 }
333 if err = args.Write(oprot); err != nil {
334 return
335 }
336 if err = oprot.WriteMessageEnd(); err != nil {
337 return
338 }
339 return oprot.Flush()
340 }
341
342
343 func (p *AddServiceClient) recvSum() (value *SumReply, err error) {
344 iprot := p.InputProtocol
345 if iprot == nil {
346 iprot = p.ProtocolFactory.GetProtocol(p.Transport)
347 p.InputProtocol = iprot
348 }
349 method, mTypeId, seqId, err := iprot.ReadMessageBegin()
350 if err != nil {
351 return
352 }
353 if method != "Sum" {
354 err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "Sum failed: wrong method name")
355 return
356 }
357 if p.SeqId != seqId {
358 err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "Sum failed: out of sequence response")
359 return
360 }
361 if mTypeId == thrift.EXCEPTION {
362 error0 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
363 var error1 error
364 error1, err = error0.Read(iprot)
365 if err != nil {
366 return
367 }
368 if err = iprot.ReadMessageEnd(); err != nil {
369 return
370 }
371 err = error1
372 return
373 }
374 if mTypeId != thrift.REPLY {
375 err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "Sum failed: invalid message type")
376 return
377 }
378 result := AddServiceSumResult{}
379 if err = result.Read(iprot); err != nil {
380 return
381 }
382 if err = iprot.ReadMessageEnd(); err != nil {
383 return
384 }
385 value = result.GetSuccess()
386 return
387 }
388
389 // Parameters:
390 // - A
391 // - B
392 func (p *AddServiceClient) Concat(ctx context.Context, a string, b string) (r *ConcatReply, err error) {
393 if err = p.sendConcat(a, b); err != nil { return }
394 return p.recvConcat()
395 }
396
397 func (p *AddServiceClient) sendConcat(a string, b string)(err error) {
398 oprot := p.OutputProtocol
399 if oprot == nil {
400 oprot = p.ProtocolFactory.GetProtocol(p.Transport)
401 p.OutputProtocol = oprot
402 }
403 p.SeqId++
404 if err = oprot.WriteMessageBegin("Concat", thrift.CALL, p.SeqId); err != nil {
405 return
406 }
407 args := AddServiceConcatArgs{
408 A : a,
409 B : b,
410 }
411 if err = args.Write(oprot); err != nil {
412 return
413 }
414 if err = oprot.WriteMessageEnd(); err != nil {
415 return
416 }
417 return oprot.Flush()
418 }
419
420
421 func (p *AddServiceClient) recvConcat() (value *ConcatReply, err error) {
422 iprot := p.InputProtocol
423 if iprot == nil {
424 iprot = p.ProtocolFactory.GetProtocol(p.Transport)
425 p.InputProtocol = iprot
426 }
427 method, mTypeId, seqId, err := iprot.ReadMessageBegin()
428 if err != nil {
429 return
430 }
431 if method != "Concat" {
432 err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "Concat failed: wrong method name")
433 return
434 }
435 if p.SeqId != seqId {
436 err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "Concat failed: out of sequence response")
437 return
438 }
439 if mTypeId == thrift.EXCEPTION {
440 error2 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
441 var error3 error
442 error3, err = error2.Read(iprot)
443 if err != nil {
444 return
445 }
446 if err = iprot.ReadMessageEnd(); err != nil {
447 return
448 }
449 err = error3
450 return
451 }
452 if mTypeId != thrift.REPLY {
453 err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "Concat failed: invalid message type")
454 return
455 }
456 result := AddServiceConcatResult{}
457 if err = result.Read(iprot); err != nil {
458 return
459 }
460 if err = iprot.ReadMessageEnd(); err != nil {
461 return
462 }
463 value = result.GetSuccess()
464 return
465 }
466
467
468 type AddServiceProcessor struct {
469 processorMap map[string]thrift.TProcessorFunction
470 handler AddService
471 }
472
473 func (p *AddServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) {
474 p.processorMap[key] = processor
475 }
476
477 func (p *AddServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) {
478 processor, ok = p.processorMap[key]
479 return processor, ok
480 }
481
482 func (p *AddServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction {
483 return p.processorMap
484 }
485
486 func NewAddServiceProcessor(handler AddService) *AddServiceProcessor {
487
488 self4 := &AddServiceProcessor{handler:handler, processorMap:make(map[string]thrift.TProcessorFunction)}
489 self4.processorMap["Sum"] = &addServiceProcessorSum{handler:handler}
490 self4.processorMap["Concat"] = &addServiceProcessorConcat{handler:handler}
491 return self4
492 }
493
494 func (p *AddServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
495 name, _, seqId, err := iprot.ReadMessageBegin()
496 if err != nil { return false, err }
497 if processor, ok := p.GetProcessorFunction(name); ok {
498 return processor.Process(ctx, seqId, iprot, oprot)
499 }
500 iprot.Skip(thrift.STRUCT)
501 iprot.ReadMessageEnd()
502 x5 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function " + name)
503 oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId)
504 x5.Write(oprot)
505 oprot.WriteMessageEnd()
506 oprot.Flush()
507 return false, x5
508
509 }
510
511 type addServiceProcessorSum struct {
512 handler AddService
513 }
514
515 func (p *addServiceProcessorSum) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
516 args := AddServiceSumArgs{}
517 if err = args.Read(iprot); err != nil {
518 iprot.ReadMessageEnd()
519 x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
520 oprot.WriteMessageBegin("Sum", thrift.EXCEPTION, seqId)
521 x.Write(oprot)
522 oprot.WriteMessageEnd()
523 oprot.Flush()
524 return false, err
525 }
526
527 iprot.ReadMessageEnd()
528 result := AddServiceSumResult{}
529 var retval *SumReply
530 var err2 error
531 if retval, err2 = p.handler.Sum(ctx, args.A, args.B); err2 != nil {
532 x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Sum: " + err2.Error())
533 oprot.WriteMessageBegin("Sum", thrift.EXCEPTION, seqId)
534 x.Write(oprot)
535 oprot.WriteMessageEnd()
536 oprot.Flush()
537 return true, err2
538 } else {
539 result.Success = retval
540 }
541 if err2 = oprot.WriteMessageBegin("Sum", thrift.REPLY, seqId); err2 != nil {
542 err = err2
543 }
544 if err2 = result.Write(oprot); err == nil && err2 != nil {
545 err = err2
546 }
547 if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
548 err = err2
549 }
550 if err2 = oprot.Flush(); err == nil && err2 != nil {
551 err = err2
552 }
553 if err != nil {
554 return
555 }
556 return true, err
557 }
558
559 type addServiceProcessorConcat struct {
560 handler AddService
561 }
562
563 func (p *addServiceProcessorConcat) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
564 args := AddServiceConcatArgs{}
565 if err = args.Read(iprot); err != nil {
566 iprot.ReadMessageEnd()
567 x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
568 oprot.WriteMessageBegin("Concat", thrift.EXCEPTION, seqId)
569 x.Write(oprot)
570 oprot.WriteMessageEnd()
571 oprot.Flush()
572 return false, err
573 }
574
575 iprot.ReadMessageEnd()
576 result := AddServiceConcatResult{}
577 var retval *ConcatReply
578 var err2 error
579 if retval, err2 = p.handler.Concat(ctx, args.A, args.B); err2 != nil {
580 x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Concat: " + err2.Error())
581 oprot.WriteMessageBegin("Concat", thrift.EXCEPTION, seqId)
582 x.Write(oprot)
583 oprot.WriteMessageEnd()
584 oprot.Flush()
585 return true, err2
586 } else {
587 result.Success = retval
588 }
589 if err2 = oprot.WriteMessageBegin("Concat", thrift.REPLY, seqId); err2 != nil {
590 err = err2
591 }
592 if err2 = result.Write(oprot); err == nil && err2 != nil {
593 err = err2
594 }
595 if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
596 err = err2
597 }
598 if err2 = oprot.Flush(); err == nil && err2 != nil {
599 err = err2
600 }
601 if err != nil {
602 return
603 }
604 return true, err
605 }
606
607
608 // HELPER FUNCTIONS AND STRUCTURES
609
610 // Attributes:
611 // - A
612 // - B
613 type AddServiceSumArgs struct {
614 A int64 `thrift:"a,1" db:"a" json:"a"`
615 B int64 `thrift:"b,2" db:"b" json:"b"`
616 }
617
618 func NewAddServiceSumArgs() *AddServiceSumArgs {
619 return &AddServiceSumArgs{}
620 }
621
622
623 func (p *AddServiceSumArgs) GetA() int64 {
624 return p.A
625 }
626
627 func (p *AddServiceSumArgs) GetB() int64 {
628 return p.B
629 }
630 func (p *AddServiceSumArgs) Read(iprot thrift.TProtocol) error {
631 if _, err := iprot.ReadStructBegin(); err != nil {
632 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
633 }
634
635
636 for {
637 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
638 if err != nil {
639 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
640 }
641 if fieldTypeId == thrift.STOP { break; }
642 switch fieldId {
643 case 1:
644 if fieldTypeId == thrift.I64 {
645 if err := p.ReadField1(iprot); err != nil {
646 return err
647 }
648 } else {
649 if err := iprot.Skip(fieldTypeId); err != nil {
650 return err
651 }
652 }
653 case 2:
654 if fieldTypeId == thrift.I64 {
655 if err := p.ReadField2(iprot); err != nil {
656 return err
657 }
658 } else {
659 if err := iprot.Skip(fieldTypeId); err != nil {
660 return err
661 }
662 }
663 default:
664 if err := iprot.Skip(fieldTypeId); err != nil {
665 return err
666 }
667 }
668 if err := iprot.ReadFieldEnd(); err != nil {
669 return err
670 }
671 }
672 if err := iprot.ReadStructEnd(); err != nil {
673 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
674 }
675 return nil
676 }
677
678 func (p *AddServiceSumArgs) ReadField1(iprot thrift.TProtocol) error {
679 if v, err := iprot.ReadI64(); err != nil {
680 return thrift.PrependError("error reading field 1: ", err)
681 } else {
682 p.A = v
683 }
684 return nil
685 }
686
687 func (p *AddServiceSumArgs) ReadField2(iprot thrift.TProtocol) error {
688 if v, err := iprot.ReadI64(); err != nil {
689 return thrift.PrependError("error reading field 2: ", err)
690 } else {
691 p.B = v
692 }
693 return nil
694 }
695
696 func (p *AddServiceSumArgs) Write(oprot thrift.TProtocol) error {
697 if err := oprot.WriteStructBegin("Sum_args"); err != nil {
698 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
699 if p != nil {
700 if err := p.writeField1(oprot); err != nil { return err }
701 if err := p.writeField2(oprot); err != nil { return err }
702 }
703 if err := oprot.WriteFieldStop(); err != nil {
704 return thrift.PrependError("write field stop error: ", err) }
705 if err := oprot.WriteStructEnd(); err != nil {
706 return thrift.PrependError("write struct stop error: ", err) }
707 return nil
708 }
709
710 func (p *AddServiceSumArgs) writeField1(oprot thrift.TProtocol) (err error) {
711 if err := oprot.WriteFieldBegin("a", thrift.I64, 1); err != nil {
712 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:a: ", p), err) }
713 if err := oprot.WriteI64(int64(p.A)); err != nil {
714 return thrift.PrependError(fmt.Sprintf("%T.a (1) field write error: ", p), err) }
715 if err := oprot.WriteFieldEnd(); err != nil {
716 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:a: ", p), err) }
717 return err
718 }
719
720 func (p *AddServiceSumArgs) writeField2(oprot thrift.TProtocol) (err error) {
721 if err := oprot.WriteFieldBegin("b", thrift.I64, 2); err != nil {
722 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:b: ", p), err) }
723 if err := oprot.WriteI64(int64(p.B)); err != nil {
724 return thrift.PrependError(fmt.Sprintf("%T.b (2) field write error: ", p), err) }
725 if err := oprot.WriteFieldEnd(); err != nil {
726 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:b: ", p), err) }
727 return err
728 }
729
730 func (p *AddServiceSumArgs) String() string {
731 if p == nil {
732 return "<nil>"
733 }
734 return fmt.Sprintf("AddServiceSumArgs(%+v)", *p)
735 }
736
737 // Attributes:
738 // - Success
739 type AddServiceSumResult struct {
740 Success *SumReply `thrift:"success,0" db:"success" json:"success,omitempty"`
741 }
742
743 func NewAddServiceSumResult() *AddServiceSumResult {
744 return &AddServiceSumResult{}
745 }
746
747 var AddServiceSumResult_Success_DEFAULT *SumReply
748 func (p *AddServiceSumResult) GetSuccess() *SumReply {
749 if !p.IsSetSuccess() {
750 return AddServiceSumResult_Success_DEFAULT
751 }
752 return p.Success
753 }
754 func (p *AddServiceSumResult) IsSetSuccess() bool {
755 return p.Success != nil
756 }
757
758 func (p *AddServiceSumResult) Read(iprot thrift.TProtocol) error {
759 if _, err := iprot.ReadStructBegin(); err != nil {
760 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
761 }
762
763
764 for {
765 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
766 if err != nil {
767 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
768 }
769 if fieldTypeId == thrift.STOP { break; }
770 switch fieldId {
771 case 0:
772 if fieldTypeId == thrift.STRUCT {
773 if err := p.ReadField0(iprot); err != nil {
774 return err
775 }
776 } else {
777 if err := iprot.Skip(fieldTypeId); err != nil {
778 return err
779 }
780 }
781 default:
782 if err := iprot.Skip(fieldTypeId); err != nil {
783 return err
784 }
785 }
786 if err := iprot.ReadFieldEnd(); err != nil {
787 return err
788 }
789 }
790 if err := iprot.ReadStructEnd(); err != nil {
791 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
792 }
793 return nil
794 }
795
796 func (p *AddServiceSumResult) ReadField0(iprot thrift.TProtocol) error {
797 p.Success = &SumReply{}
798 if err := p.Success.Read(iprot); err != nil {
799 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err)
800 }
801 return nil
802 }
803
804 func (p *AddServiceSumResult) Write(oprot thrift.TProtocol) error {
805 if err := oprot.WriteStructBegin("Sum_result"); err != nil {
806 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
807 if p != nil {
808 if err := p.writeField0(oprot); err != nil { return err }
809 }
810 if err := oprot.WriteFieldStop(); err != nil {
811 return thrift.PrependError("write field stop error: ", err) }
812 if err := oprot.WriteStructEnd(); err != nil {
813 return thrift.PrependError("write struct stop error: ", err) }
814 return nil
815 }
816
817 func (p *AddServiceSumResult) writeField0(oprot thrift.TProtocol) (err error) {
818 if p.IsSetSuccess() {
819 if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil {
820 return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) }
821 if err := p.Success.Write(oprot); err != nil {
822 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err)
823 }
824 if err := oprot.WriteFieldEnd(); err != nil {
825 return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) }
826 }
827 return err
828 }
829
830 func (p *AddServiceSumResult) String() string {
831 if p == nil {
832 return "<nil>"
833 }
834 return fmt.Sprintf("AddServiceSumResult(%+v)", *p)
835 }
836
837 // Attributes:
838 // - A
839 // - B
840 type AddServiceConcatArgs struct {
841 A string `thrift:"a,1" db:"a" json:"a"`
842 B string `thrift:"b,2" db:"b" json:"b"`
843 }
844
845 func NewAddServiceConcatArgs() *AddServiceConcatArgs {
846 return &AddServiceConcatArgs{}
847 }
848
849
850 func (p *AddServiceConcatArgs) GetA() string {
851 return p.A
852 }
853
854 func (p *AddServiceConcatArgs) GetB() string {
855 return p.B
856 }
857 func (p *AddServiceConcatArgs) Read(iprot thrift.TProtocol) error {
858 if _, err := iprot.ReadStructBegin(); err != nil {
859 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
860 }
861
862
863 for {
864 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
865 if err != nil {
866 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
867 }
868 if fieldTypeId == thrift.STOP { break; }
869 switch fieldId {
870 case 1:
871 if fieldTypeId == thrift.STRING {
872 if err := p.ReadField1(iprot); err != nil {
873 return err
874 }
875 } else {
876 if err := iprot.Skip(fieldTypeId); err != nil {
877 return err
878 }
879 }
880 case 2:
881 if fieldTypeId == thrift.STRING {
882 if err := p.ReadField2(iprot); err != nil {
883 return err
884 }
885 } else {
886 if err := iprot.Skip(fieldTypeId); err != nil {
887 return err
888 }
889 }
890 default:
891 if err := iprot.Skip(fieldTypeId); err != nil {
892 return err
893 }
894 }
895 if err := iprot.ReadFieldEnd(); err != nil {
896 return err
897 }
898 }
899 if err := iprot.ReadStructEnd(); err != nil {
900 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
901 }
902 return nil
903 }
904
905 func (p *AddServiceConcatArgs) ReadField1(iprot thrift.TProtocol) error {
906 if v, err := iprot.ReadString(); err != nil {
907 return thrift.PrependError("error reading field 1: ", err)
908 } else {
909 p.A = v
910 }
911 return nil
912 }
913
914 func (p *AddServiceConcatArgs) ReadField2(iprot thrift.TProtocol) error {
915 if v, err := iprot.ReadString(); err != nil {
916 return thrift.PrependError("error reading field 2: ", err)
917 } else {
918 p.B = v
919 }
920 return nil
921 }
922
923 func (p *AddServiceConcatArgs) Write(oprot thrift.TProtocol) error {
924 if err := oprot.WriteStructBegin("Concat_args"); err != nil {
925 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
926 if p != nil {
927 if err := p.writeField1(oprot); err != nil { return err }
928 if err := p.writeField2(oprot); err != nil { return err }
929 }
930 if err := oprot.WriteFieldStop(); err != nil {
931 return thrift.PrependError("write field stop error: ", err) }
932 if err := oprot.WriteStructEnd(); err != nil {
933 return thrift.PrependError("write struct stop error: ", err) }
934 return nil
935 }
936
937 func (p *AddServiceConcatArgs) writeField1(oprot thrift.TProtocol) (err error) {
938 if err := oprot.WriteFieldBegin("a", thrift.STRING, 1); err != nil {
939 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:a: ", p), err) }
940 if err := oprot.WriteString(string(p.A)); err != nil {
941 return thrift.PrependError(fmt.Sprintf("%T.a (1) field write error: ", p), err) }
942 if err := oprot.WriteFieldEnd(); err != nil {
943 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:a: ", p), err) }
944 return err
945 }
946
947 func (p *AddServiceConcatArgs) writeField2(oprot thrift.TProtocol) (err error) {
948 if err := oprot.WriteFieldBegin("b", thrift.STRING, 2); err != nil {
949 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:b: ", p), err) }
950 if err := oprot.WriteString(string(p.B)); err != nil {
951 return thrift.PrependError(fmt.Sprintf("%T.b (2) field write error: ", p), err) }
952 if err := oprot.WriteFieldEnd(); err != nil {
953 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:b: ", p), err) }
954 return err
955 }
956
957 func (p *AddServiceConcatArgs) String() string {
958 if p == nil {
959 return "<nil>"
960 }
961 return fmt.Sprintf("AddServiceConcatArgs(%+v)", *p)
962 }
963
964 // Attributes:
965 // - Success
966 type AddServiceConcatResult struct {
967 Success *ConcatReply `thrift:"success,0" db:"success" json:"success,omitempty"`
968 }
969
970 func NewAddServiceConcatResult() *AddServiceConcatResult {
971 return &AddServiceConcatResult{}
972 }
973
974 var AddServiceConcatResult_Success_DEFAULT *ConcatReply
975 func (p *AddServiceConcatResult) GetSuccess() *ConcatReply {
976 if !p.IsSetSuccess() {
977 return AddServiceConcatResult_Success_DEFAULT
978 }
979 return p.Success
980 }
981 func (p *AddServiceConcatResult) IsSetSuccess() bool {
982 return p.Success != nil
983 }
984
985 func (p *AddServiceConcatResult) Read(iprot thrift.TProtocol) error {
986 if _, err := iprot.ReadStructBegin(); err != nil {
987 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
988 }
989
990
991 for {
992 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
993 if err != nil {
994 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
995 }
996 if fieldTypeId == thrift.STOP { break; }
997 switch fieldId {
998 case 0:
999 if fieldTypeId == thrift.STRUCT {
1000 if err := p.ReadField0(iprot); err != nil {
1001 return err
1002 }
1003 } else {
1004 if err := iprot.Skip(fieldTypeId); err != nil {
1005 return err
1006 }
1007 }
1008 default:
1009 if err := iprot.Skip(fieldTypeId); err != nil {
1010 return err
1011 }
1012 }
1013 if err := iprot.ReadFieldEnd(); err != nil {
1014 return err
1015 }
1016 }
1017 if err := iprot.ReadStructEnd(); err != nil {
1018 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
1019 }
1020 return nil
1021 }
1022
1023 func (p *AddServiceConcatResult) ReadField0(iprot thrift.TProtocol) error {
1024 p.Success = &ConcatReply{}
1025 if err := p.Success.Read(iprot); err != nil {
1026 return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err)
1027 }
1028 return nil
1029 }
1030
1031 func (p *AddServiceConcatResult) Write(oprot thrift.TProtocol) error {
1032 if err := oprot.WriteStructBegin("Concat_result"); err != nil {
1033 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
1034 if p != nil {
1035 if err := p.writeField0(oprot); err != nil { return err }
1036 }
1037 if err := oprot.WriteFieldStop(); err != nil {
1038 return thrift.PrependError("write field stop error: ", err) }
1039 if err := oprot.WriteStructEnd(); err != nil {
1040 return thrift.PrependError("write struct stop error: ", err) }
1041 return nil
1042 }
1043
1044 func (p *AddServiceConcatResult) writeField0(oprot thrift.TProtocol) (err error) {
1045 if p.IsSetSuccess() {
1046 if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil {
1047 return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) }
1048 if err := p.Success.Write(oprot); err != nil {
1049 return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err)
1050 }
1051 if err := oprot.WriteFieldEnd(); err != nil {
1052 return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) }
1053 }
1054 return err
1055 }
1056
1057 func (p *AddServiceConcatResult) String() string {
1058 if p == nil {
1059 return "<nil>"
1060 }
1061 return fmt.Sprintf("AddServiceConcatResult(%+v)", *p)
1062 }
1063
1064
+0
-18
examples/addsvc/thrift/gen-go/addsvc/constants.go less more
0 // Autogenerated by Thrift Compiler (0.9.3)
1 // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
2
3 package addsvc
4
5 import (
6 "bytes"
7 "fmt"
8 "github.com/apache/thrift/lib/go/thrift"
9 )
10
11 // (needed to ensure safety because of naive import list construction.)
12 var _ = thrift.ZERO
13 var _ = fmt.Printf
14 var _ = bytes.Equal
15
16 func init() {
17 }
+0
-269
examples/addsvc/thrift/gen-go/addsvc/ttypes.go less more
0 // Autogenerated by Thrift Compiler (0.9.3)
1 // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
2
3 package addsvc
4
5 import (
6 "bytes"
7 "fmt"
8 "github.com/apache/thrift/lib/go/thrift"
9 )
10
11 // (needed to ensure safety because of naive import list construction.)
12 var _ = thrift.ZERO
13 var _ = fmt.Printf
14 var _ = bytes.Equal
15
16 var GoUnusedProtection__ int
17
18 // Attributes:
19 // - Value
20 // - Err
21 type SumReply struct {
22 Value int64 `thrift:"value,1" json:"value"`
23 Err string `thrift:"err,2" json:"err"`
24 }
25
26 func NewSumReply() *SumReply {
27 return &SumReply{}
28 }
29
30 func (p *SumReply) GetValue() int64 {
31 return p.Value
32 }
33
34 func (p *SumReply) GetErr() string {
35 return p.Err
36 }
37 func (p *SumReply) Read(iprot thrift.TProtocol) error {
38 if _, err := iprot.ReadStructBegin(); err != nil {
39 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
40 }
41
42 for {
43 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
44 if err != nil {
45 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
46 }
47 if fieldTypeId == thrift.STOP {
48 break
49 }
50 switch fieldId {
51 case 1:
52 if err := p.readField1(iprot); err != nil {
53 return err
54 }
55 case 2:
56 if err := p.readField2(iprot); err != nil {
57 return err
58 }
59 default:
60 if err := iprot.Skip(fieldTypeId); err != nil {
61 return err
62 }
63 }
64 if err := iprot.ReadFieldEnd(); err != nil {
65 return err
66 }
67 }
68 if err := iprot.ReadStructEnd(); err != nil {
69 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
70 }
71 return nil
72 }
73
74 func (p *SumReply) readField1(iprot thrift.TProtocol) error {
75 if v, err := iprot.ReadI64(); err != nil {
76 return thrift.PrependError("error reading field 1: ", err)
77 } else {
78 p.Value = v
79 }
80 return nil
81 }
82
83 func (p *SumReply) readField2(iprot thrift.TProtocol) error {
84 if v, err := iprot.ReadString(); err != nil {
85 return thrift.PrependError("error reading field 2: ", err)
86 } else {
87 p.Err = v
88 }
89 return nil
90 }
91
92 func (p *SumReply) Write(oprot thrift.TProtocol) error {
93 if err := oprot.WriteStructBegin("SumReply"); err != nil {
94 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
95 }
96 if err := p.writeField1(oprot); err != nil {
97 return err
98 }
99 if err := p.writeField2(oprot); err != nil {
100 return err
101 }
102 if err := oprot.WriteFieldStop(); err != nil {
103 return thrift.PrependError("write field stop error: ", err)
104 }
105 if err := oprot.WriteStructEnd(); err != nil {
106 return thrift.PrependError("write struct stop error: ", err)
107 }
108 return nil
109 }
110
111 func (p *SumReply) writeField1(oprot thrift.TProtocol) (err error) {
112 if err := oprot.WriteFieldBegin("value", thrift.I64, 1); err != nil {
113 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err)
114 }
115 if err := oprot.WriteI64(int64(p.Value)); err != nil {
116 return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err)
117 }
118 if err := oprot.WriteFieldEnd(); err != nil {
119 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err)
120 }
121 return err
122 }
123
124 func (p *SumReply) writeField2(oprot thrift.TProtocol) (err error) {
125 if err := oprot.WriteFieldBegin("err", thrift.STRING, 2); err != nil {
126 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:err: ", p), err)
127 }
128 if err := oprot.WriteString(string(p.Err)); err != nil {
129 return thrift.PrependError(fmt.Sprintf("%T.err (2) field write error: ", p), err)
130 }
131 if err := oprot.WriteFieldEnd(); err != nil {
132 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:err: ", p), err)
133 }
134 return err
135 }
136
137 func (p *SumReply) String() string {
138 if p == nil {
139 return "<nil>"
140 }
141 return fmt.Sprintf("SumReply(%+v)", *p)
142 }
143
144 // Attributes:
145 // - Value
146 // - Err
147 type ConcatReply struct {
148 Value string `thrift:"value,1" json:"value"`
149 Err string `thrift:"err,2" json:"err"`
150 }
151
152 func NewConcatReply() *ConcatReply {
153 return &ConcatReply{}
154 }
155
156 func (p *ConcatReply) GetValue() string {
157 return p.Value
158 }
159
160 func (p *ConcatReply) GetErr() string {
161 return p.Err
162 }
163 func (p *ConcatReply) Read(iprot thrift.TProtocol) error {
164 if _, err := iprot.ReadStructBegin(); err != nil {
165 return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
166 }
167
168 for {
169 _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
170 if err != nil {
171 return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
172 }
173 if fieldTypeId == thrift.STOP {
174 break
175 }
176 switch fieldId {
177 case 1:
178 if err := p.readField1(iprot); err != nil {
179 return err
180 }
181 case 2:
182 if err := p.readField2(iprot); err != nil {
183 return err
184 }
185 default:
186 if err := iprot.Skip(fieldTypeId); err != nil {
187 return err
188 }
189 }
190 if err := iprot.ReadFieldEnd(); err != nil {
191 return err
192 }
193 }
194 if err := iprot.ReadStructEnd(); err != nil {
195 return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
196 }
197 return nil
198 }
199
200 func (p *ConcatReply) readField1(iprot thrift.TProtocol) error {
201 if v, err := iprot.ReadString(); err != nil {
202 return thrift.PrependError("error reading field 1: ", err)
203 } else {
204 p.Value = v
205 }
206 return nil
207 }
208
209 func (p *ConcatReply) readField2(iprot thrift.TProtocol) error {
210 if v, err := iprot.ReadString(); err != nil {
211 return thrift.PrependError("error reading field 2: ", err)
212 } else {
213 p.Err = v
214 }
215 return nil
216 }
217
218 func (p *ConcatReply) Write(oprot thrift.TProtocol) error {
219 if err := oprot.WriteStructBegin("ConcatReply"); err != nil {
220 return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
221 }
222 if err := p.writeField1(oprot); err != nil {
223 return err
224 }
225 if err := p.writeField2(oprot); err != nil {
226 return err
227 }
228 if err := oprot.WriteFieldStop(); err != nil {
229 return thrift.PrependError("write field stop error: ", err)
230 }
231 if err := oprot.WriteStructEnd(); err != nil {
232 return thrift.PrependError("write struct stop error: ", err)
233 }
234 return nil
235 }
236
237 func (p *ConcatReply) writeField1(oprot thrift.TProtocol) (err error) {
238 if err := oprot.WriteFieldBegin("value", thrift.STRING, 1); err != nil {
239 return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err)
240 }
241 if err := oprot.WriteString(string(p.Value)); err != nil {
242 return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err)
243 }
244 if err := oprot.WriteFieldEnd(); err != nil {
245 return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err)
246 }
247 return err
248 }
249
250 func (p *ConcatReply) writeField2(oprot thrift.TProtocol) (err error) {
251 if err := oprot.WriteFieldBegin("err", thrift.STRING, 2); err != nil {
252 return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:err: ", p), err)
253 }
254 if err := oprot.WriteString(string(p.Err)); err != nil {
255 return thrift.PrependError(fmt.Sprintf("%T.err (2) field write error: ", p), err)
256 }
257 if err := oprot.WriteFieldEnd(); err != nil {
258 return thrift.PrependError(fmt.Sprintf("%T write field end error 2:err: ", p), err)
259 }
260 return err
261 }
262
263 func (p *ConcatReply) String() string {
264 if p == nil {
265 return "<nil>"
266 }
267 return fmt.Sprintf("ConcatReply(%+v)", *p)
268 }