]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/thrift/test/go/src/common/simple_handler.go
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / test / go / src / common / simple_handler.go
CommitLineData
f67539c2
TL
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20package common
21
22import (
23 "errors"
24 . "gen/thrifttest"
25 "time"
26)
27
28var SimpleHandler = &simpleHandler{}
29
30type simpleHandler struct{}
31
32func (p *simpleHandler) TestVoid() (err error) {
33 return nil
34}
35
36func (p *simpleHandler) TestString(thing string) (r string, err error) {
37 return thing, nil
38}
39
40func (p *simpleHandler) TestBool(thing []byte) (r []byte, err error) {
41 return thing, nil
42}
43
44func (p *simpleHandler) TestByte(thing int8) (r int8, err error) {
45 return thing, nil
46}
47
48func (p *simpleHandler) TestI32(thing int32) (r int32, err error) {
49 return thing, nil
50}
51
52func (p *simpleHandler) TestI64(thing int64) (r int64, err error) {
53 return thing, nil
54}
55
56func (p *simpleHandler) TestDouble(thing float64) (r float64, err error) {
57 return thing, nil
58}
59
60func (p *simpleHandler) TestBinary(thing []byte) (r []byte, err error) {
61 return thing, nil
62}
63
64func (p *simpleHandler) TestStruct(thing *Xtruct) (r *Xtruct, err error) {
65 return r, err
66}
67
68func (p *simpleHandler) TestNest(nest *Xtruct2) (r *Xtruct2, err error) {
69 return nest, nil
70}
71
72func (p *simpleHandler) TestMap(thing map[int32]int32) (r map[int32]int32, err error) {
73 return thing, nil
74}
75
76func (p *simpleHandler) TestStringMap(thing map[string]string) (r map[string]string, err error) {
77 return thing, nil
78}
79
80func (p *simpleHandler) TestSet(thing []int32) (r []int32, err error) {
81 return thing, nil
82}
83
84func (p *simpleHandler) TestList(thing []int32) (r []int32, err error) {
85 return thing, nil
86}
87
88func (p *simpleHandler) TestEnum(thing Numberz) (r Numberz, err error) {
89 return thing, nil
90}
91
92func (p *simpleHandler) TestTypedef(thing UserId) (r UserId, err error) {
93 return thing, nil
94}
95
96func (p *simpleHandler) TestMapMap(hello int32) (r map[int32]map[int32]int32, err error) {
97
98 r = map[int32]map[int32]int32{
99 -4: map[int32]int32{-4: -4, -3: -3, -2: -2, -1: -1},
100 4: map[int32]int32{4: 4, 3: 3, 2: 2, 1: 1},
101 }
102 return
103}
104
105func (p *simpleHandler) TestInsanity(argument *Insanity) (r map[UserId]map[Numberz]*Insanity, err error) {
106 return nil, errors.New("No Insanity")
107}
108
109func (p *simpleHandler) TestMulti(arg0 int8, arg1 int32, arg2 int64, arg3 map[int16]string, arg4 Numberz, arg5 UserId) (r *Xtruct, err error) {
110 r = NewXtruct()
111
112 r.StringThing = "Hello2"
113 r.ByteThing = arg0
114 r.I32Thing = arg1
115 r.I64Thing = arg2
116 return
117}
118
119func (p *simpleHandler) TestException(arg string) (err error) {
120 switch arg {
121 case "Xception":
122 e := NewXception()
123 e.ErrorCode = 1001
124 e.Message = arg
125 return e
126 case "TException":
127 return errors.New("Just TException")
128 }
129 return
130}
131
132func (p *simpleHandler) TestMultiException(arg0 string, arg1 string) (r *Xtruct, err error) {
133 switch arg0 {
134
135 case "Xception":
136 e := NewXception()
137 e.ErrorCode = 1001
138 e.Message = "This is an Xception"
139 return nil, e
140 case "Xception2":
141 e := NewXception2()
142 e.ErrorCode = 2002
143 e.StructThing.StringThing = "This is an Xception2"
144 return nil, e
145 default:
146 r = NewXtruct()
147 r.StringThing = arg1
148 return
149 }
150}
151
152func (p *simpleHandler) TestOneway(secondsToSleep int32) (err error) {
153 time.Sleep(time.Second * time.Duration(secondsToSleep))
154 return
155}