rpcrequestgmiface.go 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. // Autogenerated by Thrift Compiler (0.9.2)
  2. // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  3. package common
  4. import (
  5. "bytes"
  6. "fmt"
  7. "gmanager/library/thrift"
  8. )
  9. // (needed to ensure safety because of naive import list construction.)
  10. var _ = thrift.ZERO
  11. var _ = fmt.Printf
  12. var _ = bytes.Equal
  13. type RPCRequestGMIFace interface {
  14. // Parameters:
  15. // - Reserved
  16. // - Cmd
  17. IdipGm(reserved string, cmd string) (r *Result_, err error)
  18. }
  19. type RPCRequestGMIFaceClient struct {
  20. Transport thrift.TTransport
  21. ProtocolFactory thrift.TProtocolFactory
  22. InputProtocol thrift.TProtocol
  23. OutputProtocol thrift.TProtocol
  24. SeqId int32
  25. }
  26. func NewRPCRequestGMIFaceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *RPCRequestGMIFaceClient {
  27. return &RPCRequestGMIFaceClient{Transport: t,
  28. ProtocolFactory: f,
  29. InputProtocol: f.GetProtocol(t),
  30. OutputProtocol: f.GetProtocol(t),
  31. SeqId: 0,
  32. }
  33. }
  34. func NewRPCRequestGMIFaceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *RPCRequestGMIFaceClient {
  35. return &RPCRequestGMIFaceClient{Transport: t,
  36. ProtocolFactory: nil,
  37. InputProtocol: iprot,
  38. OutputProtocol: oprot,
  39. SeqId: 0,
  40. }
  41. }
  42. // Parameters:
  43. // - Reserved
  44. // - Cmd
  45. func (p *RPCRequestGMIFaceClient) IdipGm(reserved string, cmd string) (r *Result_, err error) {
  46. if err = p.sendIdipGm(reserved, cmd); err != nil {
  47. return
  48. }
  49. return p.recvIdipGm()
  50. }
  51. func (p *RPCRequestGMIFaceClient) sendIdipGm(reserved string, cmd string) (err error) {
  52. oprot := p.OutputProtocol
  53. if oprot == nil {
  54. oprot = p.ProtocolFactory.GetProtocol(p.Transport)
  55. p.OutputProtocol = oprot
  56. }
  57. p.SeqId++
  58. if err = oprot.WriteMessageBegin("idipGm", thrift.CALL, p.SeqId); err != nil {
  59. return
  60. }
  61. args := IdipGmArgs{
  62. Reserved: reserved,
  63. Cmd: cmd,
  64. }
  65. if err = args.Write(oprot); err != nil {
  66. return
  67. }
  68. if err = oprot.WriteMessageEnd(); err != nil {
  69. return
  70. }
  71. return oprot.Flush()
  72. }
  73. func (p *RPCRequestGMIFaceClient) recvIdipGm() (value *Result_, err error) {
  74. iprot := p.InputProtocol
  75. if iprot == nil {
  76. iprot = p.ProtocolFactory.GetProtocol(p.Transport)
  77. p.InputProtocol = iprot
  78. }
  79. _, mTypeId, seqId, err := iprot.ReadMessageBegin()
  80. if err != nil {
  81. return
  82. }
  83. if mTypeId == thrift.EXCEPTION {
  84. error0 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
  85. var error1 error
  86. error1, err = error0.Read(iprot)
  87. if err != nil {
  88. return
  89. }
  90. if err = iprot.ReadMessageEnd(); err != nil {
  91. return
  92. }
  93. err = error1
  94. return
  95. }
  96. if p.SeqId != seqId {
  97. err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "idipGm failed: out of sequence response")
  98. return
  99. }
  100. result := IdipGmResult{}
  101. if err = result.Read(iprot); err != nil {
  102. return
  103. }
  104. if err = iprot.ReadMessageEnd(); err != nil {
  105. return
  106. }
  107. if result.Ouch != nil {
  108. err = result.Ouch
  109. return
  110. }
  111. value = result.GetSuccess()
  112. return
  113. }
  114. type RPCRequestGMIFaceProcessor struct {
  115. processorMap map[string]thrift.TProcessorFunction
  116. handler RPCRequestGMIFace
  117. }
  118. func (p *RPCRequestGMIFaceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) {
  119. p.processorMap[key] = processor
  120. }
  121. func (p *RPCRequestGMIFaceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) {
  122. processor, ok = p.processorMap[key]
  123. return processor, ok
  124. }
  125. func (p *RPCRequestGMIFaceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction {
  126. return p.processorMap
  127. }
  128. func NewRPCRequestGMIFaceProcessor(handler RPCRequestGMIFace) *RPCRequestGMIFaceProcessor {
  129. self2 := &RPCRequestGMIFaceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)}
  130. self2.processorMap["idipGm"] = &rPCRequestGMIFaceProcessorIdipGm{handler: handler}
  131. return self2
  132. }
  133. func (p *RPCRequestGMIFaceProcessor) Process(iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
  134. name, _, seqId, err := iprot.ReadMessageBegin()
  135. if err != nil {
  136. return false, err
  137. }
  138. if processor, ok := p.GetProcessorFunction(name); ok {
  139. return processor.Process(seqId, iprot, oprot)
  140. }
  141. iprot.Skip(thrift.STRUCT)
  142. iprot.ReadMessageEnd()
  143. x3 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name)
  144. oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId)
  145. x3.Write(oprot)
  146. oprot.WriteMessageEnd()
  147. oprot.Flush()
  148. return false, x3
  149. }
  150. type rPCRequestGMIFaceProcessorIdipGm struct {
  151. handler RPCRequestGMIFace
  152. }
  153. func (p *rPCRequestGMIFaceProcessorIdipGm) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
  154. args := IdipGmArgs{}
  155. if err = args.Read(iprot); err != nil {
  156. iprot.ReadMessageEnd()
  157. x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
  158. oprot.WriteMessageBegin("idipGm", thrift.EXCEPTION, seqId)
  159. x.Write(oprot)
  160. oprot.WriteMessageEnd()
  161. oprot.Flush()
  162. return false, err
  163. }
  164. iprot.ReadMessageEnd()
  165. result := IdipGmResult{}
  166. var retval *Result_
  167. var err2 error
  168. if retval, err2 = p.handler.IdipGm(args.Reserved, args.Cmd); err2 != nil {
  169. switch v := err2.(type) {
  170. case *InvalidOperException:
  171. result.Ouch = v
  172. default:
  173. x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing idipGm: "+err2.Error())
  174. oprot.WriteMessageBegin("idipGm", thrift.EXCEPTION, seqId)
  175. x.Write(oprot)
  176. oprot.WriteMessageEnd()
  177. oprot.Flush()
  178. return true, err2
  179. }
  180. } else {
  181. result.Success = retval
  182. }
  183. if err2 = oprot.WriteMessageBegin("idipGm", thrift.REPLY, seqId); err2 != nil {
  184. err = err2
  185. }
  186. if err2 = result.Write(oprot); err == nil && err2 != nil {
  187. err = err2
  188. }
  189. if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
  190. err = err2
  191. }
  192. if err2 = oprot.Flush(); err == nil && err2 != nil {
  193. err = err2
  194. }
  195. if err != nil {
  196. return
  197. }
  198. return true, err
  199. }
  200. // HELPER FUNCTIONS AND STRUCTURES
  201. type IdipGmArgs struct {
  202. Reserved string `thrift:"reserved,1" json:"reserved"`
  203. Cmd string `thrift:"cmd,2" json:"cmd"`
  204. }
  205. func NewIdipGmArgs() *IdipGmArgs {
  206. return &IdipGmArgs{}
  207. }
  208. func (p *IdipGmArgs) GetReserved() string {
  209. return p.Reserved
  210. }
  211. func (p *IdipGmArgs) GetCmd() string {
  212. return p.Cmd
  213. }
  214. func (p *IdipGmArgs) Read(iprot thrift.TProtocol) error {
  215. if _, err := iprot.ReadStructBegin(); err != nil {
  216. return fmt.Errorf("%T read error: %s", p, err)
  217. }
  218. for {
  219. _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
  220. if err != nil {
  221. return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
  222. }
  223. if fieldTypeId == thrift.STOP {
  224. break
  225. }
  226. switch fieldId {
  227. case 1:
  228. if err := p.ReadField1(iprot); err != nil {
  229. return err
  230. }
  231. case 2:
  232. if err := p.ReadField2(iprot); err != nil {
  233. return err
  234. }
  235. default:
  236. if err := iprot.Skip(fieldTypeId); err != nil {
  237. return err
  238. }
  239. }
  240. if err := iprot.ReadFieldEnd(); err != nil {
  241. return err
  242. }
  243. }
  244. if err := iprot.ReadStructEnd(); err != nil {
  245. return fmt.Errorf("%T read struct end error: %s", p, err)
  246. }
  247. return nil
  248. }
  249. func (p *IdipGmArgs) ReadField1(iprot thrift.TProtocol) error {
  250. if v, err := iprot.ReadString(); err != nil {
  251. return fmt.Errorf("error reading field 1: %s", err)
  252. } else {
  253. p.Reserved = v
  254. }
  255. return nil
  256. }
  257. func (p *IdipGmArgs) ReadField2(iprot thrift.TProtocol) error {
  258. if v, err := iprot.ReadString(); err != nil {
  259. return fmt.Errorf("error reading field 2: %s", err)
  260. } else {
  261. p.Cmd = v
  262. }
  263. return nil
  264. }
  265. func (p *IdipGmArgs) Write(oprot thrift.TProtocol) error {
  266. if err := oprot.WriteStructBegin("idipGm_args"); err != nil {
  267. return fmt.Errorf("%T write struct begin error: %s", p, err)
  268. }
  269. if err := p.writeField1(oprot); err != nil {
  270. return err
  271. }
  272. if err := p.writeField2(oprot); err != nil {
  273. return err
  274. }
  275. if err := oprot.WriteFieldStop(); err != nil {
  276. return fmt.Errorf("write field stop error: %s", err)
  277. }
  278. if err := oprot.WriteStructEnd(); err != nil {
  279. return fmt.Errorf("write struct stop error: %s", err)
  280. }
  281. return nil
  282. }
  283. func (p *IdipGmArgs) writeField1(oprot thrift.TProtocol) (err error) {
  284. if err := oprot.WriteFieldBegin("reserved", thrift.STRING, 1); err != nil {
  285. return fmt.Errorf("%T write field begin error 1:reserved: %s", p, err)
  286. }
  287. if err := oprot.WriteString(string(p.Reserved)); err != nil {
  288. return fmt.Errorf("%T.reserved (1) field write error: %s", p, err)
  289. }
  290. if err := oprot.WriteFieldEnd(); err != nil {
  291. return fmt.Errorf("%T write field end error 1:reserved: %s", p, err)
  292. }
  293. return err
  294. }
  295. func (p *IdipGmArgs) writeField2(oprot thrift.TProtocol) (err error) {
  296. if err := oprot.WriteFieldBegin("cmd", thrift.STRING, 2); err != nil {
  297. return fmt.Errorf("%T write field begin error 2:cmd: %s", p, err)
  298. }
  299. if err := oprot.WriteString(string(p.Cmd)); err != nil {
  300. return fmt.Errorf("%T.cmd (2) field write error: %s", p, err)
  301. }
  302. if err := oprot.WriteFieldEnd(); err != nil {
  303. return fmt.Errorf("%T write field end error 2:cmd: %s", p, err)
  304. }
  305. return err
  306. }
  307. func (p *IdipGmArgs) String() string {
  308. if p == nil {
  309. return "<nil>"
  310. }
  311. return fmt.Sprintf("IdipGmArgs(%+v)", *p)
  312. }
  313. type IdipGmResult struct {
  314. Success *Result_ `thrift:"success,0" json:"success"`
  315. Ouch *InvalidOperException `thrift:"ouch,1" json:"ouch"`
  316. }
  317. func NewIdipGmResult() *IdipGmResult {
  318. return &IdipGmResult{}
  319. }
  320. var IdipGmResult_Success_DEFAULT *Result_
  321. func (p *IdipGmResult) GetSuccess() *Result_ {
  322. if !p.IsSetSuccess() {
  323. return IdipGmResult_Success_DEFAULT
  324. }
  325. return p.Success
  326. }
  327. var IdipGmResult_Ouch_DEFAULT *InvalidOperException
  328. func (p *IdipGmResult) GetOuch() *InvalidOperException {
  329. if !p.IsSetOuch() {
  330. return IdipGmResult_Ouch_DEFAULT
  331. }
  332. return p.Ouch
  333. }
  334. func (p *IdipGmResult) IsSetSuccess() bool {
  335. return p.Success != nil
  336. }
  337. func (p *IdipGmResult) IsSetOuch() bool {
  338. return p.Ouch != nil
  339. }
  340. func (p *IdipGmResult) Read(iprot thrift.TProtocol) error {
  341. if _, err := iprot.ReadStructBegin(); err != nil {
  342. return fmt.Errorf("%T read error: %s", p, err)
  343. }
  344. for {
  345. _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
  346. if err != nil {
  347. return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
  348. }
  349. if fieldTypeId == thrift.STOP {
  350. break
  351. }
  352. switch fieldId {
  353. case 0:
  354. if err := p.ReadField0(iprot); err != nil {
  355. return err
  356. }
  357. case 1:
  358. if err := p.ReadField1(iprot); err != nil {
  359. return err
  360. }
  361. default:
  362. if err := iprot.Skip(fieldTypeId); err != nil {
  363. return err
  364. }
  365. }
  366. if err := iprot.ReadFieldEnd(); err != nil {
  367. return err
  368. }
  369. }
  370. if err := iprot.ReadStructEnd(); err != nil {
  371. return fmt.Errorf("%T read struct end error: %s", p, err)
  372. }
  373. return nil
  374. }
  375. func (p *IdipGmResult) ReadField0(iprot thrift.TProtocol) error {
  376. p.Success = &Result_{}
  377. if err := p.Success.Read(iprot); err != nil {
  378. return fmt.Errorf("%T error reading struct: %s", p.Success, err)
  379. }
  380. return nil
  381. }
  382. func (p *IdipGmResult) ReadField1(iprot thrift.TProtocol) error {
  383. p.Ouch = &InvalidOperException{}
  384. if err := p.Ouch.Read(iprot); err != nil {
  385. return fmt.Errorf("%T error reading struct: %s", p.Ouch, err)
  386. }
  387. return nil
  388. }
  389. func (p *IdipGmResult) Write(oprot thrift.TProtocol) error {
  390. if err := oprot.WriteStructBegin("idipGm_result"); err != nil {
  391. return fmt.Errorf("%T write struct begin error: %s", p, err)
  392. }
  393. if err := p.writeField0(oprot); err != nil {
  394. return err
  395. }
  396. if err := p.writeField1(oprot); err != nil {
  397. return err
  398. }
  399. if err := oprot.WriteFieldStop(); err != nil {
  400. return fmt.Errorf("write field stop error: %s", err)
  401. }
  402. if err := oprot.WriteStructEnd(); err != nil {
  403. return fmt.Errorf("write struct stop error: %s", err)
  404. }
  405. return nil
  406. }
  407. func (p *IdipGmResult) writeField0(oprot thrift.TProtocol) (err error) {
  408. if p.IsSetSuccess() {
  409. if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil {
  410. return fmt.Errorf("%T write field begin error 0:success: %s", p, err)
  411. }
  412. if err := p.Success.Write(oprot); err != nil {
  413. return fmt.Errorf("%T error writing struct: %s", p.Success, err)
  414. }
  415. if err := oprot.WriteFieldEnd(); err != nil {
  416. return fmt.Errorf("%T write field end error 0:success: %s", p, err)
  417. }
  418. }
  419. return err
  420. }
  421. func (p *IdipGmResult) writeField1(oprot thrift.TProtocol) (err error) {
  422. if p.IsSetOuch() {
  423. if err := oprot.WriteFieldBegin("ouch", thrift.STRUCT, 1); err != nil {
  424. return fmt.Errorf("%T write field begin error 1:ouch: %s", p, err)
  425. }
  426. if err := p.Ouch.Write(oprot); err != nil {
  427. return fmt.Errorf("%T error writing struct: %s", p.Ouch, err)
  428. }
  429. if err := oprot.WriteFieldEnd(); err != nil {
  430. return fmt.Errorf("%T write field end error 1:ouch: %s", p, err)
  431. }
  432. }
  433. return err
  434. }
  435. func (p *IdipGmResult) String() string {
  436. if p == nil {
  437. return "<nil>"
  438. }
  439. return fmt.Sprintf("IdipGmResult(%+v)", *p)
  440. }