baggagerestrictionmanager.go 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. // Autogenerated by Thrift Compiler (0.9.3)
  2. // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  3. package baggage
  4. import (
  5. "bytes"
  6. "fmt"
  7. "github.com/uber/jaeger-client-go/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 BaggageRestrictionManager interface {
  14. // getBaggageRestrictions retrieves the baggage restrictions for a specific service.
  15. // Usually, baggageRestrictions apply to all services however there may be situations
  16. // where a baggageKey might only be allowed to be set by a specific service.
  17. //
  18. // Parameters:
  19. // - ServiceName
  20. GetBaggageRestrictions(serviceName string) (r []*BaggageRestriction, err error)
  21. }
  22. type BaggageRestrictionManagerClient struct {
  23. Transport thrift.TTransport
  24. ProtocolFactory thrift.TProtocolFactory
  25. InputProtocol thrift.TProtocol
  26. OutputProtocol thrift.TProtocol
  27. SeqId int32
  28. }
  29. func NewBaggageRestrictionManagerClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *BaggageRestrictionManagerClient {
  30. return &BaggageRestrictionManagerClient{Transport: t,
  31. ProtocolFactory: f,
  32. InputProtocol: f.GetProtocol(t),
  33. OutputProtocol: f.GetProtocol(t),
  34. SeqId: 0,
  35. }
  36. }
  37. func NewBaggageRestrictionManagerClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *BaggageRestrictionManagerClient {
  38. return &BaggageRestrictionManagerClient{Transport: t,
  39. ProtocolFactory: nil,
  40. InputProtocol: iprot,
  41. OutputProtocol: oprot,
  42. SeqId: 0,
  43. }
  44. }
  45. // getBaggageRestrictions retrieves the baggage restrictions for a specific service.
  46. // Usually, baggageRestrictions apply to all services however there may be situations
  47. // where a baggageKey might only be allowed to be set by a specific service.
  48. //
  49. // Parameters:
  50. // - ServiceName
  51. func (p *BaggageRestrictionManagerClient) GetBaggageRestrictions(serviceName string) (r []*BaggageRestriction, err error) {
  52. if err = p.sendGetBaggageRestrictions(serviceName); err != nil {
  53. return
  54. }
  55. return p.recvGetBaggageRestrictions()
  56. }
  57. func (p *BaggageRestrictionManagerClient) sendGetBaggageRestrictions(serviceName string) (err error) {
  58. oprot := p.OutputProtocol
  59. if oprot == nil {
  60. oprot = p.ProtocolFactory.GetProtocol(p.Transport)
  61. p.OutputProtocol = oprot
  62. }
  63. p.SeqId++
  64. if err = oprot.WriteMessageBegin("getBaggageRestrictions", thrift.CALL, p.SeqId); err != nil {
  65. return
  66. }
  67. args := BaggageRestrictionManagerGetBaggageRestrictionsArgs{
  68. ServiceName: serviceName,
  69. }
  70. if err = args.Write(oprot); err != nil {
  71. return
  72. }
  73. if err = oprot.WriteMessageEnd(); err != nil {
  74. return
  75. }
  76. return oprot.Flush()
  77. }
  78. func (p *BaggageRestrictionManagerClient) recvGetBaggageRestrictions() (value []*BaggageRestriction, err error) {
  79. iprot := p.InputProtocol
  80. if iprot == nil {
  81. iprot = p.ProtocolFactory.GetProtocol(p.Transport)
  82. p.InputProtocol = iprot
  83. }
  84. method, mTypeId, seqId, err := iprot.ReadMessageBegin()
  85. if err != nil {
  86. return
  87. }
  88. if method != "getBaggageRestrictions" {
  89. err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "getBaggageRestrictions failed: wrong method name")
  90. return
  91. }
  92. if p.SeqId != seqId {
  93. err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getBaggageRestrictions failed: out of sequence response")
  94. return
  95. }
  96. if mTypeId == thrift.EXCEPTION {
  97. error0 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
  98. var error1 error
  99. error1, err = error0.Read(iprot)
  100. if err != nil {
  101. return
  102. }
  103. if err = iprot.ReadMessageEnd(); err != nil {
  104. return
  105. }
  106. err = error1
  107. return
  108. }
  109. if mTypeId != thrift.REPLY {
  110. err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "getBaggageRestrictions failed: invalid message type")
  111. return
  112. }
  113. result := BaggageRestrictionManagerGetBaggageRestrictionsResult{}
  114. if err = result.Read(iprot); err != nil {
  115. return
  116. }
  117. if err = iprot.ReadMessageEnd(); err != nil {
  118. return
  119. }
  120. value = result.GetSuccess()
  121. return
  122. }
  123. type BaggageRestrictionManagerProcessor struct {
  124. processorMap map[string]thrift.TProcessorFunction
  125. handler BaggageRestrictionManager
  126. }
  127. func (p *BaggageRestrictionManagerProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) {
  128. p.processorMap[key] = processor
  129. }
  130. func (p *BaggageRestrictionManagerProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) {
  131. processor, ok = p.processorMap[key]
  132. return processor, ok
  133. }
  134. func (p *BaggageRestrictionManagerProcessor) ProcessorMap() map[string]thrift.TProcessorFunction {
  135. return p.processorMap
  136. }
  137. func NewBaggageRestrictionManagerProcessor(handler BaggageRestrictionManager) *BaggageRestrictionManagerProcessor {
  138. self2 := &BaggageRestrictionManagerProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)}
  139. self2.processorMap["getBaggageRestrictions"] = &baggageRestrictionManagerProcessorGetBaggageRestrictions{handler: handler}
  140. return self2
  141. }
  142. func (p *BaggageRestrictionManagerProcessor) Process(iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
  143. name, _, seqId, err := iprot.ReadMessageBegin()
  144. if err != nil {
  145. return false, err
  146. }
  147. if processor, ok := p.GetProcessorFunction(name); ok {
  148. return processor.Process(seqId, iprot, oprot)
  149. }
  150. iprot.Skip(thrift.STRUCT)
  151. iprot.ReadMessageEnd()
  152. x3 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name)
  153. oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId)
  154. x3.Write(oprot)
  155. oprot.WriteMessageEnd()
  156. oprot.Flush()
  157. return false, x3
  158. }
  159. type baggageRestrictionManagerProcessorGetBaggageRestrictions struct {
  160. handler BaggageRestrictionManager
  161. }
  162. func (p *baggageRestrictionManagerProcessorGetBaggageRestrictions) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
  163. args := BaggageRestrictionManagerGetBaggageRestrictionsArgs{}
  164. if err = args.Read(iprot); err != nil {
  165. iprot.ReadMessageEnd()
  166. x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
  167. oprot.WriteMessageBegin("getBaggageRestrictions", thrift.EXCEPTION, seqId)
  168. x.Write(oprot)
  169. oprot.WriteMessageEnd()
  170. oprot.Flush()
  171. return false, err
  172. }
  173. iprot.ReadMessageEnd()
  174. result := BaggageRestrictionManagerGetBaggageRestrictionsResult{}
  175. var retval []*BaggageRestriction
  176. var err2 error
  177. if retval, err2 = p.handler.GetBaggageRestrictions(args.ServiceName); err2 != nil {
  178. x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getBaggageRestrictions: "+err2.Error())
  179. oprot.WriteMessageBegin("getBaggageRestrictions", thrift.EXCEPTION, seqId)
  180. x.Write(oprot)
  181. oprot.WriteMessageEnd()
  182. oprot.Flush()
  183. return true, err2
  184. } else {
  185. result.Success = retval
  186. }
  187. if err2 = oprot.WriteMessageBegin("getBaggageRestrictions", thrift.REPLY, seqId); err2 != nil {
  188. err = err2
  189. }
  190. if err2 = result.Write(oprot); err == nil && err2 != nil {
  191. err = err2
  192. }
  193. if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
  194. err = err2
  195. }
  196. if err2 = oprot.Flush(); err == nil && err2 != nil {
  197. err = err2
  198. }
  199. if err != nil {
  200. return
  201. }
  202. return true, err
  203. }
  204. // HELPER FUNCTIONS AND STRUCTURES
  205. // Attributes:
  206. // - ServiceName
  207. type BaggageRestrictionManagerGetBaggageRestrictionsArgs struct {
  208. ServiceName string `thrift:"serviceName,1" json:"serviceName"`
  209. }
  210. func NewBaggageRestrictionManagerGetBaggageRestrictionsArgs() *BaggageRestrictionManagerGetBaggageRestrictionsArgs {
  211. return &BaggageRestrictionManagerGetBaggageRestrictionsArgs{}
  212. }
  213. func (p *BaggageRestrictionManagerGetBaggageRestrictionsArgs) GetServiceName() string {
  214. return p.ServiceName
  215. }
  216. func (p *BaggageRestrictionManagerGetBaggageRestrictionsArgs) Read(iprot thrift.TProtocol) error {
  217. if _, err := iprot.ReadStructBegin(); err != nil {
  218. return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
  219. }
  220. for {
  221. _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
  222. if err != nil {
  223. return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
  224. }
  225. if fieldTypeId == thrift.STOP {
  226. break
  227. }
  228. switch fieldId {
  229. case 1:
  230. if err := p.readField1(iprot); err != nil {
  231. return err
  232. }
  233. default:
  234. if err := iprot.Skip(fieldTypeId); err != nil {
  235. return err
  236. }
  237. }
  238. if err := iprot.ReadFieldEnd(); err != nil {
  239. return err
  240. }
  241. }
  242. if err := iprot.ReadStructEnd(); err != nil {
  243. return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
  244. }
  245. return nil
  246. }
  247. func (p *BaggageRestrictionManagerGetBaggageRestrictionsArgs) readField1(iprot thrift.TProtocol) error {
  248. if v, err := iprot.ReadString(); err != nil {
  249. return thrift.PrependError("error reading field 1: ", err)
  250. } else {
  251. p.ServiceName = v
  252. }
  253. return nil
  254. }
  255. func (p *BaggageRestrictionManagerGetBaggageRestrictionsArgs) Write(oprot thrift.TProtocol) error {
  256. if err := oprot.WriteStructBegin("getBaggageRestrictions_args"); err != nil {
  257. return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
  258. }
  259. if err := p.writeField1(oprot); err != nil {
  260. return err
  261. }
  262. if err := oprot.WriteFieldStop(); err != nil {
  263. return thrift.PrependError("write field stop error: ", err)
  264. }
  265. if err := oprot.WriteStructEnd(); err != nil {
  266. return thrift.PrependError("write struct stop error: ", err)
  267. }
  268. return nil
  269. }
  270. func (p *BaggageRestrictionManagerGetBaggageRestrictionsArgs) writeField1(oprot thrift.TProtocol) (err error) {
  271. if err := oprot.WriteFieldBegin("serviceName", thrift.STRING, 1); err != nil {
  272. return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:serviceName: ", p), err)
  273. }
  274. if err := oprot.WriteString(string(p.ServiceName)); err != nil {
  275. return thrift.PrependError(fmt.Sprintf("%T.serviceName (1) field write error: ", p), err)
  276. }
  277. if err := oprot.WriteFieldEnd(); err != nil {
  278. return thrift.PrependError(fmt.Sprintf("%T write field end error 1:serviceName: ", p), err)
  279. }
  280. return err
  281. }
  282. func (p *BaggageRestrictionManagerGetBaggageRestrictionsArgs) String() string {
  283. if p == nil {
  284. return "<nil>"
  285. }
  286. return fmt.Sprintf("BaggageRestrictionManagerGetBaggageRestrictionsArgs(%+v)", *p)
  287. }
  288. // Attributes:
  289. // - Success
  290. type BaggageRestrictionManagerGetBaggageRestrictionsResult struct {
  291. Success []*BaggageRestriction `thrift:"success,0" json:"success,omitempty"`
  292. }
  293. func NewBaggageRestrictionManagerGetBaggageRestrictionsResult() *BaggageRestrictionManagerGetBaggageRestrictionsResult {
  294. return &BaggageRestrictionManagerGetBaggageRestrictionsResult{}
  295. }
  296. var BaggageRestrictionManagerGetBaggageRestrictionsResult_Success_DEFAULT []*BaggageRestriction
  297. func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) GetSuccess() []*BaggageRestriction {
  298. return p.Success
  299. }
  300. func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) IsSetSuccess() bool {
  301. return p.Success != nil
  302. }
  303. func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) Read(iprot thrift.TProtocol) error {
  304. if _, err := iprot.ReadStructBegin(); err != nil {
  305. return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
  306. }
  307. for {
  308. _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
  309. if err != nil {
  310. return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
  311. }
  312. if fieldTypeId == thrift.STOP {
  313. break
  314. }
  315. switch fieldId {
  316. case 0:
  317. if err := p.readField0(iprot); err != nil {
  318. return err
  319. }
  320. default:
  321. if err := iprot.Skip(fieldTypeId); err != nil {
  322. return err
  323. }
  324. }
  325. if err := iprot.ReadFieldEnd(); err != nil {
  326. return err
  327. }
  328. }
  329. if err := iprot.ReadStructEnd(); err != nil {
  330. return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
  331. }
  332. return nil
  333. }
  334. func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) readField0(iprot thrift.TProtocol) error {
  335. _, size, err := iprot.ReadListBegin()
  336. if err != nil {
  337. return thrift.PrependError("error reading list begin: ", err)
  338. }
  339. tSlice := make([]*BaggageRestriction, 0, size)
  340. p.Success = tSlice
  341. for i := 0; i < size; i++ {
  342. _elem4 := &BaggageRestriction{}
  343. if err := _elem4.Read(iprot); err != nil {
  344. return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem4), err)
  345. }
  346. p.Success = append(p.Success, _elem4)
  347. }
  348. if err := iprot.ReadListEnd(); err != nil {
  349. return thrift.PrependError("error reading list end: ", err)
  350. }
  351. return nil
  352. }
  353. func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) Write(oprot thrift.TProtocol) error {
  354. if err := oprot.WriteStructBegin("getBaggageRestrictions_result"); err != nil {
  355. return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
  356. }
  357. if err := p.writeField0(oprot); err != nil {
  358. return err
  359. }
  360. if err := oprot.WriteFieldStop(); err != nil {
  361. return thrift.PrependError("write field stop error: ", err)
  362. }
  363. if err := oprot.WriteStructEnd(); err != nil {
  364. return thrift.PrependError("write struct stop error: ", err)
  365. }
  366. return nil
  367. }
  368. func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) writeField0(oprot thrift.TProtocol) (err error) {
  369. if p.IsSetSuccess() {
  370. if err := oprot.WriteFieldBegin("success", thrift.LIST, 0); err != nil {
  371. return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err)
  372. }
  373. if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Success)); err != nil {
  374. return thrift.PrependError("error writing list begin: ", err)
  375. }
  376. for _, v := range p.Success {
  377. if err := v.Write(oprot); err != nil {
  378. return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err)
  379. }
  380. }
  381. if err := oprot.WriteListEnd(); err != nil {
  382. return thrift.PrependError("error writing list end: ", err)
  383. }
  384. if err := oprot.WriteFieldEnd(); err != nil {
  385. return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err)
  386. }
  387. }
  388. return err
  389. }
  390. func (p *BaggageRestrictionManagerGetBaggageRestrictionsResult) String() string {
  391. if p == nil {
  392. return "<nil>"
  393. }
  394. return fmt.Sprintf("BaggageRestrictionManagerGetBaggageRestrictionsResult(%+v)", *p)
  395. }