sidekick-client 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +52 -0
- data/VERSION +1 -0
- data/lib/ext/README +1 -0
- data/lib/ext/bunny-0.6.0/LICENSE +20 -0
- data/lib/ext/bunny-0.6.0/README.rdoc +66 -0
- data/lib/ext/bunny-0.6.0/Rakefile +24 -0
- data/lib/ext/bunny-0.6.0/bunny.gemspec +65 -0
- data/lib/ext/bunny-0.6.0/examples/simple_08.rb +30 -0
- data/lib/ext/bunny-0.6.0/examples/simple_09.rb +30 -0
- data/lib/ext/bunny-0.6.0/examples/simple_ack_08.rb +33 -0
- data/lib/ext/bunny-0.6.0/examples/simple_ack_09.rb +33 -0
- data/lib/ext/bunny-0.6.0/examples/simple_consumer_08.rb +53 -0
- data/lib/ext/bunny-0.6.0/examples/simple_consumer_09.rb +53 -0
- data/lib/ext/bunny-0.6.0/examples/simple_fanout_08.rb +39 -0
- data/lib/ext/bunny-0.6.0/examples/simple_fanout_09.rb +39 -0
- data/lib/ext/bunny-0.6.0/examples/simple_headers_08.rb +40 -0
- data/lib/ext/bunny-0.6.0/examples/simple_headers_09.rb +40 -0
- data/lib/ext/bunny-0.6.0/examples/simple_publisher_08.rb +27 -0
- data/lib/ext/bunny-0.6.0/examples/simple_publisher_09.rb +27 -0
- data/lib/ext/bunny-0.6.0/examples/simple_topic_08.rb +59 -0
- data/lib/ext/bunny-0.6.0/examples/simple_topic_09.rb +59 -0
- data/lib/ext/bunny-0.6.0/lib/bunny/channel08.rb +39 -0
- data/lib/ext/bunny-0.6.0/lib/bunny/channel09.rb +39 -0
- data/lib/ext/bunny-0.6.0/lib/bunny/client08.rb +494 -0
- data/lib/ext/bunny-0.6.0/lib/bunny/client09.rb +460 -0
- data/lib/ext/bunny-0.6.0/lib/bunny/exchange08.rb +175 -0
- data/lib/ext/bunny-0.6.0/lib/bunny/exchange09.rb +177 -0
- data/lib/ext/bunny-0.6.0/lib/bunny/queue08.rb +389 -0
- data/lib/ext/bunny-0.6.0/lib/bunny/queue09.rb +395 -0
- data/lib/ext/bunny-0.6.0/lib/bunny/subscription08.rb +85 -0
- data/lib/ext/bunny-0.6.0/lib/bunny/subscription09.rb +85 -0
- data/lib/ext/bunny-0.6.0/lib/bunny.rb +87 -0
- data/lib/ext/bunny-0.6.0/lib/qrack/channel.rb +18 -0
- data/lib/ext/bunny-0.6.0/lib/qrack/client.rb +204 -0
- data/lib/ext/bunny-0.6.0/lib/qrack/protocol/protocol08.rb +132 -0
- data/lib/ext/bunny-0.6.0/lib/qrack/protocol/protocol09.rb +133 -0
- data/lib/ext/bunny-0.6.0/lib/qrack/protocol/spec08.rb +823 -0
- data/lib/ext/bunny-0.6.0/lib/qrack/protocol/spec09.rb +521 -0
- data/lib/ext/bunny-0.6.0/lib/qrack/qrack08.rb +23 -0
- data/lib/ext/bunny-0.6.0/lib/qrack/qrack09.rb +23 -0
- data/lib/ext/bunny-0.6.0/lib/qrack/queue.rb +53 -0
- data/lib/ext/bunny-0.6.0/lib/qrack/subscription.rb +102 -0
- data/lib/ext/bunny-0.6.0/lib/qrack/transport/buffer08.rb +276 -0
- data/lib/ext/bunny-0.6.0/lib/qrack/transport/buffer09.rb +276 -0
- data/lib/ext/bunny-0.6.0/lib/qrack/transport/frame08.rb +112 -0
- data/lib/ext/bunny-0.6.0/lib/qrack/transport/frame09.rb +94 -0
- data/lib/ext/bunny-0.6.0/spec/spec_08/bunny_spec.rb +65 -0
- data/lib/ext/bunny-0.6.0/spec/spec_08/connection_spec.rb +12 -0
- data/lib/ext/bunny-0.6.0/spec/spec_08/exchange_spec.rb +162 -0
- data/lib/ext/bunny-0.6.0/spec/spec_08/queue_spec.rb +206 -0
- data/lib/ext/bunny-0.6.0/spec/spec_09/bunny_spec.rb +65 -0
- data/lib/ext/bunny-0.6.0/spec/spec_09/connection_spec.rb +12 -0
- data/lib/ext/bunny-0.6.0/spec/spec_09/exchange_spec.rb +162 -0
- data/lib/ext/bunny-0.6.0/spec/spec_09/queue_spec.rb +205 -0
- data/lib/ext/eventmachine-0.12.10/.gitignore +14 -0
- data/lib/ext/eventmachine-0.12.10/README +82 -0
- data/lib/ext/eventmachine-0.12.10/Rakefile +374 -0
- data/lib/ext/eventmachine-0.12.10/docs/COPYING +60 -0
- data/lib/ext/eventmachine-0.12.10/docs/ChangeLog +211 -0
- data/lib/ext/eventmachine-0.12.10/docs/DEFERRABLES +133 -0
- data/lib/ext/eventmachine-0.12.10/docs/EPOLL +141 -0
- data/lib/ext/eventmachine-0.12.10/docs/GNU +281 -0
- data/lib/ext/eventmachine-0.12.10/docs/INSTALL +13 -0
- data/lib/ext/eventmachine-0.12.10/docs/KEYBOARD +38 -0
- data/lib/ext/eventmachine-0.12.10/docs/LEGAL +25 -0
- data/lib/ext/eventmachine-0.12.10/docs/LIGHTWEIGHT_CONCURRENCY +70 -0
- data/lib/ext/eventmachine-0.12.10/docs/PURE_RUBY +75 -0
- data/lib/ext/eventmachine-0.12.10/docs/RELEASE_NOTES +94 -0
- data/lib/ext/eventmachine-0.12.10/docs/SMTP +2 -0
- data/lib/ext/eventmachine-0.12.10/docs/SPAWNED_PROCESSES +89 -0
- data/lib/ext/eventmachine-0.12.10/docs/TODO +8 -0
- data/lib/ext/eventmachine-0.12.10/eventmachine.gemspec +40 -0
- data/lib/ext/eventmachine-0.12.10/examples/ex_channel.rb +43 -0
- data/lib/ext/eventmachine-0.12.10/examples/ex_queue.rb +2 -0
- data/lib/ext/eventmachine-0.12.10/examples/helper.rb +2 -0
- data/lib/ext/eventmachine-0.12.10/ext/binder.cpp +125 -0
- data/lib/ext/eventmachine-0.12.10/ext/binder.h +46 -0
- data/lib/ext/eventmachine-0.12.10/ext/cmain.cpp +827 -0
- data/lib/ext/eventmachine-0.12.10/ext/cplusplus.cpp +202 -0
- data/lib/ext/eventmachine-0.12.10/ext/ed.cpp +1893 -0
- data/lib/ext/eventmachine-0.12.10/ext/ed.h +424 -0
- data/lib/ext/eventmachine-0.12.10/ext/em.cpp +2282 -0
- data/lib/ext/eventmachine-0.12.10/ext/em.h +232 -0
- data/lib/ext/eventmachine-0.12.10/ext/emwin.cpp +300 -0
- data/lib/ext/eventmachine-0.12.10/ext/emwin.h +94 -0
- data/lib/ext/eventmachine-0.12.10/ext/epoll.cpp +26 -0
- data/lib/ext/eventmachine-0.12.10/ext/epoll.h +25 -0
- data/lib/ext/eventmachine-0.12.10/ext/eventmachine.h +122 -0
- data/lib/ext/eventmachine-0.12.10/ext/eventmachine_cpp.h +96 -0
- data/lib/ext/eventmachine-0.12.10/ext/extconf.rb +148 -0
- data/lib/ext/eventmachine-0.12.10/ext/fastfilereader/extconf.rb +83 -0
- data/lib/ext/eventmachine-0.12.10/ext/fastfilereader/mapper.cpp +214 -0
- data/lib/ext/eventmachine-0.12.10/ext/fastfilereader/mapper.h +59 -0
- data/lib/ext/eventmachine-0.12.10/ext/fastfilereader/rubymain.cpp +127 -0
- data/lib/ext/eventmachine-0.12.10/ext/files.cpp +94 -0
- data/lib/ext/eventmachine-0.12.10/ext/files.h +65 -0
- data/lib/ext/eventmachine-0.12.10/ext/kb.cpp +81 -0
- data/lib/ext/eventmachine-0.12.10/ext/page.cpp +107 -0
- data/lib/ext/eventmachine-0.12.10/ext/page.h +51 -0
- data/lib/ext/eventmachine-0.12.10/ext/pipe.cpp +349 -0
- data/lib/ext/eventmachine-0.12.10/ext/project.h +151 -0
- data/lib/ext/eventmachine-0.12.10/ext/rubymain.cpp +1166 -0
- data/lib/ext/eventmachine-0.12.10/ext/sigs.cpp +89 -0
- data/lib/ext/eventmachine-0.12.10/ext/sigs.h +32 -0
- data/lib/ext/eventmachine-0.12.10/ext/ssl.cpp +460 -0
- data/lib/ext/eventmachine-0.12.10/ext/ssl.h +94 -0
- data/lib/ext/eventmachine-0.12.10/java/.classpath +8 -0
- data/lib/ext/eventmachine-0.12.10/java/.project +17 -0
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EmReactor.java +570 -0
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EmReactorException.java +40 -0
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EventableChannel.java +69 -0
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EventableDatagramChannel.java +189 -0
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/EventableSocketChannel.java +364 -0
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/Application.java +194 -0
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/Connection.java +74 -0
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/ConnectionFactory.java +37 -0
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/DefaultConnectionFactory.java +46 -0
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/PeriodicTimer.java +38 -0
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/application/Timer.java +54 -0
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/ApplicationTest.java +109 -0
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/ConnectTest.java +148 -0
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/EMTest.java +80 -0
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/TestDatagrams.java +53 -0
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/TestServers.java +75 -0
- data/lib/ext/eventmachine-0.12.10/java/src/com/rubyeventmachine/tests/TestTimers.java +90 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/buftok.rb +138 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/callback.rb +26 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/channel.rb +57 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/connection.rb +564 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/deferrable.rb +192 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/file_watch.rb +54 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/future.rb +61 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/messages.rb +66 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/process_watch.rb +44 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/processes.rb +119 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/header_and_content.rb +138 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/httpclient.rb +263 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/httpclient2.rb +590 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/line_and_text.rb +125 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/linetext2.rb +161 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/memcache.rb +323 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/object_protocol.rb +45 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/postgres3.rb +247 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/saslauth.rb +175 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/smtpclient.rb +357 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/smtpserver.rb +547 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/socks4.rb +66 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/stomp.rb +200 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols/tcptest.rb +53 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/protocols.rb +36 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/queue.rb +61 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/spawnable.rb +85 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/streamer.rb +130 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/timers.rb +56 -0
- data/lib/ext/eventmachine-0.12.10/lib/em/version.rb +3 -0
- data/lib/ext/eventmachine-0.12.10/lib/eventmachine.rb +1592 -0
- data/lib/ext/eventmachine-0.12.10/lib/evma/callback.rb +32 -0
- data/lib/ext/eventmachine-0.12.10/lib/evma/container.rb +75 -0
- data/lib/ext/eventmachine-0.12.10/lib/evma/factory.rb +77 -0
- data/lib/ext/eventmachine-0.12.10/lib/evma/protocol.rb +87 -0
- data/lib/ext/eventmachine-0.12.10/lib/evma/reactor.rb +48 -0
- data/lib/ext/eventmachine-0.12.10/lib/evma.rb +32 -0
- data/lib/ext/eventmachine-0.12.10/lib/jeventmachine.rb +257 -0
- data/lib/ext/eventmachine-0.12.10/lib/pr_eventmachine.rb +1022 -0
- data/lib/ext/eventmachine-0.12.10/setup.rb +1585 -0
- data/lib/ext/eventmachine-0.12.10/tasks/cpp.rake_example +77 -0
- data/lib/ext/eventmachine-0.12.10/tests/client.crt +31 -0
- data/lib/ext/eventmachine-0.12.10/tests/client.key +51 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_attach.rb +126 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_basic.rb +284 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_channel.rb +63 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_connection_count.rb +35 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_defer.rb +47 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_epoll.rb +160 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_error_handler.rb +35 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_errors.rb +82 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_exc.rb +55 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_file_watch.rb +49 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_futures.rb +198 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_get_sock_opt.rb +30 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_handler_check.rb +37 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_hc.rb +218 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_httpclient.rb +218 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_httpclient2.rb +153 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_inactivity_timeout.rb +50 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_kb.rb +60 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_ltp.rb +182 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_ltp2.rb +317 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_next_tick.rb +133 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_object_protocol.rb +37 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_pause.rb +70 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_pending_connect_timeout.rb +48 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_process_watch.rb +48 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_processes.rb +128 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_proxy_connection.rb +92 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_pure.rb +125 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_queue.rb +44 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_running.rb +42 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_sasl.rb +72 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_send_file.rb +242 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_servers.rb +76 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_smtpclient.rb +83 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_smtpserver.rb +85 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_spawn.rb +322 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_ssl_args.rb +79 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_ssl_methods.rb +50 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_ssl_verify.rb +82 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_timers.rb +162 -0
- data/lib/ext/eventmachine-0.12.10/tests/test_ud.rb +36 -0
- data/lib/ext/eventmachine-0.12.10/tests/testem.rb +31 -0
- data/lib/ext/eventmachine-0.12.10/web/whatis +7 -0
- data/lib/ext/misc/README +1 -0
- data/lib/ext/misc/indifferent_access.rb +131 -0
- data/lib/ext/uuidtools-2.1.1/CHANGELOG +56 -0
- data/lib/ext/uuidtools-2.1.1/LICENSE +20 -0
- data/lib/ext/uuidtools-2.1.1/README +13 -0
- data/lib/ext/uuidtools-2.1.1/Rakefile +48 -0
- data/lib/ext/uuidtools-2.1.1/lib/compat/securerandom.rb +202 -0
- data/lib/ext/uuidtools-2.1.1/lib/uuidtools/version.rb +35 -0
- data/lib/ext/uuidtools-2.1.1/lib/uuidtools.rb +618 -0
- data/lib/ext/uuidtools-2.1.1/spec/spec.opts +1 -0
- data/lib/ext/uuidtools-2.1.1/spec/spec_helper.rb +7 -0
- data/lib/ext/uuidtools-2.1.1/spec/uuidtools/mac_address_spec.rb +15 -0
- data/lib/ext/uuidtools-2.1.1/spec/uuidtools/utility_spec.rb +21 -0
- data/lib/ext/uuidtools-2.1.1/spec/uuidtools/uuid_creation_spec.rb +121 -0
- data/lib/ext/uuidtools-2.1.1/spec/uuidtools/uuid_parsing_spec.rb +127 -0
- data/lib/ext/uuidtools-2.1.1/tasks/benchmark.rake +38 -0
- data/lib/ext/uuidtools-2.1.1/tasks/clobber.rake +2 -0
- data/lib/ext/uuidtools-2.1.1/tasks/gem.rake +68 -0
- data/lib/ext/uuidtools-2.1.1/tasks/git.rake +40 -0
- data/lib/ext/uuidtools-2.1.1/tasks/metrics.rake +22 -0
- data/lib/ext/uuidtools-2.1.1/tasks/rdoc.rake +29 -0
- data/lib/ext/uuidtools-2.1.1/tasks/rubyforge.rake +89 -0
- data/lib/ext/uuidtools-2.1.1/tasks/spec.rake +64 -0
- data/lib/ext/uuidtools-2.1.1/website/index.html +95 -0
- data/lib/sidekick/client/sidekick_client.rb +46 -0
- data/lib/sidekick/shared/sidekick_logger.rb +14 -0
- data/lib/sidekick/shared/sidekick_queue_publisher.rb +91 -0
- data/lib/sidekick-client.rb +7 -0
- data/sidekick-client.gemspec +289 -0
- data/test/helper.rb +10 -0
- data/test/test_sidekick-client.rb +7 -0
- 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
|