spec091.go 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306
  1. // Copyright (c) 2012, Sean Treadway, SoundCloud Ltd.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Source code and contact info at http://github.com/streadway/amqp
  5. /* GENERATED FILE - DO NOT EDIT */
  6. /* Rebuild from the spec/gen.go tool */
  7. package amqp
  8. import (
  9. "encoding/binary"
  10. "fmt"
  11. "io"
  12. )
  13. // Error codes that can be sent from the server during a connection or
  14. // channel exception or used by the client to indicate a class of error like
  15. // ErrCredentials. The text of the error is likely more interesting than
  16. // these constants.
  17. const (
  18. frameMethod = 1
  19. frameHeader = 2
  20. frameBody = 3
  21. frameHeartbeat = 8
  22. frameMinSize = 4096
  23. frameEnd = 206
  24. replySuccess = 200
  25. ContentTooLarge = 311
  26. NoRoute = 312
  27. NoConsumers = 313
  28. ConnectionForced = 320
  29. InvalidPath = 402
  30. AccessRefused = 403
  31. NotFound = 404
  32. ResourceLocked = 405
  33. PreconditionFailed = 406
  34. FrameError = 501
  35. SyntaxError = 502
  36. CommandInvalid = 503
  37. ChannelError = 504
  38. UnexpectedFrame = 505
  39. ResourceError = 506
  40. NotAllowed = 530
  41. NotImplemented = 540
  42. InternalError = 541
  43. )
  44. func isSoftExceptionCode(code int) bool {
  45. switch code {
  46. case 311:
  47. return true
  48. case 312:
  49. return true
  50. case 313:
  51. return true
  52. case 403:
  53. return true
  54. case 404:
  55. return true
  56. case 405:
  57. return true
  58. case 406:
  59. return true
  60. }
  61. return false
  62. }
  63. type connectionStart struct {
  64. VersionMajor byte
  65. VersionMinor byte
  66. ServerProperties Table
  67. Mechanisms string
  68. Locales string
  69. }
  70. func (me *connectionStart) id() (uint16, uint16) {
  71. return 10, 10
  72. }
  73. func (me *connectionStart) wait() bool {
  74. return true
  75. }
  76. func (me *connectionStart) write(w io.Writer) (err error) {
  77. if err = binary.Write(w, binary.BigEndian, me.VersionMajor); err != nil {
  78. return
  79. }
  80. if err = binary.Write(w, binary.BigEndian, me.VersionMinor); err != nil {
  81. return
  82. }
  83. if err = writeTable(w, me.ServerProperties); err != nil {
  84. return
  85. }
  86. if err = writeLongstr(w, me.Mechanisms); err != nil {
  87. return
  88. }
  89. if err = writeLongstr(w, me.Locales); err != nil {
  90. return
  91. }
  92. return
  93. }
  94. func (me *connectionStart) read(r io.Reader) (err error) {
  95. if err = binary.Read(r, binary.BigEndian, &me.VersionMajor); err != nil {
  96. return
  97. }
  98. if err = binary.Read(r, binary.BigEndian, &me.VersionMinor); err != nil {
  99. return
  100. }
  101. if me.ServerProperties, err = readTable(r); err != nil {
  102. return
  103. }
  104. if me.Mechanisms, err = readLongstr(r); err != nil {
  105. return
  106. }
  107. if me.Locales, err = readLongstr(r); err != nil {
  108. return
  109. }
  110. return
  111. }
  112. type connectionStartOk struct {
  113. ClientProperties Table
  114. Mechanism string
  115. Response string
  116. Locale string
  117. }
  118. func (me *connectionStartOk) id() (uint16, uint16) {
  119. return 10, 11
  120. }
  121. func (me *connectionStartOk) wait() bool {
  122. return true
  123. }
  124. func (me *connectionStartOk) write(w io.Writer) (err error) {
  125. if err = writeTable(w, me.ClientProperties); err != nil {
  126. return
  127. }
  128. if err = writeShortstr(w, me.Mechanism); err != nil {
  129. return
  130. }
  131. if err = writeLongstr(w, me.Response); err != nil {
  132. return
  133. }
  134. if err = writeShortstr(w, me.Locale); err != nil {
  135. return
  136. }
  137. return
  138. }
  139. func (me *connectionStartOk) read(r io.Reader) (err error) {
  140. if me.ClientProperties, err = readTable(r); err != nil {
  141. return
  142. }
  143. if me.Mechanism, err = readShortstr(r); err != nil {
  144. return
  145. }
  146. if me.Response, err = readLongstr(r); err != nil {
  147. return
  148. }
  149. if me.Locale, err = readShortstr(r); err != nil {
  150. return
  151. }
  152. return
  153. }
  154. type connectionSecure struct {
  155. Challenge string
  156. }
  157. func (me *connectionSecure) id() (uint16, uint16) {
  158. return 10, 20
  159. }
  160. func (me *connectionSecure) wait() bool {
  161. return true
  162. }
  163. func (me *connectionSecure) write(w io.Writer) (err error) {
  164. if err = writeLongstr(w, me.Challenge); err != nil {
  165. return
  166. }
  167. return
  168. }
  169. func (me *connectionSecure) read(r io.Reader) (err error) {
  170. if me.Challenge, err = readLongstr(r); err != nil {
  171. return
  172. }
  173. return
  174. }
  175. type connectionSecureOk struct {
  176. Response string
  177. }
  178. func (me *connectionSecureOk) id() (uint16, uint16) {
  179. return 10, 21
  180. }
  181. func (me *connectionSecureOk) wait() bool {
  182. return true
  183. }
  184. func (me *connectionSecureOk) write(w io.Writer) (err error) {
  185. if err = writeLongstr(w, me.Response); err != nil {
  186. return
  187. }
  188. return
  189. }
  190. func (me *connectionSecureOk) read(r io.Reader) (err error) {
  191. if me.Response, err = readLongstr(r); err != nil {
  192. return
  193. }
  194. return
  195. }
  196. type connectionTune struct {
  197. ChannelMax uint16
  198. FrameMax uint32
  199. Heartbeat uint16
  200. }
  201. func (me *connectionTune) id() (uint16, uint16) {
  202. return 10, 30
  203. }
  204. func (me *connectionTune) wait() bool {
  205. return true
  206. }
  207. func (me *connectionTune) write(w io.Writer) (err error) {
  208. if err = binary.Write(w, binary.BigEndian, me.ChannelMax); err != nil {
  209. return
  210. }
  211. if err = binary.Write(w, binary.BigEndian, me.FrameMax); err != nil {
  212. return
  213. }
  214. if err = binary.Write(w, binary.BigEndian, me.Heartbeat); err != nil {
  215. return
  216. }
  217. return
  218. }
  219. func (me *connectionTune) read(r io.Reader) (err error) {
  220. if err = binary.Read(r, binary.BigEndian, &me.ChannelMax); err != nil {
  221. return
  222. }
  223. if err = binary.Read(r, binary.BigEndian, &me.FrameMax); err != nil {
  224. return
  225. }
  226. if err = binary.Read(r, binary.BigEndian, &me.Heartbeat); err != nil {
  227. return
  228. }
  229. return
  230. }
  231. type connectionTuneOk struct {
  232. ChannelMax uint16
  233. FrameMax uint32
  234. Heartbeat uint16
  235. }
  236. func (me *connectionTuneOk) id() (uint16, uint16) {
  237. return 10, 31
  238. }
  239. func (me *connectionTuneOk) wait() bool {
  240. return true
  241. }
  242. func (me *connectionTuneOk) write(w io.Writer) (err error) {
  243. if err = binary.Write(w, binary.BigEndian, me.ChannelMax); err != nil {
  244. return
  245. }
  246. if err = binary.Write(w, binary.BigEndian, me.FrameMax); err != nil {
  247. return
  248. }
  249. if err = binary.Write(w, binary.BigEndian, me.Heartbeat); err != nil {
  250. return
  251. }
  252. return
  253. }
  254. func (me *connectionTuneOk) read(r io.Reader) (err error) {
  255. if err = binary.Read(r, binary.BigEndian, &me.ChannelMax); err != nil {
  256. return
  257. }
  258. if err = binary.Read(r, binary.BigEndian, &me.FrameMax); err != nil {
  259. return
  260. }
  261. if err = binary.Read(r, binary.BigEndian, &me.Heartbeat); err != nil {
  262. return
  263. }
  264. return
  265. }
  266. type connectionOpen struct {
  267. VirtualHost string
  268. reserved1 string
  269. reserved2 bool
  270. }
  271. func (me *connectionOpen) id() (uint16, uint16) {
  272. return 10, 40
  273. }
  274. func (me *connectionOpen) wait() bool {
  275. return true
  276. }
  277. func (me *connectionOpen) write(w io.Writer) (err error) {
  278. var bits byte
  279. if err = writeShortstr(w, me.VirtualHost); err != nil {
  280. return
  281. }
  282. if err = writeShortstr(w, me.reserved1); err != nil {
  283. return
  284. }
  285. if me.reserved2 {
  286. bits |= 1 << 0
  287. }
  288. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  289. return
  290. }
  291. return
  292. }
  293. func (me *connectionOpen) read(r io.Reader) (err error) {
  294. var bits byte
  295. if me.VirtualHost, err = readShortstr(r); err != nil {
  296. return
  297. }
  298. if me.reserved1, err = readShortstr(r); err != nil {
  299. return
  300. }
  301. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  302. return
  303. }
  304. me.reserved2 = (bits&(1<<0) > 0)
  305. return
  306. }
  307. type connectionOpenOk struct {
  308. reserved1 string
  309. }
  310. func (me *connectionOpenOk) id() (uint16, uint16) {
  311. return 10, 41
  312. }
  313. func (me *connectionOpenOk) wait() bool {
  314. return true
  315. }
  316. func (me *connectionOpenOk) write(w io.Writer) (err error) {
  317. if err = writeShortstr(w, me.reserved1); err != nil {
  318. return
  319. }
  320. return
  321. }
  322. func (me *connectionOpenOk) read(r io.Reader) (err error) {
  323. if me.reserved1, err = readShortstr(r); err != nil {
  324. return
  325. }
  326. return
  327. }
  328. type connectionClose struct {
  329. ReplyCode uint16
  330. ReplyText string
  331. ClassId uint16
  332. MethodId uint16
  333. }
  334. func (me *connectionClose) id() (uint16, uint16) {
  335. return 10, 50
  336. }
  337. func (me *connectionClose) wait() bool {
  338. return true
  339. }
  340. func (me *connectionClose) write(w io.Writer) (err error) {
  341. if err = binary.Write(w, binary.BigEndian, me.ReplyCode); err != nil {
  342. return
  343. }
  344. if err = writeShortstr(w, me.ReplyText); err != nil {
  345. return
  346. }
  347. if err = binary.Write(w, binary.BigEndian, me.ClassId); err != nil {
  348. return
  349. }
  350. if err = binary.Write(w, binary.BigEndian, me.MethodId); err != nil {
  351. return
  352. }
  353. return
  354. }
  355. func (me *connectionClose) read(r io.Reader) (err error) {
  356. if err = binary.Read(r, binary.BigEndian, &me.ReplyCode); err != nil {
  357. return
  358. }
  359. if me.ReplyText, err = readShortstr(r); err != nil {
  360. return
  361. }
  362. if err = binary.Read(r, binary.BigEndian, &me.ClassId); err != nil {
  363. return
  364. }
  365. if err = binary.Read(r, binary.BigEndian, &me.MethodId); err != nil {
  366. return
  367. }
  368. return
  369. }
  370. type connectionCloseOk struct {
  371. }
  372. func (me *connectionCloseOk) id() (uint16, uint16) {
  373. return 10, 51
  374. }
  375. func (me *connectionCloseOk) wait() bool {
  376. return true
  377. }
  378. func (me *connectionCloseOk) write(w io.Writer) (err error) {
  379. return
  380. }
  381. func (me *connectionCloseOk) read(r io.Reader) (err error) {
  382. return
  383. }
  384. type connectionBlocked struct {
  385. Reason string
  386. }
  387. func (me *connectionBlocked) id() (uint16, uint16) {
  388. return 10, 60
  389. }
  390. func (me *connectionBlocked) wait() bool {
  391. return false
  392. }
  393. func (me *connectionBlocked) write(w io.Writer) (err error) {
  394. if err = writeShortstr(w, me.Reason); err != nil {
  395. return
  396. }
  397. return
  398. }
  399. func (me *connectionBlocked) read(r io.Reader) (err error) {
  400. if me.Reason, err = readShortstr(r); err != nil {
  401. return
  402. }
  403. return
  404. }
  405. type connectionUnblocked struct {
  406. }
  407. func (me *connectionUnblocked) id() (uint16, uint16) {
  408. return 10, 61
  409. }
  410. func (me *connectionUnblocked) wait() bool {
  411. return false
  412. }
  413. func (me *connectionUnblocked) write(w io.Writer) (err error) {
  414. return
  415. }
  416. func (me *connectionUnblocked) read(r io.Reader) (err error) {
  417. return
  418. }
  419. type channelOpen struct {
  420. reserved1 string
  421. }
  422. func (me *channelOpen) id() (uint16, uint16) {
  423. return 20, 10
  424. }
  425. func (me *channelOpen) wait() bool {
  426. return true
  427. }
  428. func (me *channelOpen) write(w io.Writer) (err error) {
  429. if err = writeShortstr(w, me.reserved1); err != nil {
  430. return
  431. }
  432. return
  433. }
  434. func (me *channelOpen) read(r io.Reader) (err error) {
  435. if me.reserved1, err = readShortstr(r); err != nil {
  436. return
  437. }
  438. return
  439. }
  440. type channelOpenOk struct {
  441. reserved1 string
  442. }
  443. func (me *channelOpenOk) id() (uint16, uint16) {
  444. return 20, 11
  445. }
  446. func (me *channelOpenOk) wait() bool {
  447. return true
  448. }
  449. func (me *channelOpenOk) write(w io.Writer) (err error) {
  450. if err = writeLongstr(w, me.reserved1); err != nil {
  451. return
  452. }
  453. return
  454. }
  455. func (me *channelOpenOk) read(r io.Reader) (err error) {
  456. if me.reserved1, err = readLongstr(r); err != nil {
  457. return
  458. }
  459. return
  460. }
  461. type channelFlow struct {
  462. Active bool
  463. }
  464. func (me *channelFlow) id() (uint16, uint16) {
  465. return 20, 20
  466. }
  467. func (me *channelFlow) wait() bool {
  468. return true
  469. }
  470. func (me *channelFlow) write(w io.Writer) (err error) {
  471. var bits byte
  472. if me.Active {
  473. bits |= 1 << 0
  474. }
  475. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  476. return
  477. }
  478. return
  479. }
  480. func (me *channelFlow) read(r io.Reader) (err error) {
  481. var bits byte
  482. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  483. return
  484. }
  485. me.Active = (bits&(1<<0) > 0)
  486. return
  487. }
  488. type channelFlowOk struct {
  489. Active bool
  490. }
  491. func (me *channelFlowOk) id() (uint16, uint16) {
  492. return 20, 21
  493. }
  494. func (me *channelFlowOk) wait() bool {
  495. return false
  496. }
  497. func (me *channelFlowOk) write(w io.Writer) (err error) {
  498. var bits byte
  499. if me.Active {
  500. bits |= 1 << 0
  501. }
  502. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  503. return
  504. }
  505. return
  506. }
  507. func (me *channelFlowOk) read(r io.Reader) (err error) {
  508. var bits byte
  509. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  510. return
  511. }
  512. me.Active = (bits&(1<<0) > 0)
  513. return
  514. }
  515. type channelClose struct {
  516. ReplyCode uint16
  517. ReplyText string
  518. ClassId uint16
  519. MethodId uint16
  520. }
  521. func (me *channelClose) id() (uint16, uint16) {
  522. return 20, 40
  523. }
  524. func (me *channelClose) wait() bool {
  525. return true
  526. }
  527. func (me *channelClose) write(w io.Writer) (err error) {
  528. if err = binary.Write(w, binary.BigEndian, me.ReplyCode); err != nil {
  529. return
  530. }
  531. if err = writeShortstr(w, me.ReplyText); err != nil {
  532. return
  533. }
  534. if err = binary.Write(w, binary.BigEndian, me.ClassId); err != nil {
  535. return
  536. }
  537. if err = binary.Write(w, binary.BigEndian, me.MethodId); err != nil {
  538. return
  539. }
  540. return
  541. }
  542. func (me *channelClose) read(r io.Reader) (err error) {
  543. if err = binary.Read(r, binary.BigEndian, &me.ReplyCode); err != nil {
  544. return
  545. }
  546. if me.ReplyText, err = readShortstr(r); err != nil {
  547. return
  548. }
  549. if err = binary.Read(r, binary.BigEndian, &me.ClassId); err != nil {
  550. return
  551. }
  552. if err = binary.Read(r, binary.BigEndian, &me.MethodId); err != nil {
  553. return
  554. }
  555. return
  556. }
  557. type channelCloseOk struct {
  558. }
  559. func (me *channelCloseOk) id() (uint16, uint16) {
  560. return 20, 41
  561. }
  562. func (me *channelCloseOk) wait() bool {
  563. return true
  564. }
  565. func (me *channelCloseOk) write(w io.Writer) (err error) {
  566. return
  567. }
  568. func (me *channelCloseOk) read(r io.Reader) (err error) {
  569. return
  570. }
  571. type exchangeDeclare struct {
  572. reserved1 uint16
  573. Exchange string
  574. Type string
  575. Passive bool
  576. Durable bool
  577. AutoDelete bool
  578. Internal bool
  579. NoWait bool
  580. Arguments Table
  581. }
  582. func (me *exchangeDeclare) id() (uint16, uint16) {
  583. return 40, 10
  584. }
  585. func (me *exchangeDeclare) wait() bool {
  586. return true && !me.NoWait
  587. }
  588. func (me *exchangeDeclare) write(w io.Writer) (err error) {
  589. var bits byte
  590. if err = binary.Write(w, binary.BigEndian, me.reserved1); err != nil {
  591. return
  592. }
  593. if err = writeShortstr(w, me.Exchange); err != nil {
  594. return
  595. }
  596. if err = writeShortstr(w, me.Type); err != nil {
  597. return
  598. }
  599. if me.Passive {
  600. bits |= 1 << 0
  601. }
  602. if me.Durable {
  603. bits |= 1 << 1
  604. }
  605. if me.AutoDelete {
  606. bits |= 1 << 2
  607. }
  608. if me.Internal {
  609. bits |= 1 << 3
  610. }
  611. if me.NoWait {
  612. bits |= 1 << 4
  613. }
  614. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  615. return
  616. }
  617. if err = writeTable(w, me.Arguments); err != nil {
  618. return
  619. }
  620. return
  621. }
  622. func (me *exchangeDeclare) read(r io.Reader) (err error) {
  623. var bits byte
  624. if err = binary.Read(r, binary.BigEndian, &me.reserved1); err != nil {
  625. return
  626. }
  627. if me.Exchange, err = readShortstr(r); err != nil {
  628. return
  629. }
  630. if me.Type, err = readShortstr(r); err != nil {
  631. return
  632. }
  633. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  634. return
  635. }
  636. me.Passive = (bits&(1<<0) > 0)
  637. me.Durable = (bits&(1<<1) > 0)
  638. me.AutoDelete = (bits&(1<<2) > 0)
  639. me.Internal = (bits&(1<<3) > 0)
  640. me.NoWait = (bits&(1<<4) > 0)
  641. if me.Arguments, err = readTable(r); err != nil {
  642. return
  643. }
  644. return
  645. }
  646. type exchangeDeclareOk struct {
  647. }
  648. func (me *exchangeDeclareOk) id() (uint16, uint16) {
  649. return 40, 11
  650. }
  651. func (me *exchangeDeclareOk) wait() bool {
  652. return true
  653. }
  654. func (me *exchangeDeclareOk) write(w io.Writer) (err error) {
  655. return
  656. }
  657. func (me *exchangeDeclareOk) read(r io.Reader) (err error) {
  658. return
  659. }
  660. type exchangeDelete struct {
  661. reserved1 uint16
  662. Exchange string
  663. IfUnused bool
  664. NoWait bool
  665. }
  666. func (me *exchangeDelete) id() (uint16, uint16) {
  667. return 40, 20
  668. }
  669. func (me *exchangeDelete) wait() bool {
  670. return true && !me.NoWait
  671. }
  672. func (me *exchangeDelete) write(w io.Writer) (err error) {
  673. var bits byte
  674. if err = binary.Write(w, binary.BigEndian, me.reserved1); err != nil {
  675. return
  676. }
  677. if err = writeShortstr(w, me.Exchange); err != nil {
  678. return
  679. }
  680. if me.IfUnused {
  681. bits |= 1 << 0
  682. }
  683. if me.NoWait {
  684. bits |= 1 << 1
  685. }
  686. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  687. return
  688. }
  689. return
  690. }
  691. func (me *exchangeDelete) read(r io.Reader) (err error) {
  692. var bits byte
  693. if err = binary.Read(r, binary.BigEndian, &me.reserved1); err != nil {
  694. return
  695. }
  696. if me.Exchange, err = readShortstr(r); err != nil {
  697. return
  698. }
  699. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  700. return
  701. }
  702. me.IfUnused = (bits&(1<<0) > 0)
  703. me.NoWait = (bits&(1<<1) > 0)
  704. return
  705. }
  706. type exchangeDeleteOk struct {
  707. }
  708. func (me *exchangeDeleteOk) id() (uint16, uint16) {
  709. return 40, 21
  710. }
  711. func (me *exchangeDeleteOk) wait() bool {
  712. return true
  713. }
  714. func (me *exchangeDeleteOk) write(w io.Writer) (err error) {
  715. return
  716. }
  717. func (me *exchangeDeleteOk) read(r io.Reader) (err error) {
  718. return
  719. }
  720. type exchangeBind struct {
  721. reserved1 uint16
  722. Destination string
  723. Source string
  724. RoutingKey string
  725. NoWait bool
  726. Arguments Table
  727. }
  728. func (me *exchangeBind) id() (uint16, uint16) {
  729. return 40, 30
  730. }
  731. func (me *exchangeBind) wait() bool {
  732. return true && !me.NoWait
  733. }
  734. func (me *exchangeBind) write(w io.Writer) (err error) {
  735. var bits byte
  736. if err = binary.Write(w, binary.BigEndian, me.reserved1); err != nil {
  737. return
  738. }
  739. if err = writeShortstr(w, me.Destination); err != nil {
  740. return
  741. }
  742. if err = writeShortstr(w, me.Source); err != nil {
  743. return
  744. }
  745. if err = writeShortstr(w, me.RoutingKey); err != nil {
  746. return
  747. }
  748. if me.NoWait {
  749. bits |= 1 << 0
  750. }
  751. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  752. return
  753. }
  754. if err = writeTable(w, me.Arguments); err != nil {
  755. return
  756. }
  757. return
  758. }
  759. func (me *exchangeBind) read(r io.Reader) (err error) {
  760. var bits byte
  761. if err = binary.Read(r, binary.BigEndian, &me.reserved1); err != nil {
  762. return
  763. }
  764. if me.Destination, err = readShortstr(r); err != nil {
  765. return
  766. }
  767. if me.Source, err = readShortstr(r); err != nil {
  768. return
  769. }
  770. if me.RoutingKey, err = readShortstr(r); err != nil {
  771. return
  772. }
  773. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  774. return
  775. }
  776. me.NoWait = (bits&(1<<0) > 0)
  777. if me.Arguments, err = readTable(r); err != nil {
  778. return
  779. }
  780. return
  781. }
  782. type exchangeBindOk struct {
  783. }
  784. func (me *exchangeBindOk) id() (uint16, uint16) {
  785. return 40, 31
  786. }
  787. func (me *exchangeBindOk) wait() bool {
  788. return true
  789. }
  790. func (me *exchangeBindOk) write(w io.Writer) (err error) {
  791. return
  792. }
  793. func (me *exchangeBindOk) read(r io.Reader) (err error) {
  794. return
  795. }
  796. type exchangeUnbind struct {
  797. reserved1 uint16
  798. Destination string
  799. Source string
  800. RoutingKey string
  801. NoWait bool
  802. Arguments Table
  803. }
  804. func (me *exchangeUnbind) id() (uint16, uint16) {
  805. return 40, 40
  806. }
  807. func (me *exchangeUnbind) wait() bool {
  808. return true && !me.NoWait
  809. }
  810. func (me *exchangeUnbind) write(w io.Writer) (err error) {
  811. var bits byte
  812. if err = binary.Write(w, binary.BigEndian, me.reserved1); err != nil {
  813. return
  814. }
  815. if err = writeShortstr(w, me.Destination); err != nil {
  816. return
  817. }
  818. if err = writeShortstr(w, me.Source); err != nil {
  819. return
  820. }
  821. if err = writeShortstr(w, me.RoutingKey); err != nil {
  822. return
  823. }
  824. if me.NoWait {
  825. bits |= 1 << 0
  826. }
  827. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  828. return
  829. }
  830. if err = writeTable(w, me.Arguments); err != nil {
  831. return
  832. }
  833. return
  834. }
  835. func (me *exchangeUnbind) read(r io.Reader) (err error) {
  836. var bits byte
  837. if err = binary.Read(r, binary.BigEndian, &me.reserved1); err != nil {
  838. return
  839. }
  840. if me.Destination, err = readShortstr(r); err != nil {
  841. return
  842. }
  843. if me.Source, err = readShortstr(r); err != nil {
  844. return
  845. }
  846. if me.RoutingKey, err = readShortstr(r); err != nil {
  847. return
  848. }
  849. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  850. return
  851. }
  852. me.NoWait = (bits&(1<<0) > 0)
  853. if me.Arguments, err = readTable(r); err != nil {
  854. return
  855. }
  856. return
  857. }
  858. type exchangeUnbindOk struct {
  859. }
  860. func (me *exchangeUnbindOk) id() (uint16, uint16) {
  861. return 40, 51
  862. }
  863. func (me *exchangeUnbindOk) wait() bool {
  864. return true
  865. }
  866. func (me *exchangeUnbindOk) write(w io.Writer) (err error) {
  867. return
  868. }
  869. func (me *exchangeUnbindOk) read(r io.Reader) (err error) {
  870. return
  871. }
  872. type queueDeclare struct {
  873. reserved1 uint16
  874. Queue string
  875. Passive bool
  876. Durable bool
  877. Exclusive bool
  878. AutoDelete bool
  879. NoWait bool
  880. Arguments Table
  881. }
  882. func (me *queueDeclare) id() (uint16, uint16) {
  883. return 50, 10
  884. }
  885. func (me *queueDeclare) wait() bool {
  886. return true && !me.NoWait
  887. }
  888. func (me *queueDeclare) write(w io.Writer) (err error) {
  889. var bits byte
  890. if err = binary.Write(w, binary.BigEndian, me.reserved1); err != nil {
  891. return
  892. }
  893. if err = writeShortstr(w, me.Queue); err != nil {
  894. return
  895. }
  896. if me.Passive {
  897. bits |= 1 << 0
  898. }
  899. if me.Durable {
  900. bits |= 1 << 1
  901. }
  902. if me.Exclusive {
  903. bits |= 1 << 2
  904. }
  905. if me.AutoDelete {
  906. bits |= 1 << 3
  907. }
  908. if me.NoWait {
  909. bits |= 1 << 4
  910. }
  911. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  912. return
  913. }
  914. if err = writeTable(w, me.Arguments); err != nil {
  915. return
  916. }
  917. return
  918. }
  919. func (me *queueDeclare) read(r io.Reader) (err error) {
  920. var bits byte
  921. if err = binary.Read(r, binary.BigEndian, &me.reserved1); err != nil {
  922. return
  923. }
  924. if me.Queue, err = readShortstr(r); err != nil {
  925. return
  926. }
  927. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  928. return
  929. }
  930. me.Passive = (bits&(1<<0) > 0)
  931. me.Durable = (bits&(1<<1) > 0)
  932. me.Exclusive = (bits&(1<<2) > 0)
  933. me.AutoDelete = (bits&(1<<3) > 0)
  934. me.NoWait = (bits&(1<<4) > 0)
  935. if me.Arguments, err = readTable(r); err != nil {
  936. return
  937. }
  938. return
  939. }
  940. type queueDeclareOk struct {
  941. Queue string
  942. MessageCount uint32
  943. ConsumerCount uint32
  944. }
  945. func (me *queueDeclareOk) id() (uint16, uint16) {
  946. return 50, 11
  947. }
  948. func (me *queueDeclareOk) wait() bool {
  949. return true
  950. }
  951. func (me *queueDeclareOk) write(w io.Writer) (err error) {
  952. if err = writeShortstr(w, me.Queue); err != nil {
  953. return
  954. }
  955. if err = binary.Write(w, binary.BigEndian, me.MessageCount); err != nil {
  956. return
  957. }
  958. if err = binary.Write(w, binary.BigEndian, me.ConsumerCount); err != nil {
  959. return
  960. }
  961. return
  962. }
  963. func (me *queueDeclareOk) read(r io.Reader) (err error) {
  964. if me.Queue, err = readShortstr(r); err != nil {
  965. return
  966. }
  967. if err = binary.Read(r, binary.BigEndian, &me.MessageCount); err != nil {
  968. return
  969. }
  970. if err = binary.Read(r, binary.BigEndian, &me.ConsumerCount); err != nil {
  971. return
  972. }
  973. return
  974. }
  975. type queueBind struct {
  976. reserved1 uint16
  977. Queue string
  978. Exchange string
  979. RoutingKey string
  980. NoWait bool
  981. Arguments Table
  982. }
  983. func (me *queueBind) id() (uint16, uint16) {
  984. return 50, 20
  985. }
  986. func (me *queueBind) wait() bool {
  987. return true && !me.NoWait
  988. }
  989. func (me *queueBind) write(w io.Writer) (err error) {
  990. var bits byte
  991. if err = binary.Write(w, binary.BigEndian, me.reserved1); err != nil {
  992. return
  993. }
  994. if err = writeShortstr(w, me.Queue); err != nil {
  995. return
  996. }
  997. if err = writeShortstr(w, me.Exchange); err != nil {
  998. return
  999. }
  1000. if err = writeShortstr(w, me.RoutingKey); err != nil {
  1001. return
  1002. }
  1003. if me.NoWait {
  1004. bits |= 1 << 0
  1005. }
  1006. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  1007. return
  1008. }
  1009. if err = writeTable(w, me.Arguments); err != nil {
  1010. return
  1011. }
  1012. return
  1013. }
  1014. func (me *queueBind) read(r io.Reader) (err error) {
  1015. var bits byte
  1016. if err = binary.Read(r, binary.BigEndian, &me.reserved1); err != nil {
  1017. return
  1018. }
  1019. if me.Queue, err = readShortstr(r); err != nil {
  1020. return
  1021. }
  1022. if me.Exchange, err = readShortstr(r); err != nil {
  1023. return
  1024. }
  1025. if me.RoutingKey, err = readShortstr(r); err != nil {
  1026. return
  1027. }
  1028. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  1029. return
  1030. }
  1031. me.NoWait = (bits&(1<<0) > 0)
  1032. if me.Arguments, err = readTable(r); err != nil {
  1033. return
  1034. }
  1035. return
  1036. }
  1037. type queueBindOk struct {
  1038. }
  1039. func (me *queueBindOk) id() (uint16, uint16) {
  1040. return 50, 21
  1041. }
  1042. func (me *queueBindOk) wait() bool {
  1043. return true
  1044. }
  1045. func (me *queueBindOk) write(w io.Writer) (err error) {
  1046. return
  1047. }
  1048. func (me *queueBindOk) read(r io.Reader) (err error) {
  1049. return
  1050. }
  1051. type queueUnbind struct {
  1052. reserved1 uint16
  1053. Queue string
  1054. Exchange string
  1055. RoutingKey string
  1056. Arguments Table
  1057. }
  1058. func (me *queueUnbind) id() (uint16, uint16) {
  1059. return 50, 50
  1060. }
  1061. func (me *queueUnbind) wait() bool {
  1062. return true
  1063. }
  1064. func (me *queueUnbind) write(w io.Writer) (err error) {
  1065. if err = binary.Write(w, binary.BigEndian, me.reserved1); err != nil {
  1066. return
  1067. }
  1068. if err = writeShortstr(w, me.Queue); err != nil {
  1069. return
  1070. }
  1071. if err = writeShortstr(w, me.Exchange); err != nil {
  1072. return
  1073. }
  1074. if err = writeShortstr(w, me.RoutingKey); err != nil {
  1075. return
  1076. }
  1077. if err = writeTable(w, me.Arguments); err != nil {
  1078. return
  1079. }
  1080. return
  1081. }
  1082. func (me *queueUnbind) read(r io.Reader) (err error) {
  1083. if err = binary.Read(r, binary.BigEndian, &me.reserved1); err != nil {
  1084. return
  1085. }
  1086. if me.Queue, err = readShortstr(r); err != nil {
  1087. return
  1088. }
  1089. if me.Exchange, err = readShortstr(r); err != nil {
  1090. return
  1091. }
  1092. if me.RoutingKey, err = readShortstr(r); err != nil {
  1093. return
  1094. }
  1095. if me.Arguments, err = readTable(r); err != nil {
  1096. return
  1097. }
  1098. return
  1099. }
  1100. type queueUnbindOk struct {
  1101. }
  1102. func (me *queueUnbindOk) id() (uint16, uint16) {
  1103. return 50, 51
  1104. }
  1105. func (me *queueUnbindOk) wait() bool {
  1106. return true
  1107. }
  1108. func (me *queueUnbindOk) write(w io.Writer) (err error) {
  1109. return
  1110. }
  1111. func (me *queueUnbindOk) read(r io.Reader) (err error) {
  1112. return
  1113. }
  1114. type queuePurge struct {
  1115. reserved1 uint16
  1116. Queue string
  1117. NoWait bool
  1118. }
  1119. func (me *queuePurge) id() (uint16, uint16) {
  1120. return 50, 30
  1121. }
  1122. func (me *queuePurge) wait() bool {
  1123. return true && !me.NoWait
  1124. }
  1125. func (me *queuePurge) write(w io.Writer) (err error) {
  1126. var bits byte
  1127. if err = binary.Write(w, binary.BigEndian, me.reserved1); err != nil {
  1128. return
  1129. }
  1130. if err = writeShortstr(w, me.Queue); err != nil {
  1131. return
  1132. }
  1133. if me.NoWait {
  1134. bits |= 1 << 0
  1135. }
  1136. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  1137. return
  1138. }
  1139. return
  1140. }
  1141. func (me *queuePurge) read(r io.Reader) (err error) {
  1142. var bits byte
  1143. if err = binary.Read(r, binary.BigEndian, &me.reserved1); err != nil {
  1144. return
  1145. }
  1146. if me.Queue, err = readShortstr(r); err != nil {
  1147. return
  1148. }
  1149. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  1150. return
  1151. }
  1152. me.NoWait = (bits&(1<<0) > 0)
  1153. return
  1154. }
  1155. type queuePurgeOk struct {
  1156. MessageCount uint32
  1157. }
  1158. func (me *queuePurgeOk) id() (uint16, uint16) {
  1159. return 50, 31
  1160. }
  1161. func (me *queuePurgeOk) wait() bool {
  1162. return true
  1163. }
  1164. func (me *queuePurgeOk) write(w io.Writer) (err error) {
  1165. if err = binary.Write(w, binary.BigEndian, me.MessageCount); err != nil {
  1166. return
  1167. }
  1168. return
  1169. }
  1170. func (me *queuePurgeOk) read(r io.Reader) (err error) {
  1171. if err = binary.Read(r, binary.BigEndian, &me.MessageCount); err != nil {
  1172. return
  1173. }
  1174. return
  1175. }
  1176. type queueDelete struct {
  1177. reserved1 uint16
  1178. Queue string
  1179. IfUnused bool
  1180. IfEmpty bool
  1181. NoWait bool
  1182. }
  1183. func (me *queueDelete) id() (uint16, uint16) {
  1184. return 50, 40
  1185. }
  1186. func (me *queueDelete) wait() bool {
  1187. return true && !me.NoWait
  1188. }
  1189. func (me *queueDelete) write(w io.Writer) (err error) {
  1190. var bits byte
  1191. if err = binary.Write(w, binary.BigEndian, me.reserved1); err != nil {
  1192. return
  1193. }
  1194. if err = writeShortstr(w, me.Queue); err != nil {
  1195. return
  1196. }
  1197. if me.IfUnused {
  1198. bits |= 1 << 0
  1199. }
  1200. if me.IfEmpty {
  1201. bits |= 1 << 1
  1202. }
  1203. if me.NoWait {
  1204. bits |= 1 << 2
  1205. }
  1206. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  1207. return
  1208. }
  1209. return
  1210. }
  1211. func (me *queueDelete) read(r io.Reader) (err error) {
  1212. var bits byte
  1213. if err = binary.Read(r, binary.BigEndian, &me.reserved1); err != nil {
  1214. return
  1215. }
  1216. if me.Queue, err = readShortstr(r); err != nil {
  1217. return
  1218. }
  1219. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  1220. return
  1221. }
  1222. me.IfUnused = (bits&(1<<0) > 0)
  1223. me.IfEmpty = (bits&(1<<1) > 0)
  1224. me.NoWait = (bits&(1<<2) > 0)
  1225. return
  1226. }
  1227. type queueDeleteOk struct {
  1228. MessageCount uint32
  1229. }
  1230. func (me *queueDeleteOk) id() (uint16, uint16) {
  1231. return 50, 41
  1232. }
  1233. func (me *queueDeleteOk) wait() bool {
  1234. return true
  1235. }
  1236. func (me *queueDeleteOk) write(w io.Writer) (err error) {
  1237. if err = binary.Write(w, binary.BigEndian, me.MessageCount); err != nil {
  1238. return
  1239. }
  1240. return
  1241. }
  1242. func (me *queueDeleteOk) read(r io.Reader) (err error) {
  1243. if err = binary.Read(r, binary.BigEndian, &me.MessageCount); err != nil {
  1244. return
  1245. }
  1246. return
  1247. }
  1248. type basicQos struct {
  1249. PrefetchSize uint32
  1250. PrefetchCount uint16
  1251. Global bool
  1252. }
  1253. func (me *basicQos) id() (uint16, uint16) {
  1254. return 60, 10
  1255. }
  1256. func (me *basicQos) wait() bool {
  1257. return true
  1258. }
  1259. func (me *basicQos) write(w io.Writer) (err error) {
  1260. var bits byte
  1261. if err = binary.Write(w, binary.BigEndian, me.PrefetchSize); err != nil {
  1262. return
  1263. }
  1264. if err = binary.Write(w, binary.BigEndian, me.PrefetchCount); err != nil {
  1265. return
  1266. }
  1267. if me.Global {
  1268. bits |= 1 << 0
  1269. }
  1270. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  1271. return
  1272. }
  1273. return
  1274. }
  1275. func (me *basicQos) read(r io.Reader) (err error) {
  1276. var bits byte
  1277. if err = binary.Read(r, binary.BigEndian, &me.PrefetchSize); err != nil {
  1278. return
  1279. }
  1280. if err = binary.Read(r, binary.BigEndian, &me.PrefetchCount); err != nil {
  1281. return
  1282. }
  1283. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  1284. return
  1285. }
  1286. me.Global = (bits&(1<<0) > 0)
  1287. return
  1288. }
  1289. type basicQosOk struct {
  1290. }
  1291. func (me *basicQosOk) id() (uint16, uint16) {
  1292. return 60, 11
  1293. }
  1294. func (me *basicQosOk) wait() bool {
  1295. return true
  1296. }
  1297. func (me *basicQosOk) write(w io.Writer) (err error) {
  1298. return
  1299. }
  1300. func (me *basicQosOk) read(r io.Reader) (err error) {
  1301. return
  1302. }
  1303. type basicConsume struct {
  1304. reserved1 uint16
  1305. Queue string
  1306. ConsumerTag string
  1307. NoLocal bool
  1308. NoAck bool
  1309. Exclusive bool
  1310. NoWait bool
  1311. Arguments Table
  1312. }
  1313. func (me *basicConsume) id() (uint16, uint16) {
  1314. return 60, 20
  1315. }
  1316. func (me *basicConsume) wait() bool {
  1317. return true && !me.NoWait
  1318. }
  1319. func (me *basicConsume) write(w io.Writer) (err error) {
  1320. var bits byte
  1321. if err = binary.Write(w, binary.BigEndian, me.reserved1); err != nil {
  1322. return
  1323. }
  1324. if err = writeShortstr(w, me.Queue); err != nil {
  1325. return
  1326. }
  1327. if err = writeShortstr(w, me.ConsumerTag); err != nil {
  1328. return
  1329. }
  1330. if me.NoLocal {
  1331. bits |= 1 << 0
  1332. }
  1333. if me.NoAck {
  1334. bits |= 1 << 1
  1335. }
  1336. if me.Exclusive {
  1337. bits |= 1 << 2
  1338. }
  1339. if me.NoWait {
  1340. bits |= 1 << 3
  1341. }
  1342. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  1343. return
  1344. }
  1345. if err = writeTable(w, me.Arguments); err != nil {
  1346. return
  1347. }
  1348. return
  1349. }
  1350. func (me *basicConsume) read(r io.Reader) (err error) {
  1351. var bits byte
  1352. if err = binary.Read(r, binary.BigEndian, &me.reserved1); err != nil {
  1353. return
  1354. }
  1355. if me.Queue, err = readShortstr(r); err != nil {
  1356. return
  1357. }
  1358. if me.ConsumerTag, err = readShortstr(r); err != nil {
  1359. return
  1360. }
  1361. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  1362. return
  1363. }
  1364. me.NoLocal = (bits&(1<<0) > 0)
  1365. me.NoAck = (bits&(1<<1) > 0)
  1366. me.Exclusive = (bits&(1<<2) > 0)
  1367. me.NoWait = (bits&(1<<3) > 0)
  1368. if me.Arguments, err = readTable(r); err != nil {
  1369. return
  1370. }
  1371. return
  1372. }
  1373. type basicConsumeOk struct {
  1374. ConsumerTag string
  1375. }
  1376. func (me *basicConsumeOk) id() (uint16, uint16) {
  1377. return 60, 21
  1378. }
  1379. func (me *basicConsumeOk) wait() bool {
  1380. return true
  1381. }
  1382. func (me *basicConsumeOk) write(w io.Writer) (err error) {
  1383. if err = writeShortstr(w, me.ConsumerTag); err != nil {
  1384. return
  1385. }
  1386. return
  1387. }
  1388. func (me *basicConsumeOk) read(r io.Reader) (err error) {
  1389. if me.ConsumerTag, err = readShortstr(r); err != nil {
  1390. return
  1391. }
  1392. return
  1393. }
  1394. type basicCancel struct {
  1395. ConsumerTag string
  1396. NoWait bool
  1397. }
  1398. func (me *basicCancel) id() (uint16, uint16) {
  1399. return 60, 30
  1400. }
  1401. func (me *basicCancel) wait() bool {
  1402. return true && !me.NoWait
  1403. }
  1404. func (me *basicCancel) write(w io.Writer) (err error) {
  1405. var bits byte
  1406. if err = writeShortstr(w, me.ConsumerTag); err != nil {
  1407. return
  1408. }
  1409. if me.NoWait {
  1410. bits |= 1 << 0
  1411. }
  1412. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  1413. return
  1414. }
  1415. return
  1416. }
  1417. func (me *basicCancel) read(r io.Reader) (err error) {
  1418. var bits byte
  1419. if me.ConsumerTag, err = readShortstr(r); err != nil {
  1420. return
  1421. }
  1422. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  1423. return
  1424. }
  1425. me.NoWait = (bits&(1<<0) > 0)
  1426. return
  1427. }
  1428. type basicCancelOk struct {
  1429. ConsumerTag string
  1430. }
  1431. func (me *basicCancelOk) id() (uint16, uint16) {
  1432. return 60, 31
  1433. }
  1434. func (me *basicCancelOk) wait() bool {
  1435. return true
  1436. }
  1437. func (me *basicCancelOk) write(w io.Writer) (err error) {
  1438. if err = writeShortstr(w, me.ConsumerTag); err != nil {
  1439. return
  1440. }
  1441. return
  1442. }
  1443. func (me *basicCancelOk) read(r io.Reader) (err error) {
  1444. if me.ConsumerTag, err = readShortstr(r); err != nil {
  1445. return
  1446. }
  1447. return
  1448. }
  1449. type basicPublish struct {
  1450. reserved1 uint16
  1451. Exchange string
  1452. RoutingKey string
  1453. Mandatory bool
  1454. Immediate bool
  1455. Properties properties
  1456. Body []byte
  1457. }
  1458. func (me *basicPublish) id() (uint16, uint16) {
  1459. return 60, 40
  1460. }
  1461. func (me *basicPublish) wait() bool {
  1462. return false
  1463. }
  1464. func (me *basicPublish) getContent() (properties, []byte) {
  1465. return me.Properties, me.Body
  1466. }
  1467. func (me *basicPublish) setContent(props properties, body []byte) {
  1468. me.Properties, me.Body = props, body
  1469. }
  1470. func (me *basicPublish) write(w io.Writer) (err error) {
  1471. var bits byte
  1472. if err = binary.Write(w, binary.BigEndian, me.reserved1); err != nil {
  1473. return
  1474. }
  1475. if err = writeShortstr(w, me.Exchange); err != nil {
  1476. return
  1477. }
  1478. if err = writeShortstr(w, me.RoutingKey); err != nil {
  1479. return
  1480. }
  1481. if me.Mandatory {
  1482. bits |= 1 << 0
  1483. }
  1484. if me.Immediate {
  1485. bits |= 1 << 1
  1486. }
  1487. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  1488. return
  1489. }
  1490. return
  1491. }
  1492. func (me *basicPublish) read(r io.Reader) (err error) {
  1493. var bits byte
  1494. if err = binary.Read(r, binary.BigEndian, &me.reserved1); err != nil {
  1495. return
  1496. }
  1497. if me.Exchange, err = readShortstr(r); err != nil {
  1498. return
  1499. }
  1500. if me.RoutingKey, err = readShortstr(r); err != nil {
  1501. return
  1502. }
  1503. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  1504. return
  1505. }
  1506. me.Mandatory = (bits&(1<<0) > 0)
  1507. me.Immediate = (bits&(1<<1) > 0)
  1508. return
  1509. }
  1510. type basicReturn struct {
  1511. ReplyCode uint16
  1512. ReplyText string
  1513. Exchange string
  1514. RoutingKey string
  1515. Properties properties
  1516. Body []byte
  1517. }
  1518. func (me *basicReturn) id() (uint16, uint16) {
  1519. return 60, 50
  1520. }
  1521. func (me *basicReturn) wait() bool {
  1522. return false
  1523. }
  1524. func (me *basicReturn) getContent() (properties, []byte) {
  1525. return me.Properties, me.Body
  1526. }
  1527. func (me *basicReturn) setContent(props properties, body []byte) {
  1528. me.Properties, me.Body = props, body
  1529. }
  1530. func (me *basicReturn) write(w io.Writer) (err error) {
  1531. if err = binary.Write(w, binary.BigEndian, me.ReplyCode); err != nil {
  1532. return
  1533. }
  1534. if err = writeShortstr(w, me.ReplyText); err != nil {
  1535. return
  1536. }
  1537. if err = writeShortstr(w, me.Exchange); err != nil {
  1538. return
  1539. }
  1540. if err = writeShortstr(w, me.RoutingKey); err != nil {
  1541. return
  1542. }
  1543. return
  1544. }
  1545. func (me *basicReturn) read(r io.Reader) (err error) {
  1546. if err = binary.Read(r, binary.BigEndian, &me.ReplyCode); err != nil {
  1547. return
  1548. }
  1549. if me.ReplyText, err = readShortstr(r); err != nil {
  1550. return
  1551. }
  1552. if me.Exchange, err = readShortstr(r); err != nil {
  1553. return
  1554. }
  1555. if me.RoutingKey, err = readShortstr(r); err != nil {
  1556. return
  1557. }
  1558. return
  1559. }
  1560. type basicDeliver struct {
  1561. ConsumerTag string
  1562. DeliveryTag uint64
  1563. Redelivered bool
  1564. Exchange string
  1565. RoutingKey string
  1566. Properties properties
  1567. Body []byte
  1568. }
  1569. func (me *basicDeliver) id() (uint16, uint16) {
  1570. return 60, 60
  1571. }
  1572. func (me *basicDeliver) wait() bool {
  1573. return false
  1574. }
  1575. func (me *basicDeliver) getContent() (properties, []byte) {
  1576. return me.Properties, me.Body
  1577. }
  1578. func (me *basicDeliver) setContent(props properties, body []byte) {
  1579. me.Properties, me.Body = props, body
  1580. }
  1581. func (me *basicDeliver) write(w io.Writer) (err error) {
  1582. var bits byte
  1583. if err = writeShortstr(w, me.ConsumerTag); err != nil {
  1584. return
  1585. }
  1586. if err = binary.Write(w, binary.BigEndian, me.DeliveryTag); err != nil {
  1587. return
  1588. }
  1589. if me.Redelivered {
  1590. bits |= 1 << 0
  1591. }
  1592. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  1593. return
  1594. }
  1595. if err = writeShortstr(w, me.Exchange); err != nil {
  1596. return
  1597. }
  1598. if err = writeShortstr(w, me.RoutingKey); err != nil {
  1599. return
  1600. }
  1601. return
  1602. }
  1603. func (me *basicDeliver) read(r io.Reader) (err error) {
  1604. var bits byte
  1605. if me.ConsumerTag, err = readShortstr(r); err != nil {
  1606. return
  1607. }
  1608. if err = binary.Read(r, binary.BigEndian, &me.DeliveryTag); err != nil {
  1609. return
  1610. }
  1611. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  1612. return
  1613. }
  1614. me.Redelivered = (bits&(1<<0) > 0)
  1615. if me.Exchange, err = readShortstr(r); err != nil {
  1616. return
  1617. }
  1618. if me.RoutingKey, err = readShortstr(r); err != nil {
  1619. return
  1620. }
  1621. return
  1622. }
  1623. type basicGet struct {
  1624. reserved1 uint16
  1625. Queue string
  1626. NoAck bool
  1627. }
  1628. func (me *basicGet) id() (uint16, uint16) {
  1629. return 60, 70
  1630. }
  1631. func (me *basicGet) wait() bool {
  1632. return true
  1633. }
  1634. func (me *basicGet) write(w io.Writer) (err error) {
  1635. var bits byte
  1636. if err = binary.Write(w, binary.BigEndian, me.reserved1); err != nil {
  1637. return
  1638. }
  1639. if err = writeShortstr(w, me.Queue); err != nil {
  1640. return
  1641. }
  1642. if me.NoAck {
  1643. bits |= 1 << 0
  1644. }
  1645. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  1646. return
  1647. }
  1648. return
  1649. }
  1650. func (me *basicGet) read(r io.Reader) (err error) {
  1651. var bits byte
  1652. if err = binary.Read(r, binary.BigEndian, &me.reserved1); err != nil {
  1653. return
  1654. }
  1655. if me.Queue, err = readShortstr(r); err != nil {
  1656. return
  1657. }
  1658. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  1659. return
  1660. }
  1661. me.NoAck = (bits&(1<<0) > 0)
  1662. return
  1663. }
  1664. type basicGetOk struct {
  1665. DeliveryTag uint64
  1666. Redelivered bool
  1667. Exchange string
  1668. RoutingKey string
  1669. MessageCount uint32
  1670. Properties properties
  1671. Body []byte
  1672. }
  1673. func (me *basicGetOk) id() (uint16, uint16) {
  1674. return 60, 71
  1675. }
  1676. func (me *basicGetOk) wait() bool {
  1677. return true
  1678. }
  1679. func (me *basicGetOk) getContent() (properties, []byte) {
  1680. return me.Properties, me.Body
  1681. }
  1682. func (me *basicGetOk) setContent(props properties, body []byte) {
  1683. me.Properties, me.Body = props, body
  1684. }
  1685. func (me *basicGetOk) write(w io.Writer) (err error) {
  1686. var bits byte
  1687. if err = binary.Write(w, binary.BigEndian, me.DeliveryTag); err != nil {
  1688. return
  1689. }
  1690. if me.Redelivered {
  1691. bits |= 1 << 0
  1692. }
  1693. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  1694. return
  1695. }
  1696. if err = writeShortstr(w, me.Exchange); err != nil {
  1697. return
  1698. }
  1699. if err = writeShortstr(w, me.RoutingKey); err != nil {
  1700. return
  1701. }
  1702. if err = binary.Write(w, binary.BigEndian, me.MessageCount); err != nil {
  1703. return
  1704. }
  1705. return
  1706. }
  1707. func (me *basicGetOk) read(r io.Reader) (err error) {
  1708. var bits byte
  1709. if err = binary.Read(r, binary.BigEndian, &me.DeliveryTag); err != nil {
  1710. return
  1711. }
  1712. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  1713. return
  1714. }
  1715. me.Redelivered = (bits&(1<<0) > 0)
  1716. if me.Exchange, err = readShortstr(r); err != nil {
  1717. return
  1718. }
  1719. if me.RoutingKey, err = readShortstr(r); err != nil {
  1720. return
  1721. }
  1722. if err = binary.Read(r, binary.BigEndian, &me.MessageCount); err != nil {
  1723. return
  1724. }
  1725. return
  1726. }
  1727. type basicGetEmpty struct {
  1728. reserved1 string
  1729. }
  1730. func (me *basicGetEmpty) id() (uint16, uint16) {
  1731. return 60, 72
  1732. }
  1733. func (me *basicGetEmpty) wait() bool {
  1734. return true
  1735. }
  1736. func (me *basicGetEmpty) write(w io.Writer) (err error) {
  1737. if err = writeShortstr(w, me.reserved1); err != nil {
  1738. return
  1739. }
  1740. return
  1741. }
  1742. func (me *basicGetEmpty) read(r io.Reader) (err error) {
  1743. if me.reserved1, err = readShortstr(r); err != nil {
  1744. return
  1745. }
  1746. return
  1747. }
  1748. type basicAck struct {
  1749. DeliveryTag uint64
  1750. Multiple bool
  1751. }
  1752. func (me *basicAck) id() (uint16, uint16) {
  1753. return 60, 80
  1754. }
  1755. func (me *basicAck) wait() bool {
  1756. return false
  1757. }
  1758. func (me *basicAck) write(w io.Writer) (err error) {
  1759. var bits byte
  1760. if err = binary.Write(w, binary.BigEndian, me.DeliveryTag); err != nil {
  1761. return
  1762. }
  1763. if me.Multiple {
  1764. bits |= 1 << 0
  1765. }
  1766. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  1767. return
  1768. }
  1769. return
  1770. }
  1771. func (me *basicAck) read(r io.Reader) (err error) {
  1772. var bits byte
  1773. if err = binary.Read(r, binary.BigEndian, &me.DeliveryTag); err != nil {
  1774. return
  1775. }
  1776. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  1777. return
  1778. }
  1779. me.Multiple = (bits&(1<<0) > 0)
  1780. return
  1781. }
  1782. type basicReject struct {
  1783. DeliveryTag uint64
  1784. Requeue bool
  1785. }
  1786. func (me *basicReject) id() (uint16, uint16) {
  1787. return 60, 90
  1788. }
  1789. func (me *basicReject) wait() bool {
  1790. return false
  1791. }
  1792. func (me *basicReject) write(w io.Writer) (err error) {
  1793. var bits byte
  1794. if err = binary.Write(w, binary.BigEndian, me.DeliveryTag); err != nil {
  1795. return
  1796. }
  1797. if me.Requeue {
  1798. bits |= 1 << 0
  1799. }
  1800. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  1801. return
  1802. }
  1803. return
  1804. }
  1805. func (me *basicReject) read(r io.Reader) (err error) {
  1806. var bits byte
  1807. if err = binary.Read(r, binary.BigEndian, &me.DeliveryTag); err != nil {
  1808. return
  1809. }
  1810. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  1811. return
  1812. }
  1813. me.Requeue = (bits&(1<<0) > 0)
  1814. return
  1815. }
  1816. type basicRecoverAsync struct {
  1817. Requeue bool
  1818. }
  1819. func (me *basicRecoverAsync) id() (uint16, uint16) {
  1820. return 60, 100
  1821. }
  1822. func (me *basicRecoverAsync) wait() bool {
  1823. return false
  1824. }
  1825. func (me *basicRecoverAsync) write(w io.Writer) (err error) {
  1826. var bits byte
  1827. if me.Requeue {
  1828. bits |= 1 << 0
  1829. }
  1830. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  1831. return
  1832. }
  1833. return
  1834. }
  1835. func (me *basicRecoverAsync) read(r io.Reader) (err error) {
  1836. var bits byte
  1837. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  1838. return
  1839. }
  1840. me.Requeue = (bits&(1<<0) > 0)
  1841. return
  1842. }
  1843. type basicRecover struct {
  1844. Requeue bool
  1845. }
  1846. func (me *basicRecover) id() (uint16, uint16) {
  1847. return 60, 110
  1848. }
  1849. func (me *basicRecover) wait() bool {
  1850. return true
  1851. }
  1852. func (me *basicRecover) write(w io.Writer) (err error) {
  1853. var bits byte
  1854. if me.Requeue {
  1855. bits |= 1 << 0
  1856. }
  1857. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  1858. return
  1859. }
  1860. return
  1861. }
  1862. func (me *basicRecover) read(r io.Reader) (err error) {
  1863. var bits byte
  1864. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  1865. return
  1866. }
  1867. me.Requeue = (bits&(1<<0) > 0)
  1868. return
  1869. }
  1870. type basicRecoverOk struct {
  1871. }
  1872. func (me *basicRecoverOk) id() (uint16, uint16) {
  1873. return 60, 111
  1874. }
  1875. func (me *basicRecoverOk) wait() bool {
  1876. return true
  1877. }
  1878. func (me *basicRecoverOk) write(w io.Writer) (err error) {
  1879. return
  1880. }
  1881. func (me *basicRecoverOk) read(r io.Reader) (err error) {
  1882. return
  1883. }
  1884. type basicNack struct {
  1885. DeliveryTag uint64
  1886. Multiple bool
  1887. Requeue bool
  1888. }
  1889. func (me *basicNack) id() (uint16, uint16) {
  1890. return 60, 120
  1891. }
  1892. func (me *basicNack) wait() bool {
  1893. return false
  1894. }
  1895. func (me *basicNack) write(w io.Writer) (err error) {
  1896. var bits byte
  1897. if err = binary.Write(w, binary.BigEndian, me.DeliveryTag); err != nil {
  1898. return
  1899. }
  1900. if me.Multiple {
  1901. bits |= 1 << 0
  1902. }
  1903. if me.Requeue {
  1904. bits |= 1 << 1
  1905. }
  1906. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  1907. return
  1908. }
  1909. return
  1910. }
  1911. func (me *basicNack) read(r io.Reader) (err error) {
  1912. var bits byte
  1913. if err = binary.Read(r, binary.BigEndian, &me.DeliveryTag); err != nil {
  1914. return
  1915. }
  1916. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  1917. return
  1918. }
  1919. me.Multiple = (bits&(1<<0) > 0)
  1920. me.Requeue = (bits&(1<<1) > 0)
  1921. return
  1922. }
  1923. type txSelect struct {
  1924. }
  1925. func (me *txSelect) id() (uint16, uint16) {
  1926. return 90, 10
  1927. }
  1928. func (me *txSelect) wait() bool {
  1929. return true
  1930. }
  1931. func (me *txSelect) write(w io.Writer) (err error) {
  1932. return
  1933. }
  1934. func (me *txSelect) read(r io.Reader) (err error) {
  1935. return
  1936. }
  1937. type txSelectOk struct {
  1938. }
  1939. func (me *txSelectOk) id() (uint16, uint16) {
  1940. return 90, 11
  1941. }
  1942. func (me *txSelectOk) wait() bool {
  1943. return true
  1944. }
  1945. func (me *txSelectOk) write(w io.Writer) (err error) {
  1946. return
  1947. }
  1948. func (me *txSelectOk) read(r io.Reader) (err error) {
  1949. return
  1950. }
  1951. type txCommit struct {
  1952. }
  1953. func (me *txCommit) id() (uint16, uint16) {
  1954. return 90, 20
  1955. }
  1956. func (me *txCommit) wait() bool {
  1957. return true
  1958. }
  1959. func (me *txCommit) write(w io.Writer) (err error) {
  1960. return
  1961. }
  1962. func (me *txCommit) read(r io.Reader) (err error) {
  1963. return
  1964. }
  1965. type txCommitOk struct {
  1966. }
  1967. func (me *txCommitOk) id() (uint16, uint16) {
  1968. return 90, 21
  1969. }
  1970. func (me *txCommitOk) wait() bool {
  1971. return true
  1972. }
  1973. func (me *txCommitOk) write(w io.Writer) (err error) {
  1974. return
  1975. }
  1976. func (me *txCommitOk) read(r io.Reader) (err error) {
  1977. return
  1978. }
  1979. type txRollback struct {
  1980. }
  1981. func (me *txRollback) id() (uint16, uint16) {
  1982. return 90, 30
  1983. }
  1984. func (me *txRollback) wait() bool {
  1985. return true
  1986. }
  1987. func (me *txRollback) write(w io.Writer) (err error) {
  1988. return
  1989. }
  1990. func (me *txRollback) read(r io.Reader) (err error) {
  1991. return
  1992. }
  1993. type txRollbackOk struct {
  1994. }
  1995. func (me *txRollbackOk) id() (uint16, uint16) {
  1996. return 90, 31
  1997. }
  1998. func (me *txRollbackOk) wait() bool {
  1999. return true
  2000. }
  2001. func (me *txRollbackOk) write(w io.Writer) (err error) {
  2002. return
  2003. }
  2004. func (me *txRollbackOk) read(r io.Reader) (err error) {
  2005. return
  2006. }
  2007. type confirmSelect struct {
  2008. Nowait bool
  2009. }
  2010. func (me *confirmSelect) id() (uint16, uint16) {
  2011. return 85, 10
  2012. }
  2013. func (me *confirmSelect) wait() bool {
  2014. return true
  2015. }
  2016. func (me *confirmSelect) write(w io.Writer) (err error) {
  2017. var bits byte
  2018. if me.Nowait {
  2019. bits |= 1 << 0
  2020. }
  2021. if err = binary.Write(w, binary.BigEndian, bits); err != nil {
  2022. return
  2023. }
  2024. return
  2025. }
  2026. func (me *confirmSelect) read(r io.Reader) (err error) {
  2027. var bits byte
  2028. if err = binary.Read(r, binary.BigEndian, &bits); err != nil {
  2029. return
  2030. }
  2031. me.Nowait = (bits&(1<<0) > 0)
  2032. return
  2033. }
  2034. type confirmSelectOk struct {
  2035. }
  2036. func (me *confirmSelectOk) id() (uint16, uint16) {
  2037. return 85, 11
  2038. }
  2039. func (me *confirmSelectOk) wait() bool {
  2040. return true
  2041. }
  2042. func (me *confirmSelectOk) write(w io.Writer) (err error) {
  2043. return
  2044. }
  2045. func (me *confirmSelectOk) read(r io.Reader) (err error) {
  2046. return
  2047. }
  2048. func (me *reader) parseMethodFrame(channel uint16, size uint32) (f frame, err error) {
  2049. mf := &methodFrame{
  2050. ChannelId: channel,
  2051. }
  2052. if err = binary.Read(me.r, binary.BigEndian, &mf.ClassId); err != nil {
  2053. return
  2054. }
  2055. if err = binary.Read(me.r, binary.BigEndian, &mf.MethodId); err != nil {
  2056. return
  2057. }
  2058. switch mf.ClassId {
  2059. case 10: // connection
  2060. switch mf.MethodId {
  2061. case 10: // connection start
  2062. //fmt.Println("NextMethod: class:10 method:10")
  2063. method := &connectionStart{}
  2064. if err = method.read(me.r); err != nil {
  2065. return
  2066. }
  2067. mf.Method = method
  2068. case 11: // connection start-ok
  2069. //fmt.Println("NextMethod: class:10 method:11")
  2070. method := &connectionStartOk{}
  2071. if err = method.read(me.r); err != nil {
  2072. return
  2073. }
  2074. mf.Method = method
  2075. case 20: // connection secure
  2076. //fmt.Println("NextMethod: class:10 method:20")
  2077. method := &connectionSecure{}
  2078. if err = method.read(me.r); err != nil {
  2079. return
  2080. }
  2081. mf.Method = method
  2082. case 21: // connection secure-ok
  2083. //fmt.Println("NextMethod: class:10 method:21")
  2084. method := &connectionSecureOk{}
  2085. if err = method.read(me.r); err != nil {
  2086. return
  2087. }
  2088. mf.Method = method
  2089. case 30: // connection tune
  2090. //fmt.Println("NextMethod: class:10 method:30")
  2091. method := &connectionTune{}
  2092. if err = method.read(me.r); err != nil {
  2093. return
  2094. }
  2095. mf.Method = method
  2096. case 31: // connection tune-ok
  2097. //fmt.Println("NextMethod: class:10 method:31")
  2098. method := &connectionTuneOk{}
  2099. if err = method.read(me.r); err != nil {
  2100. return
  2101. }
  2102. mf.Method = method
  2103. case 40: // connection open
  2104. //fmt.Println("NextMethod: class:10 method:40")
  2105. method := &connectionOpen{}
  2106. if err = method.read(me.r); err != nil {
  2107. return
  2108. }
  2109. mf.Method = method
  2110. case 41: // connection open-ok
  2111. //fmt.Println("NextMethod: class:10 method:41")
  2112. method := &connectionOpenOk{}
  2113. if err = method.read(me.r); err != nil {
  2114. return
  2115. }
  2116. mf.Method = method
  2117. case 50: // connection close
  2118. //fmt.Println("NextMethod: class:10 method:50")
  2119. method := &connectionClose{}
  2120. if err = method.read(me.r); err != nil {
  2121. return
  2122. }
  2123. mf.Method = method
  2124. case 51: // connection close-ok
  2125. //fmt.Println("NextMethod: class:10 method:51")
  2126. method := &connectionCloseOk{}
  2127. if err = method.read(me.r); err != nil {
  2128. return
  2129. }
  2130. mf.Method = method
  2131. case 60: // connection blocked
  2132. //fmt.Println("NextMethod: class:10 method:60")
  2133. method := &connectionBlocked{}
  2134. if err = method.read(me.r); err != nil {
  2135. return
  2136. }
  2137. mf.Method = method
  2138. case 61: // connection unblocked
  2139. //fmt.Println("NextMethod: class:10 method:61")
  2140. method := &connectionUnblocked{}
  2141. if err = method.read(me.r); err != nil {
  2142. return
  2143. }
  2144. mf.Method = method
  2145. default:
  2146. return nil, fmt.Errorf("Bad method frame, unknown method %d for class %d", mf.MethodId, mf.ClassId)
  2147. }
  2148. case 20: // channel
  2149. switch mf.MethodId {
  2150. case 10: // channel open
  2151. //fmt.Println("NextMethod: class:20 method:10")
  2152. method := &channelOpen{}
  2153. if err = method.read(me.r); err != nil {
  2154. return
  2155. }
  2156. mf.Method = method
  2157. case 11: // channel open-ok
  2158. //fmt.Println("NextMethod: class:20 method:11")
  2159. method := &channelOpenOk{}
  2160. if err = method.read(me.r); err != nil {
  2161. return
  2162. }
  2163. mf.Method = method
  2164. case 20: // channel flow
  2165. //fmt.Println("NextMethod: class:20 method:20")
  2166. method := &channelFlow{}
  2167. if err = method.read(me.r); err != nil {
  2168. return
  2169. }
  2170. mf.Method = method
  2171. case 21: // channel flow-ok
  2172. //fmt.Println("NextMethod: class:20 method:21")
  2173. method := &channelFlowOk{}
  2174. if err = method.read(me.r); err != nil {
  2175. return
  2176. }
  2177. mf.Method = method
  2178. case 40: // channel close
  2179. //fmt.Println("NextMethod: class:20 method:40")
  2180. method := &channelClose{}
  2181. if err = method.read(me.r); err != nil {
  2182. return
  2183. }
  2184. mf.Method = method
  2185. case 41: // channel close-ok
  2186. //fmt.Println("NextMethod: class:20 method:41")
  2187. method := &channelCloseOk{}
  2188. if err = method.read(me.r); err != nil {
  2189. return
  2190. }
  2191. mf.Method = method
  2192. default:
  2193. return nil, fmt.Errorf("Bad method frame, unknown method %d for class %d", mf.MethodId, mf.ClassId)
  2194. }
  2195. case 40: // exchange
  2196. switch mf.MethodId {
  2197. case 10: // exchange declare
  2198. //fmt.Println("NextMethod: class:40 method:10")
  2199. method := &exchangeDeclare{}
  2200. if err = method.read(me.r); err != nil {
  2201. return
  2202. }
  2203. mf.Method = method
  2204. case 11: // exchange declare-ok
  2205. //fmt.Println("NextMethod: class:40 method:11")
  2206. method := &exchangeDeclareOk{}
  2207. if err = method.read(me.r); err != nil {
  2208. return
  2209. }
  2210. mf.Method = method
  2211. case 20: // exchange delete
  2212. //fmt.Println("NextMethod: class:40 method:20")
  2213. method := &exchangeDelete{}
  2214. if err = method.read(me.r); err != nil {
  2215. return
  2216. }
  2217. mf.Method = method
  2218. case 21: // exchange delete-ok
  2219. //fmt.Println("NextMethod: class:40 method:21")
  2220. method := &exchangeDeleteOk{}
  2221. if err = method.read(me.r); err != nil {
  2222. return
  2223. }
  2224. mf.Method = method
  2225. case 30: // exchange bind
  2226. //fmt.Println("NextMethod: class:40 method:30")
  2227. method := &exchangeBind{}
  2228. if err = method.read(me.r); err != nil {
  2229. return
  2230. }
  2231. mf.Method = method
  2232. case 31: // exchange bind-ok
  2233. //fmt.Println("NextMethod: class:40 method:31")
  2234. method := &exchangeBindOk{}
  2235. if err = method.read(me.r); err != nil {
  2236. return
  2237. }
  2238. mf.Method = method
  2239. case 40: // exchange unbind
  2240. //fmt.Println("NextMethod: class:40 method:40")
  2241. method := &exchangeUnbind{}
  2242. if err = method.read(me.r); err != nil {
  2243. return
  2244. }
  2245. mf.Method = method
  2246. case 51: // exchange unbind-ok
  2247. //fmt.Println("NextMethod: class:40 method:51")
  2248. method := &exchangeUnbindOk{}
  2249. if err = method.read(me.r); err != nil {
  2250. return
  2251. }
  2252. mf.Method = method
  2253. default:
  2254. return nil, fmt.Errorf("Bad method frame, unknown method %d for class %d", mf.MethodId, mf.ClassId)
  2255. }
  2256. case 50: // queue
  2257. switch mf.MethodId {
  2258. case 10: // queue declare
  2259. //fmt.Println("NextMethod: class:50 method:10")
  2260. method := &queueDeclare{}
  2261. if err = method.read(me.r); err != nil {
  2262. return
  2263. }
  2264. mf.Method = method
  2265. case 11: // queue declare-ok
  2266. //fmt.Println("NextMethod: class:50 method:11")
  2267. method := &queueDeclareOk{}
  2268. if err = method.read(me.r); err != nil {
  2269. return
  2270. }
  2271. mf.Method = method
  2272. case 20: // queue bind
  2273. //fmt.Println("NextMethod: class:50 method:20")
  2274. method := &queueBind{}
  2275. if err = method.read(me.r); err != nil {
  2276. return
  2277. }
  2278. mf.Method = method
  2279. case 21: // queue bind-ok
  2280. //fmt.Println("NextMethod: class:50 method:21")
  2281. method := &queueBindOk{}
  2282. if err = method.read(me.r); err != nil {
  2283. return
  2284. }
  2285. mf.Method = method
  2286. case 50: // queue unbind
  2287. //fmt.Println("NextMethod: class:50 method:50")
  2288. method := &queueUnbind{}
  2289. if err = method.read(me.r); err != nil {
  2290. return
  2291. }
  2292. mf.Method = method
  2293. case 51: // queue unbind-ok
  2294. //fmt.Println("NextMethod: class:50 method:51")
  2295. method := &queueUnbindOk{}
  2296. if err = method.read(me.r); err != nil {
  2297. return
  2298. }
  2299. mf.Method = method
  2300. case 30: // queue purge
  2301. //fmt.Println("NextMethod: class:50 method:30")
  2302. method := &queuePurge{}
  2303. if err = method.read(me.r); err != nil {
  2304. return
  2305. }
  2306. mf.Method = method
  2307. case 31: // queue purge-ok
  2308. //fmt.Println("NextMethod: class:50 method:31")
  2309. method := &queuePurgeOk{}
  2310. if err = method.read(me.r); err != nil {
  2311. return
  2312. }
  2313. mf.Method = method
  2314. case 40: // queue delete
  2315. //fmt.Println("NextMethod: class:50 method:40")
  2316. method := &queueDelete{}
  2317. if err = method.read(me.r); err != nil {
  2318. return
  2319. }
  2320. mf.Method = method
  2321. case 41: // queue delete-ok
  2322. //fmt.Println("NextMethod: class:50 method:41")
  2323. method := &queueDeleteOk{}
  2324. if err = method.read(me.r); err != nil {
  2325. return
  2326. }
  2327. mf.Method = method
  2328. default:
  2329. return nil, fmt.Errorf("Bad method frame, unknown method %d for class %d", mf.MethodId, mf.ClassId)
  2330. }
  2331. case 60: // basic
  2332. switch mf.MethodId {
  2333. case 10: // basic qos
  2334. //fmt.Println("NextMethod: class:60 method:10")
  2335. method := &basicQos{}
  2336. if err = method.read(me.r); err != nil {
  2337. return
  2338. }
  2339. mf.Method = method
  2340. case 11: // basic qos-ok
  2341. //fmt.Println("NextMethod: class:60 method:11")
  2342. method := &basicQosOk{}
  2343. if err = method.read(me.r); err != nil {
  2344. return
  2345. }
  2346. mf.Method = method
  2347. case 20: // basic consume
  2348. //fmt.Println("NextMethod: class:60 method:20")
  2349. method := &basicConsume{}
  2350. if err = method.read(me.r); err != nil {
  2351. return
  2352. }
  2353. mf.Method = method
  2354. case 21: // basic consume-ok
  2355. //fmt.Println("NextMethod: class:60 method:21")
  2356. method := &basicConsumeOk{}
  2357. if err = method.read(me.r); err != nil {
  2358. return
  2359. }
  2360. mf.Method = method
  2361. case 30: // basic cancel
  2362. //fmt.Println("NextMethod: class:60 method:30")
  2363. method := &basicCancel{}
  2364. if err = method.read(me.r); err != nil {
  2365. return
  2366. }
  2367. mf.Method = method
  2368. case 31: // basic cancel-ok
  2369. //fmt.Println("NextMethod: class:60 method:31")
  2370. method := &basicCancelOk{}
  2371. if err = method.read(me.r); err != nil {
  2372. return
  2373. }
  2374. mf.Method = method
  2375. case 40: // basic publish
  2376. //fmt.Println("NextMethod: class:60 method:40")
  2377. method := &basicPublish{}
  2378. if err = method.read(me.r); err != nil {
  2379. return
  2380. }
  2381. mf.Method = method
  2382. case 50: // basic return
  2383. //fmt.Println("NextMethod: class:60 method:50")
  2384. method := &basicReturn{}
  2385. if err = method.read(me.r); err != nil {
  2386. return
  2387. }
  2388. mf.Method = method
  2389. case 60: // basic deliver
  2390. //fmt.Println("NextMethod: class:60 method:60")
  2391. method := &basicDeliver{}
  2392. if err = method.read(me.r); err != nil {
  2393. return
  2394. }
  2395. mf.Method = method
  2396. case 70: // basic get
  2397. //fmt.Println("NextMethod: class:60 method:70")
  2398. method := &basicGet{}
  2399. if err = method.read(me.r); err != nil {
  2400. return
  2401. }
  2402. mf.Method = method
  2403. case 71: // basic get-ok
  2404. //fmt.Println("NextMethod: class:60 method:71")
  2405. method := &basicGetOk{}
  2406. if err = method.read(me.r); err != nil {
  2407. return
  2408. }
  2409. mf.Method = method
  2410. case 72: // basic get-empty
  2411. //fmt.Println("NextMethod: class:60 method:72")
  2412. method := &basicGetEmpty{}
  2413. if err = method.read(me.r); err != nil {
  2414. return
  2415. }
  2416. mf.Method = method
  2417. case 80: // basic ack
  2418. //fmt.Println("NextMethod: class:60 method:80")
  2419. method := &basicAck{}
  2420. if err = method.read(me.r); err != nil {
  2421. return
  2422. }
  2423. mf.Method = method
  2424. case 90: // basic reject
  2425. //fmt.Println("NextMethod: class:60 method:90")
  2426. method := &basicReject{}
  2427. if err = method.read(me.r); err != nil {
  2428. return
  2429. }
  2430. mf.Method = method
  2431. case 100: // basic recover-async
  2432. //fmt.Println("NextMethod: class:60 method:100")
  2433. method := &basicRecoverAsync{}
  2434. if err = method.read(me.r); err != nil {
  2435. return
  2436. }
  2437. mf.Method = method
  2438. case 110: // basic recover
  2439. //fmt.Println("NextMethod: class:60 method:110")
  2440. method := &basicRecover{}
  2441. if err = method.read(me.r); err != nil {
  2442. return
  2443. }
  2444. mf.Method = method
  2445. case 111: // basic recover-ok
  2446. //fmt.Println("NextMethod: class:60 method:111")
  2447. method := &basicRecoverOk{}
  2448. if err = method.read(me.r); err != nil {
  2449. return
  2450. }
  2451. mf.Method = method
  2452. case 120: // basic nack
  2453. //fmt.Println("NextMethod: class:60 method:120")
  2454. method := &basicNack{}
  2455. if err = method.read(me.r); err != nil {
  2456. return
  2457. }
  2458. mf.Method = method
  2459. default:
  2460. return nil, fmt.Errorf("Bad method frame, unknown method %d for class %d", mf.MethodId, mf.ClassId)
  2461. }
  2462. case 90: // tx
  2463. switch mf.MethodId {
  2464. case 10: // tx select
  2465. //fmt.Println("NextMethod: class:90 method:10")
  2466. method := &txSelect{}
  2467. if err = method.read(me.r); err != nil {
  2468. return
  2469. }
  2470. mf.Method = method
  2471. case 11: // tx select-ok
  2472. //fmt.Println("NextMethod: class:90 method:11")
  2473. method := &txSelectOk{}
  2474. if err = method.read(me.r); err != nil {
  2475. return
  2476. }
  2477. mf.Method = method
  2478. case 20: // tx commit
  2479. //fmt.Println("NextMethod: class:90 method:20")
  2480. method := &txCommit{}
  2481. if err = method.read(me.r); err != nil {
  2482. return
  2483. }
  2484. mf.Method = method
  2485. case 21: // tx commit-ok
  2486. //fmt.Println("NextMethod: class:90 method:21")
  2487. method := &txCommitOk{}
  2488. if err = method.read(me.r); err != nil {
  2489. return
  2490. }
  2491. mf.Method = method
  2492. case 30: // tx rollback
  2493. //fmt.Println("NextMethod: class:90 method:30")
  2494. method := &txRollback{}
  2495. if err = method.read(me.r); err != nil {
  2496. return
  2497. }
  2498. mf.Method = method
  2499. case 31: // tx rollback-ok
  2500. //fmt.Println("NextMethod: class:90 method:31")
  2501. method := &txRollbackOk{}
  2502. if err = method.read(me.r); err != nil {
  2503. return
  2504. }
  2505. mf.Method = method
  2506. default:
  2507. return nil, fmt.Errorf("Bad method frame, unknown method %d for class %d", mf.MethodId, mf.ClassId)
  2508. }
  2509. case 85: // confirm
  2510. switch mf.MethodId {
  2511. case 10: // confirm select
  2512. //fmt.Println("NextMethod: class:85 method:10")
  2513. method := &confirmSelect{}
  2514. if err = method.read(me.r); err != nil {
  2515. return
  2516. }
  2517. mf.Method = method
  2518. case 11: // confirm select-ok
  2519. //fmt.Println("NextMethod: class:85 method:11")
  2520. method := &confirmSelectOk{}
  2521. if err = method.read(me.r); err != nil {
  2522. return
  2523. }
  2524. mf.Method = method
  2525. default:
  2526. return nil, fmt.Errorf("Bad method frame, unknown method %d for class %d", mf.MethodId, mf.ClassId)
  2527. }
  2528. default:
  2529. return nil, fmt.Errorf("Bad method frame, unknown class %d", mf.ClassId)
  2530. }
  2531. return mf, nil
  2532. }