sidekick-client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (247) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +17 -0
  5. data/Rakefile +52 -0
  6. data/VERSION +1 -0
  7. data/lib/ext/README +1 -0
  8. data/lib/ext/bunny-0.6.0/LICENSE +20 -0
  9. data/lib/ext/bunny-0.6.0/README.rdoc +66 -0
  10. data/lib/ext/bunny-0.6.0/Rakefile +24 -0
  11. data/lib/ext/bunny-0.6.0/bunny.gemspec +65 -0
  12. data/lib/ext/bunny-0.6.0/examples/simple_08.rb +30 -0
  13. data/lib/ext/bunny-0.6.0/examples/simple_09.rb +30 -0
  14. data/lib/ext/bunny-0.6.0/examples/simple_ack_08.rb +33 -0
  15. data/lib/ext/bunny-0.6.0/examples/simple_ack_09.rb +33 -0
  16. data/lib/ext/bunny-0.6.0/examples/simple_consumer_08.rb +53 -0
  17. data/lib/ext/bunny-0.6.0/examples/simple_consumer_09.rb +53 -0
  18. data/lib/ext/bunny-0.6.0/examples/simple_fanout_08.rb +39 -0
  19. data/lib/ext/bunny-0.6.0/examples/simple_fanout_09.rb +39 -0
  20. data/lib/ext/bunny-0.6.0/examples/simple_headers_08.rb +40 -0
  21. data/lib/ext/bunny-0.6.0/examples/simple_headers_09.rb +40 -0
  22. data/lib/ext/bunny-0.6.0/examples/simple_publisher_08.rb +27 -0
  23. data/lib/ext/bunny-0.6.0/examples/simple_publisher_09.rb +27 -0
  24. data/lib/ext/bunny-0.6.0/examples/simple_topic_08.rb +59 -0
  25. data/lib/ext/bunny-0.6.0/examples/simple_topic_09.rb +59 -0
  26. data/lib/ext/bunny-0.6.0/lib/bunny/channel08.rb +39 -0
  27. data/lib/ext/bunny-0.6.0/lib/bunny/channel09.rb +39 -0
  28. data/lib/ext/bunny-0.6.0/lib/bunny/client08.rb +494 -0
  29. data/lib/ext/bunny-0.6.0/lib/bunny/client09.rb +460 -0
  30. data/lib/ext/bunny-0.6.0/lib/bunny/exchange08.rb +175 -0
  31. data/lib/ext/bunny-0.6.0/lib/bunny/exchange09.rb +177 -0
  32. data/lib/ext/bunny-0.6.0/lib/bunny/queue08.rb +389 -0
  33. data/lib/ext/bunny-0.6.0/lib/bunny/queue09.rb +395 -0
  34. data/lib/ext/bunny-0.6.0/lib/bunny/subscription08.rb +85 -0
  35. data/lib/ext/bunny-0.6.0/lib/bunny/subscription09.rb +85 -0
  36. data/lib/ext/bunny-0.6.0/lib/bunny.rb +87 -0
  37. data/lib/ext/bunny-0.6.0/lib/qrack/channel.rb +18 -0
  38. data/lib/ext/bunny-0.6.0/lib/qrack/client.rb +204 -0
  39. data/lib/ext/bunny-0.6.0/lib/qrack/protocol/protocol08.rb +132 -0
  40. data/lib/ext/bunny-0.6.0/lib/qrack/protocol/protocol09.rb +133 -0
  41. data/lib/ext/bunny-0.6.0/lib/qrack/protocol/spec08.rb +823 -0
  42. data/lib/ext/bunny-0.6.0/lib/qrack/protocol/spec09.rb +521 -0
  43. data/lib/ext/bunny-0.6.0/lib/qrack/qrack08.rb +23 -0
  44. data/lib/ext/bunny-0.6.0/lib/qrack/qrack09.rb +23 -0
  45. data/lib/ext/bunny-0.6.0/lib/qrack/queue.rb +53 -0
  46. data/lib/ext/bunny-0.6.0/lib/qrack/subscription.rb +102 -0
  47. data/lib/ext/bunny-0.6.0/lib/qrack/transport/buffer08.rb +276 -0
  48. data/lib/ext/bunny-0.6.0/lib/qrack/transport/buffer09.rb +276 -0
  49. data/lib/ext/bunny-0.6.0/lib/qrack/transport/frame08.rb +112 -0
  50. data/lib/ext/bunny-0.6.0/lib/qrack/transport/frame09.rb +94 -0
  51. data/lib/ext/bunny-0.6.0/spec/spec_08/bunny_spec.rb +65 -0
  52. data/lib/ext/bunny-0.6.0/spec/spec_08/connection_spec.rb +12 -0
  53. data/lib/ext/bunny-0.6.0/spec/spec_08/exchange_spec.rb +162 -0
  54. data/lib/ext/bunny-0.6.0/spec/spec_08/queue_spec.rb +206 -0
  55. data/lib/ext/bunny-0.6.0/spec/spec_09/bunny_spec.rb +65 -0
  56. data/lib/ext/bunny-0.6.0/spec/spec_09/connection_spec.rb +12 -0
  57. data/lib/ext/bunny-0.6.0/spec/spec_09/exchange_spec.rb +162 -0
  58. data/lib/ext/bunny-0.6.0/spec/spec_09/queue_spec.rb +205 -0
  59. data/lib/ext/eventmachine-0.12.10/.gitignore +14 -0
  60. data/lib/ext/eventmachine-0.12.10/README +82 -0
  61. data/lib/ext/eventmachine-0.12.10/Rakefile +374 -0
  62. data/lib/ext/eventmachine-0.12.10/docs/COPYING +60 -0
  63. data/lib/ext/eventmachine-0.12.10/docs/ChangeLog +211 -0
  64. data/lib/ext/eventmachine-0.12.10/docs/DEFERRABLES +133 -0
  65. data/lib/ext/eventmachine-0.12.10/docs/EPOLL +141 -0
  66. data/lib/ext/eventmachine-0.12.10/docs/GNU +281 -0
  67. data/lib/ext/eventmachine-0.12.10/docs/INSTALL +13 -0
  68. data/lib/ext/eventmachine-0.12.10/docs/KEYBOARD +38 -0
  69. data/lib/ext/eventmachine-0.12.10/docs/LEGAL +25 -0
  70. data/lib/ext/eventmachine-0.12.10/docs/LIGHTWEIGHT_CONCURRENCY +70 -0
  71. data/lib/ext/eventmachine-0.12.10/docs/PURE_RUBY +75 -0
  72. data/lib/ext/eventmachine-0.12.10/docs/RELEASE_NOTES +94 -0
  73. data/lib/ext/eventmachine-0.12.10/docs/SMTP +2 -0
  74. data/lib/ext/eventmachine-0.12.10/docs/SPAWNED_PROCESSES +89 -0
  75. data/lib/ext/eventmachine-0.12.10/docs/TODO +8 -0
  76. data/lib/ext/eventmachine-0.12.10/eventmachine.gemspec +40 -0
  77. data/lib/ext/eventmachine-0.12.10/examples/ex_channel.rb +43 -0
  78. data/lib/ext/eventmachine-0.12.10/examples/ex_queue.rb +2 -0
  79. data/lib/ext/eventmachine-0.12.10/examples/helper.rb +2 -0
  80. data/lib/ext/eventmachine-0.12.10/ext/binder.cpp +125 -0
  81. data/lib/ext/eventmachine-0.12.10/ext/binder.h +46 -0
  82. data/lib/ext/eventmachine-0.12.10/ext/cmain.cpp +827 -0
  83. data/lib/ext/eventmachine-0.12.10/ext/cplusplus.cpp +202 -0
  84. data/lib/ext/eventmachine-0.12.10/ext/ed.cpp +1893 -0
  85. data/lib/ext/eventmachine-0.12.10/ext/ed.h +424 -0
  86. data/lib/ext/eventmachine-0.12.10/ext/em.cpp +2282 -0
  87. data/lib/ext/eventmachine-0.12.10/ext/em.h +232 -0
  88. data/lib/ext/eventmachine-0.12.10/ext/emwin.cpp +300 -0
  89. data/lib/ext/eventmachine-0.12.10/ext/emwin.h +94 -0
  90. data/lib/ext/eventmachine-0.12.10/ext/epoll.cpp +26 -0
  91. data/lib/ext/eventmachine-0.12.10/ext/epoll.h +25 -0
  92. data/lib/ext/eventmachine-0.12.10/ext/eventmachine.h +122 -0
  93. data/lib/ext/eventmachine-0.12.10/ext/eventmachine_cpp.h +96 -0
  94. data/lib/ext/eventmachine-0.12.10/ext/extconf.rb +148 -0
  95. data/lib/ext/eventmachine-0.12.10/ext/fastfilereader/extconf.rb +83 -0
  96. data/lib/ext/eventmachine-0.12.10/ext/fastfilereader/mapper.cpp +214 -0
  97. data/lib/ext/eventmachine-0.12.10/ext/fastfilereader/mapper.h +59 -0
  98. data/lib/ext/eventmachine-0.12.10/ext/fastfilereader/rubymain.cpp +127 -0
  99. data/lib/ext/eventmachine-0.12.10/ext/files.cpp +94 -0
  100. data/lib/ext/eventmachine-0.12.10/ext/files.h +65 -0
  101. data/lib/ext/eventmachine-0.12.10/ext/kb.cpp +81 -0
  102. data/lib/ext/eventmachine-0.12.10/ext/page.cpp +107 -0
  103. data/lib/ext/eventmachine-0.12.10/ext/page.h +51 -0
  104. data/lib/ext/eventmachine-0.12.10/ext/pipe.cpp +349 -0
  105. data/lib/ext/eventmachine-0.12.10/ext/project.h +151 -0
  106. data/lib/ext/eventmachine-0.12.10/ext/rubymain.cpp +1166 -0
  107. data/lib/ext/eventmachine-0.12.10/ext/sigs.cpp +89 -0
  108. data/lib/ext/eventmachine-0.12.10/ext/sigs.h +32 -0
  109. data/lib/ext/eventmachine-0.12.10/ext/ssl.cpp +460 -0
  110. data/lib/ext/eventmachine-0.12.10/ext/ssl.h +94 -0
  111. data/lib/ext/eventmachine-0.12.10/java/.classpath +8 -0
  112. data/lib/ext/eventmachine-0.12.10/java/.project +17 -0
  113. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EmReactor.java +570 -0
  114. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EmReactorException.java +40 -0
  115. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EventableChannel.java +69 -0
  116. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EventableDatagramChannel.java +189 -0
  117. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EventableSocketChannel.java +364 -0
  118. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/Application.java +194 -0
  119. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/Connection.java +74 -0
  120. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/ConnectionFactory.java +37 -0
  121. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/DefaultConnectionFactory.java +46 -0
  122. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/PeriodicTimer.java +38 -0
  123. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/Timer.java +54 -0
  124. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/ApplicationTest.java +109 -0
  125. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/ConnectTest.java +148 -0
  126. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/EMTest.java +80 -0
  127. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/TestDatagrams.java +53 -0
  128. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/TestServers.java +75 -0
  129. data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/TestTimers.java +90 -0
  130. data/lib/ext/eventmachine-0.12.10/lib/em/buftok.rb +138 -0
  131. data/lib/ext/eventmachine-0.12.10/lib/em/callback.rb +26 -0
  132. data/lib/ext/eventmachine-0.12.10/lib/em/channel.rb +57 -0
  133. data/lib/ext/eventmachine-0.12.10/lib/em/connection.rb +564 -0
  134. data/lib/ext/eventmachine-0.12.10/lib/em/deferrable.rb +192 -0
  135. data/lib/ext/eventmachine-0.12.10/lib/em/file_watch.rb +54 -0
  136. data/lib/ext/eventmachine-0.12.10/lib/em/future.rb +61 -0
  137. data/lib/ext/eventmachine-0.12.10/lib/em/messages.rb +66 -0
  138. data/lib/ext/eventmachine-0.12.10/lib/em/process_watch.rb +44 -0
  139. data/lib/ext/eventmachine-0.12.10/lib/em/processes.rb +119 -0
  140. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/header_and_content.rb +138 -0
  141. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/httpclient.rb +263 -0
  142. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/httpclient2.rb +590 -0
  143. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/line_and_text.rb +125 -0
  144. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/linetext2.rb +161 -0
  145. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/memcache.rb +323 -0
  146. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/object_protocol.rb +45 -0
  147. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/postgres3.rb +247 -0
  148. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/saslauth.rb +175 -0
  149. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/smtpclient.rb +357 -0
  150. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/smtpserver.rb +547 -0
  151. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/socks4.rb +66 -0
  152. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/stomp.rb +200 -0
  153. data/lib/ext/eventmachine-0.12.10/lib/em/protocols/tcptest.rb +53 -0
  154. data/lib/ext/eventmachine-0.12.10/lib/em/protocols.rb +36 -0
  155. data/lib/ext/eventmachine-0.12.10/lib/em/queue.rb +61 -0
  156. data/lib/ext/eventmachine-0.12.10/lib/em/spawnable.rb +85 -0
  157. data/lib/ext/eventmachine-0.12.10/lib/em/streamer.rb +130 -0
  158. data/lib/ext/eventmachine-0.12.10/lib/em/timers.rb +56 -0
  159. data/lib/ext/eventmachine-0.12.10/lib/em/version.rb +3 -0
  160. data/lib/ext/eventmachine-0.12.10/lib/eventmachine.rb +1592 -0
  161. data/lib/ext/eventmachine-0.12.10/lib/evma/callback.rb +32 -0
  162. data/lib/ext/eventmachine-0.12.10/lib/evma/container.rb +75 -0
  163. data/lib/ext/eventmachine-0.12.10/lib/evma/factory.rb +77 -0
  164. data/lib/ext/eventmachine-0.12.10/lib/evma/protocol.rb +87 -0
  165. data/lib/ext/eventmachine-0.12.10/lib/evma/reactor.rb +48 -0
  166. data/lib/ext/eventmachine-0.12.10/lib/evma.rb +32 -0
  167. data/lib/ext/eventmachine-0.12.10/lib/jeventmachine.rb +257 -0
  168. data/lib/ext/eventmachine-0.12.10/lib/pr_eventmachine.rb +1022 -0
  169. data/lib/ext/eventmachine-0.12.10/setup.rb +1585 -0
  170. data/lib/ext/eventmachine-0.12.10/tasks/cpp.rake_example +77 -0
  171. data/lib/ext/eventmachine-0.12.10/tests/client.crt +31 -0
  172. data/lib/ext/eventmachine-0.12.10/tests/client.key +51 -0
  173. data/lib/ext/eventmachine-0.12.10/tests/test_attach.rb +126 -0
  174. data/lib/ext/eventmachine-0.12.10/tests/test_basic.rb +284 -0
  175. data/lib/ext/eventmachine-0.12.10/tests/test_channel.rb +63 -0
  176. data/lib/ext/eventmachine-0.12.10/tests/test_connection_count.rb +35 -0
  177. data/lib/ext/eventmachine-0.12.10/tests/test_defer.rb +47 -0
  178. data/lib/ext/eventmachine-0.12.10/tests/test_epoll.rb +160 -0
  179. data/lib/ext/eventmachine-0.12.10/tests/test_error_handler.rb +35 -0
  180. data/lib/ext/eventmachine-0.12.10/tests/test_errors.rb +82 -0
  181. data/lib/ext/eventmachine-0.12.10/tests/test_exc.rb +55 -0
  182. data/lib/ext/eventmachine-0.12.10/tests/test_file_watch.rb +49 -0
  183. data/lib/ext/eventmachine-0.12.10/tests/test_futures.rb +198 -0
  184. data/lib/ext/eventmachine-0.12.10/tests/test_get_sock_opt.rb +30 -0
  185. data/lib/ext/eventmachine-0.12.10/tests/test_handler_check.rb +37 -0
  186. data/lib/ext/eventmachine-0.12.10/tests/test_hc.rb +218 -0
  187. data/lib/ext/eventmachine-0.12.10/tests/test_httpclient.rb +218 -0
  188. data/lib/ext/eventmachine-0.12.10/tests/test_httpclient2.rb +153 -0
  189. data/lib/ext/eventmachine-0.12.10/tests/test_inactivity_timeout.rb +50 -0
  190. data/lib/ext/eventmachine-0.12.10/tests/test_kb.rb +60 -0
  191. data/lib/ext/eventmachine-0.12.10/tests/test_ltp.rb +182 -0
  192. data/lib/ext/eventmachine-0.12.10/tests/test_ltp2.rb +317 -0
  193. data/lib/ext/eventmachine-0.12.10/tests/test_next_tick.rb +133 -0
  194. data/lib/ext/eventmachine-0.12.10/tests/test_object_protocol.rb +37 -0
  195. data/lib/ext/eventmachine-0.12.10/tests/test_pause.rb +70 -0
  196. data/lib/ext/eventmachine-0.12.10/tests/test_pending_connect_timeout.rb +48 -0
  197. data/lib/ext/eventmachine-0.12.10/tests/test_process_watch.rb +48 -0
  198. data/lib/ext/eventmachine-0.12.10/tests/test_processes.rb +128 -0
  199. data/lib/ext/eventmachine-0.12.10/tests/test_proxy_connection.rb +92 -0
  200. data/lib/ext/eventmachine-0.12.10/tests/test_pure.rb +125 -0
  201. data/lib/ext/eventmachine-0.12.10/tests/test_queue.rb +44 -0
  202. data/lib/ext/eventmachine-0.12.10/tests/test_running.rb +42 -0
  203. data/lib/ext/eventmachine-0.12.10/tests/test_sasl.rb +72 -0
  204. data/lib/ext/eventmachine-0.12.10/tests/test_send_file.rb +242 -0
  205. data/lib/ext/eventmachine-0.12.10/tests/test_servers.rb +76 -0
  206. data/lib/ext/eventmachine-0.12.10/tests/test_smtpclient.rb +83 -0
  207. data/lib/ext/eventmachine-0.12.10/tests/test_smtpserver.rb +85 -0
  208. data/lib/ext/eventmachine-0.12.10/tests/test_spawn.rb +322 -0
  209. data/lib/ext/eventmachine-0.12.10/tests/test_ssl_args.rb +79 -0
  210. data/lib/ext/eventmachine-0.12.10/tests/test_ssl_methods.rb +50 -0
  211. data/lib/ext/eventmachine-0.12.10/tests/test_ssl_verify.rb +82 -0
  212. data/lib/ext/eventmachine-0.12.10/tests/test_timers.rb +162 -0
  213. data/lib/ext/eventmachine-0.12.10/tests/test_ud.rb +36 -0
  214. data/lib/ext/eventmachine-0.12.10/tests/testem.rb +31 -0
  215. data/lib/ext/eventmachine-0.12.10/web/whatis +7 -0
  216. data/lib/ext/misc/README +1 -0
  217. data/lib/ext/misc/indifferent_access.rb +131 -0
  218. data/lib/ext/uuidtools-2.1.1/CHANGELOG +56 -0
  219. data/lib/ext/uuidtools-2.1.1/LICENSE +20 -0
  220. data/lib/ext/uuidtools-2.1.1/README +13 -0
  221. data/lib/ext/uuidtools-2.1.1/Rakefile +48 -0
  222. data/lib/ext/uuidtools-2.1.1/lib/compat/securerandom.rb +202 -0
  223. data/lib/ext/uuidtools-2.1.1/lib/uuidtools/version.rb +35 -0
  224. data/lib/ext/uuidtools-2.1.1/lib/uuidtools.rb +618 -0
  225. data/lib/ext/uuidtools-2.1.1/spec/spec.opts +1 -0
  226. data/lib/ext/uuidtools-2.1.1/spec/spec_helper.rb +7 -0
  227. data/lib/ext/uuidtools-2.1.1/spec/uuidtools/mac_address_spec.rb +15 -0
  228. data/lib/ext/uuidtools-2.1.1/spec/uuidtools/utility_spec.rb +21 -0
  229. data/lib/ext/uuidtools-2.1.1/spec/uuidtools/uuid_creation_spec.rb +121 -0
  230. data/lib/ext/uuidtools-2.1.1/spec/uuidtools/uuid_parsing_spec.rb +127 -0
  231. data/lib/ext/uuidtools-2.1.1/tasks/benchmark.rake +38 -0
  232. data/lib/ext/uuidtools-2.1.1/tasks/clobber.rake +2 -0
  233. data/lib/ext/uuidtools-2.1.1/tasks/gem.rake +68 -0
  234. data/lib/ext/uuidtools-2.1.1/tasks/git.rake +40 -0
  235. data/lib/ext/uuidtools-2.1.1/tasks/metrics.rake +22 -0
  236. data/lib/ext/uuidtools-2.1.1/tasks/rdoc.rake +29 -0
  237. data/lib/ext/uuidtools-2.1.1/tasks/rubyforge.rake +89 -0
  238. data/lib/ext/uuidtools-2.1.1/tasks/spec.rake +64 -0
  239. data/lib/ext/uuidtools-2.1.1/website/index.html +95 -0
  240. data/lib/sidekick/client/sidekick_client.rb +46 -0
  241. data/lib/sidekick/shared/sidekick_logger.rb +14 -0
  242. data/lib/sidekick/shared/sidekick_queue_publisher.rb +91 -0
  243. data/lib/sidekick-client.rb +7 -0
  244. data/sidekick-client.gemspec +289 -0
  245. data/test/helper.rb +10 -0
  246. data/test/test_sidekick-client.rb +7 -0
  247. metadata +311 -0
@@ -0,0 +1,460 @@
1
+ module Bunny
2
+
3
+ =begin rdoc
4
+
5
+ === DESCRIPTION:
6
+
7
+ The Client class provides the major Bunny API methods.
8
+
9
+ =end
10
+
11
+ class Client09 < Qrack::Client
12
+
13
+ =begin rdoc
14
+
15
+ === DESCRIPTION:
16
+
17
+ Sets up a Bunny::Client object ready for connection to a broker/server. _Client_._status_ is set to
18
+ <tt>:not_connected</tt>.
19
+
20
+ ==== OPTIONS:
21
+
22
+ * <tt>:host => '_hostname_' (default = 'localhost')</tt>
23
+ * <tt>:port => _portno_ (default = 5672 or 5671 if :ssl set to true)</tt>
24
+ * <tt>:vhost => '_vhostname_' (default = '/')</tt>
25
+ * <tt>:user => '_username_' (default = 'guest')</tt>
26
+ * <tt>:pass => '_password_' (default = 'guest')</tt>
27
+ * <tt>:ssl => true or false (default = false)</tt> - If set to _true_, ssl
28
+ encryption will be used and port will default to 5671.
29
+ * <tt>:verify_ssl => true or false (default = true)</tt> - If ssl is enabled,
30
+ this will cause OpenSSL to validate the server certificate unless this
31
+ parameter is set to _false_.
32
+ * <tt>:logfile => '_logfilepath_' (default = nil)</tt>
33
+ * <tt>:logging => true or false (_default_)</tt> - If set to _true_, session information is sent
34
+ to STDOUT if <tt>:logfile</tt> has not been specified. Otherwise, session information is written to
35
+ <tt>:logfile</tt>.
36
+ * <tt>:frame_max => maximum frame size in bytes (default = 131072)</tt>
37
+ * <tt>:channel_max => maximum number of channels (default = 0 no maximum)</tt>
38
+ * <tt>:heartbeat => number of seconds (default = 0 no heartbeat)</tt>
39
+ * <tt>:connect_timeout => number of seconds before Qrack::ConnectionTimeout is raised (default = 5)</tt>
40
+
41
+ =end
42
+
43
+ def initialize(opts = {})
44
+ super
45
+ @spec = '0-9-1'
46
+ @port = opts[:port] || (opts[:ssl] ? Qrack::Protocol09::SSL_PORT : Qrack::Protocol09::PORT)
47
+ end
48
+
49
+ =begin rdoc
50
+
51
+ === DESCRIPTION:
52
+
53
+ Checks response from AMQP methods and takes appropriate action
54
+
55
+ =end
56
+
57
+ def check_response(received_method, expected_method, err_msg, err_class = Bunny::ProtocolError)
58
+ case
59
+ when received_method.is_a?(Qrack::Protocol09::Connection::Close)
60
+ # Clean up the socket
61
+ close_socket
62
+
63
+ raise Bunny::ForcedConnectionCloseError,
64
+ "Error Reply Code: #{received_method.reply_code}\nError Reply Text: #{received_method.reply_text}"
65
+
66
+ when received_method.is_a?(Qrack::Protocol09::Channel::Close)
67
+ # Clean up the channel
68
+ channel.active = false
69
+
70
+ raise Bunny::ForcedChannelCloseError,
71
+ "Error Reply Code: #{received_method.reply_code}\nError Reply Text: #{received_method.reply_text}"
72
+
73
+ when !received_method.is_a?(expected_method)
74
+ raise err_class, err_msg
75
+
76
+ else
77
+ :response_ok
78
+ end
79
+ end
80
+
81
+ def close_connection
82
+ # Set client channel to zero
83
+ switch_channel(0)
84
+
85
+ send_frame(
86
+ Qrack::Protocol09::Connection::Close.new(:reply_code => 200, :reply_text => 'Goodbye', :class_id => 0, :method_id => 0)
87
+ )
88
+
89
+ method = next_method
90
+
91
+ check_response(method, Qrack::Protocol09::Connection::CloseOk, "Error closing connection")
92
+
93
+ end
94
+
95
+ def create_channel
96
+ channels.each do |c|
97
+ return c if (!c.open? and c.number != 0)
98
+ end
99
+ # If no channel to re-use instantiate new one
100
+ Bunny::Channel09.new(self)
101
+ end
102
+
103
+ =begin rdoc
104
+
105
+ === DESCRIPTION:
106
+
107
+ Declares an exchange to the broker/server. If the exchange does not exist, a new one is created
108
+ using the arguments passed in. If the exchange already exists, a reference to it is created, provided
109
+ that the arguments passed in do not conflict with the existing attributes of the exchange. If an error
110
+ occurs a _Bunny_::_ProtocolError_ is raised.
111
+
112
+ ==== OPTIONS:
113
+
114
+ * <tt>:type => one of :direct (_default_), :fanout, :topic, :headers</tt>
115
+ * <tt>:passive => true or false</tt> - If set to _true_, the server will not create the exchange.
116
+ The client can use this to check whether an exchange exists without modifying the server state.
117
+ * <tt>:durable => true or false (_default_)</tt> - If set to _true_ when creating a new exchange, the exchange
118
+ will be marked as durable. Durable exchanges remain active when a server restarts. Non-durable
119
+ exchanges (transient exchanges) are purged if/when a server restarts.
120
+ * <tt>:auto_delete => true or false (_default_)</tt> - If set to _true_, the exchange is deleted
121
+ when all queues have finished using it.
122
+ * <tt>:nowait => true or false (_default_)</tt> - Ignored by Bunny, always _false_.
123
+
124
+ ==== RETURNS:
125
+
126
+ Exchange
127
+
128
+ =end
129
+
130
+ def exchange(name, opts = {})
131
+ exchanges[name] || Bunny::Exchange09.new(self, name, opts)
132
+ end
133
+
134
+ def init_connection
135
+ write(Qrack::Protocol09::HEADER)
136
+ write([0, Qrack::Protocol09::VERSION_MAJOR, Qrack::Protocol09::VERSION_MINOR, Qrack::Protocol09::REVISION].pack('C4'))
137
+
138
+ frame = next_frame
139
+ if frame.nil? or !frame.payload.is_a?(Qrack::Protocol09::Connection::Start)
140
+ raise Bunny::ProtocolError, 'Connection initiation failed'
141
+ end
142
+ end
143
+
144
+ def next_frame(opts = {})
145
+ frame = nil
146
+
147
+ case
148
+ when channel.frame_buffer.size > 0
149
+ frame = channel.frame_buffer.shift
150
+ when opts.has_key?(:timeout)
151
+ Timeout::timeout(opts[:timeout], Qrack::ClientTimeout) do
152
+ frame = Qrack::Transport09::Frame.parse(buffer)
153
+ end
154
+ else
155
+ frame = Qrack::Transport09::Frame.parse(buffer)
156
+ end
157
+
158
+ @logger.info("received") { frame } if @logging
159
+
160
+ raise Bunny::ConnectionError, 'No connection to server' if (frame.nil? and !connecting?)
161
+
162
+ # Monitor server activity and discard heartbeats
163
+ @message_in = true
164
+
165
+ case
166
+ when frame.is_a?(Qrack::Transport09::Heartbeat)
167
+ next_frame(opts)
168
+ when frame.nil?
169
+ frame
170
+ when ((frame.channel != channel.number) and (frame.channel != 0))
171
+ channel.frame_buffer << frame
172
+ next_frame(opts)
173
+ else
174
+ frame
175
+ end
176
+
177
+ end
178
+
179
+ def open_connection
180
+ send_frame(
181
+ Qrack::Protocol09::Connection::StartOk.new(
182
+ :client_properties => {:platform => 'Ruby', :product => 'Bunny', :information => 'http://github.com/celldee/bunny', :version => VERSION},
183
+ :mechanism => 'PLAIN',
184
+ :response => "\0" + @user + "\0" + @pass,
185
+ :locale => 'en_US'
186
+ )
187
+ )
188
+
189
+ frame = next_frame
190
+ raise Bunny::ProtocolError, "Connection failed - user: #{@user}" if frame.nil?
191
+
192
+ method = frame.payload
193
+
194
+ if method.is_a?(Qrack::Protocol09::Connection::Tune)
195
+ send_frame(
196
+ Qrack::Protocol09::Connection::TuneOk.new( :channel_max => @channel_max, :frame_max => @frame_max, :heartbeat => @heartbeat)
197
+ )
198
+ end
199
+
200
+ send_frame(
201
+ Qrack::Protocol09::Connection::Open.new(:virtual_host => @vhost, :reserved_1 => 0, :reserved_2 => false)
202
+ )
203
+
204
+ raise Bunny::ProtocolError, 'Cannot open connection' unless next_method.is_a?(Qrack::Protocol09::Connection::OpenOk)
205
+ end
206
+
207
+ =begin rdoc
208
+
209
+ === DESCRIPTION:
210
+
211
+ Requests a specific quality of service. The QoS can be specified for the current channel
212
+ or for all channels on the connection. The particular properties and semantics of a QoS
213
+ method always depend on the content class semantics. Though the QoS method could in principle
214
+ apply to both peers, it is currently meaningful only for the server.
215
+
216
+ ==== Options:
217
+
218
+ * <tt>:prefetch_size => size in no. of octets (default = 0)</tt> - The client can request that
219
+ messages be sent in advance so that when the client finishes processing a message, the following
220
+ message is already held locally, rather than needing to be sent down the channel. Prefetching gives
221
+ a performance improvement. This field specifies the prefetch window size in octets. The server
222
+ will send a message in advance if it is equal to or smaller in size than the available prefetch
223
+ size (and also falls into other prefetch limits). May be set to zero, meaning "no specific limit",
224
+ although other prefetch limits may still apply. The prefetch-size is ignored if the no-ack option
225
+ is set.
226
+ * <tt>:prefetch_count => no. messages (default = 1)</tt> - Specifies a prefetch window in terms
227
+ of whole messages. This field may be used in combination with the prefetch-size field; a message
228
+ will only be sent in advance if both prefetch windows (and those at the channel and connection level)
229
+ allow it. The prefetch-count is ignored if the no-ack option is set.
230
+ * <tt>:global => true or false (_default_)</tt> - By default the QoS settings apply to the current channel only. If set to
231
+ true, they are applied to the entire connection.
232
+
233
+ ==== RETURNS:
234
+
235
+ <tt>:qos_ok</tt> if successful.
236
+
237
+ =end
238
+
239
+ def qos(opts = {})
240
+
241
+ send_frame(
242
+ Qrack::Protocol09::Basic::Qos.new({ :prefetch_size => 0, :prefetch_count => 1, :global => false }.merge(opts))
243
+ )
244
+
245
+ method = next_method
246
+
247
+ check_response(method, Qrack::Protocol09::Basic::QosOk, "Error specifying Quality of Service")
248
+
249
+ # return confirmation
250
+ :qos_ok
251
+ end
252
+
253
+ =begin rdoc
254
+
255
+ === DESCRIPTION:
256
+
257
+ Declares a queue to the broker/server. If the queue does not exist, a new one is created
258
+ using the arguments passed in. If the queue already exists, a reference to it is created, provided
259
+ that the arguments passed in do not conflict with the existing attributes of the queue. If an error
260
+ occurs a _Bunny_::_ProtocolError_ is raised.
261
+
262
+ ==== OPTIONS:
263
+
264
+ * <tt>:passive => true or false (_default_)</tt> - If set to _true_, the server will not create
265
+ the queue. The client can use this to check whether a queue exists without modifying the server
266
+ state.
267
+ * <tt>:durable => true or false (_default_)</tt> - If set to _true_ when creating a new queue, the
268
+ queue will be marked as durable. Durable queues remain active when a server restarts. Non-durable
269
+ queues (transient queues) are purged if/when a server restarts. Note that durable queues do not
270
+ necessarily hold persistent messages, although it does not make sense to send persistent messages
271
+ to a transient queue.
272
+ * <tt>:exclusive => true or false (_default_)</tt> - If set to _true_, requests an exclusive queue.
273
+ Exclusive queues may only be consumed from by the current connection. Setting the 'exclusive'
274
+ flag always implies 'auto-delete'.
275
+ * <tt>:auto_delete => true or false (_default_)</tt> - If set to _true_, the queue is deleted
276
+ when all consumers have finished using it. Last consumer can be cancelled either explicitly
277
+ or because its channel is closed. If there has never been a consumer on the queue, it is not
278
+ deleted.
279
+ * <tt>:nowait => true or false (_default_)</tt> - Ignored by Bunny, always _false_.
280
+
281
+ ==== RETURNS:
282
+
283
+ Queue
284
+
285
+ =end
286
+
287
+ def queue(name = nil, opts = {})
288
+ if name.is_a?(Hash)
289
+ opts = name
290
+ name = nil
291
+ end
292
+
293
+ # Queue is responsible for placing itself in the list of queues
294
+ queues[name] || Bunny::Queue09.new(self, name, opts)
295
+ end
296
+
297
+ =begin rdoc
298
+
299
+ === DESCRIPTION:
300
+
301
+ Asks the broker to redeliver all unacknowledged messages on a specified channel. Zero or
302
+ more messages may be redelivered.
303
+
304
+ ==== Options:
305
+
306
+ * <tt>:requeue => true or false (_default_)</tt> - If set to _false_, the message will be
307
+ redelivered to the original recipient. If set to _true_, the server will attempt to requeue
308
+ the message, potentially then delivering it to an alternative subscriber.
309
+
310
+ =end
311
+
312
+ def recover(opts = {})
313
+
314
+ send_frame(
315
+ Qrack::Protocol09::Basic::Recover.new({ :requeue => false }.merge(opts))
316
+ )
317
+
318
+ end
319
+
320
+ def send_frame(*args)
321
+ args.each do |data|
322
+ data = data.to_frame(channel.number) unless data.is_a?(Qrack::Transport09::Frame)
323
+ data.channel = channel.number
324
+
325
+ @logger.info("send") { data } if @logging
326
+ write(data.to_s)
327
+
328
+ # Monitor client activity for heartbeat purposes
329
+ @message_out = true
330
+ end
331
+
332
+ nil
333
+ end
334
+
335
+ def send_heartbeat
336
+ # Create a new heartbeat frame
337
+ hb = Qrack::Transport09::Heartbeat.new('')
338
+ # Channel 0 must be used
339
+ switch_channel(0) if @channel.number > 0
340
+ # Send the heartbeat to server
341
+ send_frame(hb)
342
+ end
343
+
344
+ =begin rdoc
345
+
346
+ === DESCRIPTION:
347
+
348
+ Opens a communication channel and starts a connection. If an error occurs, a
349
+ _Bunny_::_ProtocolError_ is raised. If successful, _Client_._status_ is set to <tt>:connected</tt>.
350
+
351
+ ==== RETURNS:
352
+
353
+ <tt>:connected</tt> if successful.
354
+
355
+ =end
356
+
357
+ def start_session
358
+ @connecting = true
359
+
360
+ # Create/get socket
361
+ socket
362
+
363
+ # Initiate connection
364
+ init_connection
365
+
366
+ # Open connection
367
+ open_connection
368
+
369
+ # Open another channel because channel zero is used for specific purposes
370
+ c = create_channel()
371
+ c.open
372
+
373
+ @connecting = false
374
+
375
+ # return status
376
+ @status = :connected
377
+ end
378
+
379
+ alias start start_session
380
+
381
+ =begin rdoc
382
+
383
+ === DESCRIPTION:
384
+ This method commits all messages published and acknowledged in
385
+ the current transaction. A new transaction starts immediately
386
+ after a commit.
387
+
388
+ ==== RETURNS:
389
+
390
+ <tt>:commit_ok</tt> if successful.
391
+
392
+ =end
393
+
394
+ def tx_commit
395
+ send_frame(Qrack::Protocol09::Tx::Commit.new())
396
+
397
+ method = next_method
398
+
399
+ check_response(method, Qrack::Protocol09::Tx::CommitOk, "Error commiting transaction")
400
+
401
+ # return confirmation
402
+ :commit_ok
403
+ end
404
+
405
+ =begin rdoc
406
+
407
+ === DESCRIPTION:
408
+ This method abandons all messages published and acknowledged in
409
+ the current transaction. A new transaction starts immediately
410
+ after a rollback.
411
+
412
+ ==== RETURNS:
413
+
414
+ <tt>:rollback_ok</tt> if successful.
415
+
416
+ =end
417
+
418
+ def tx_rollback
419
+ send_frame(Qrack::Protocol09::Tx::Rollback.new())
420
+
421
+ method = next_method
422
+
423
+ check_response(method, Qrack::Protocol09::Tx::RollbackOk, "Error rolling back transaction")
424
+
425
+ # return confirmation
426
+ :rollback_ok
427
+ end
428
+
429
+ =begin rdoc
430
+
431
+ === DESCRIPTION:
432
+ This method sets the channel to use standard transactions. The
433
+ client must use this method at least once on a channel before
434
+ using the Commit or Rollback methods.
435
+
436
+ ==== RETURNS:
437
+
438
+ <tt>:select_ok</tt> if successful.
439
+
440
+ =end
441
+
442
+ def tx_select
443
+ send_frame(Qrack::Protocol09::Tx::Select.new())
444
+
445
+ method = next_method
446
+
447
+ check_response(method, Qrack::Protocol::Tx::SelectOk, "Error initiating transactions for current channel")
448
+
449
+ # return confirmation
450
+ :select_ok
451
+ end
452
+
453
+ private
454
+
455
+ def buffer
456
+ @buffer ||= Qrack::Transport09::Buffer.new(self)
457
+ end
458
+
459
+ end
460
+ end