garaio_bunny 2.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +231 -0
  3. data/lib/amq/protocol/extensions.rb +16 -0
  4. data/lib/bunny/authentication/credentials_encoder.rb +55 -0
  5. data/lib/bunny/authentication/external_mechanism_encoder.rb +27 -0
  6. data/lib/bunny/authentication/plain_mechanism_encoder.rb +19 -0
  7. data/lib/bunny/channel.rb +2055 -0
  8. data/lib/bunny/channel_id_allocator.rb +82 -0
  9. data/lib/bunny/concurrent/atomic_fixnum.rb +75 -0
  10. data/lib/bunny/concurrent/condition.rb +66 -0
  11. data/lib/bunny/concurrent/continuation_queue.rb +62 -0
  12. data/lib/bunny/concurrent/linked_continuation_queue.rb +61 -0
  13. data/lib/bunny/concurrent/synchronized_sorted_set.rb +56 -0
  14. data/lib/bunny/consumer.rb +128 -0
  15. data/lib/bunny/consumer_tag_generator.rb +23 -0
  16. data/lib/bunny/consumer_work_pool.rb +122 -0
  17. data/lib/bunny/cruby/socket.rb +110 -0
  18. data/lib/bunny/cruby/ssl_socket.rb +118 -0
  19. data/lib/bunny/delivery_info.rb +93 -0
  20. data/lib/bunny/exceptions.rb +269 -0
  21. data/lib/bunny/exchange.rb +275 -0
  22. data/lib/bunny/framing.rb +56 -0
  23. data/lib/bunny/get_response.rb +83 -0
  24. data/lib/bunny/heartbeat_sender.rb +71 -0
  25. data/lib/bunny/jruby/socket.rb +57 -0
  26. data/lib/bunny/jruby/ssl_socket.rb +58 -0
  27. data/lib/bunny/message_properties.rb +119 -0
  28. data/lib/bunny/queue.rb +393 -0
  29. data/lib/bunny/reader_loop.rb +158 -0
  30. data/lib/bunny/return_info.rb +74 -0
  31. data/lib/bunny/session.rb +1483 -0
  32. data/lib/bunny/socket.rb +14 -0
  33. data/lib/bunny/ssl_socket.rb +14 -0
  34. data/lib/bunny/test_kit.rb +41 -0
  35. data/lib/bunny/timeout.rb +7 -0
  36. data/lib/bunny/transport.rb +526 -0
  37. data/lib/bunny/version.rb +6 -0
  38. data/lib/bunny/versioned_delivery_tag.rb +28 -0
  39. data/lib/bunny.rb +92 -0
  40. metadata +127 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6968f28e951ec5f7c22a54027c77e34ed1ed3cc0a192d8a349c3bd433f31765e
4
+ data.tar.gz: be7bdd9c7913c0055dfb4ebfda34fe494bcd8f18732afe105a6b5bc04979bc1a
5
+ SHA512:
6
+ metadata.gz: 1cdd517b7aa747e75c847cdd65a58fbd4c80b7e3e113d856d96936795aa9eab53d246c5a2f6dae097ca4a40f5e650e7b826e88bf5abaccb239a3de0ee8cccf06
7
+ data.tar.gz: 0c9cfb087ea822402c4383ac1438afb5ea92d5031a065eb29ec3fd9c4082476d312ceb8b07abb3834e3b7e0bb3dc325b250c50e8e2584e99c0087d15cef4932b
data/README.md ADDED
@@ -0,0 +1,231 @@
1
+ # Bunny, a Ruby RabbitMQ Client
2
+
3
+ Bunny is a RabbitMQ client that focuses on ease of use. It
4
+ is feature complete, supports all recent RabbitMQ features and does not
5
+ have any heavyweight dependencies.
6
+
7
+
8
+ ## I Know What RabbitMQ and Bunny are, How Do I Get Started?
9
+
10
+ [Right here](http://rubybunny.info/articles/getting_started.html)!
11
+
12
+
13
+ ## What is Bunny Good For?
14
+
15
+ One can use Bunny to make Ruby applications interoperate with other
16
+ applications (both built in Ruby and not). Complexity and size may vary from
17
+ simple work queues to complex multi-stage data processing workflows that involve
18
+ many applications built with all kinds of technologies.
19
+
20
+ Specific examples:
21
+
22
+ * Events collectors, metrics & analytics applications can aggregate events produced by various applications
23
+ (Web and not) in the company network.
24
+
25
+ * A Web application may route messages to a Java app that works
26
+ with SMS delivery gateways.
27
+
28
+ * MMO games can use flexible routing RabbitMQ provides to propagate event notifications to players and locations.
29
+
30
+ * Price updates from public markets or other sources can be distributed between interested parties, from trading systems to points of sale in a specific geographic region.
31
+
32
+ * Content aggregators may update full-text search and geospatial search indexes
33
+ by delegating actual indexing work to other applications over RabbitMQ.
34
+
35
+ * Companies may provide streaming/push APIs to their customers, partners
36
+ or just general public.
37
+
38
+ * Continuous integration systems can distribute builds between multiple machines with various hardware and software
39
+ configurations using advanced routing features of RabbitMQ.
40
+
41
+ * An application that watches updates from a real-time stream (be it markets data
42
+ or Twitter stream) can propagate updates to interested parties, including
43
+ Web applications that display that information in the real time.
44
+
45
+
46
+ ## Supported Ruby Versions
47
+
48
+ Modern Bunny versions support
49
+
50
+ * CRuby 2.5 through 3.0 (inclusive)
51
+
52
+ Bunny works sufficiently well on JRuby but there are known
53
+ JRuby bugs in versions prior to JRuby 9000 that cause high CPU burn. JRuby users should
54
+ use [March Hare](http://rubymarchhare.info).
55
+
56
+ Bunny `1.7.x` was the last version to support CRuby 1.9.3 and 1.8.7
57
+
58
+
59
+ ## Supported RabbitMQ Versions
60
+
61
+ Modern Bunny releases target [currently supported RabbitMQ release series](https://www.rabbitmq.com/versions.html).
62
+
63
+
64
+ ## Change Log
65
+
66
+ Bunny is a mature library (started in early 2009) with
67
+ a stable public API.
68
+
69
+ Change logs per release series:
70
+
71
+ * [master](https://github.com/ruby-amqp/bunny/blob/master/ChangeLog.md) (most notable changes for all release series)
72
+ * [2.19.x](https://github.com/ruby-amqp/bunny/blob/2.19.x-stable/ChangeLog.md)
73
+
74
+
75
+
76
+ ## Installation & Bundler Dependency
77
+
78
+ ### Most Recent Release
79
+
80
+ [![Gem Version](https://badge.fury.io/rb/bunny.svg)](http://badge.fury.io/rb/bunny)
81
+
82
+ ### With Rubygems
83
+
84
+ To install Bunny with RubyGems:
85
+
86
+ ```
87
+ gem install bunny
88
+ ```
89
+
90
+ ### Bundler Dependency
91
+
92
+ To use Bunny in a project managed with Bundler:
93
+
94
+ ``` ruby
95
+ gem "bunny", ">= 2.19.0"
96
+ ```
97
+
98
+
99
+ ## Quick Start
100
+
101
+ Below is a small snippet that demonstrates how to publish
102
+ and synchronously consume ("pull API") messages with Bunny.
103
+
104
+ For a 15 minute tutorial using more practical examples, see [Getting Started with RabbitMQ and Ruby using Bunny](http://rubybunny.info/articles/getting_started.html).
105
+
106
+ ``` ruby
107
+ require "bunny"
108
+
109
+ # Start a communication session with RabbitMQ
110
+ conn = Bunny.new
111
+ conn.start
112
+
113
+ # open a channel
114
+ ch = conn.create_channel
115
+ ch.confirm_select
116
+
117
+ # declare a queue
118
+ q = ch.queue("test1")
119
+ q.subscribe(manual_ack: true) do |delivery_info, metadata, payload|
120
+ puts "This is the message: #{payload}"
121
+ # acknowledge the delivery so that RabbitMQ can mark it for deletion
122
+ ch.ack(delivery_info.delivery_tag)
123
+ end
124
+
125
+ # publish a message to the default exchange which then gets routed to this queue
126
+ q.publish("Hello, everybody!")
127
+
128
+ # await confirmations from RabbitMQ, see
129
+ # https://www.rabbitmq.com/publishers.html#data-safety for details
130
+ ch.wait_for_confirms
131
+
132
+ # give the above consumer some time consume the delivery and print out the message
133
+ sleep 1
134
+
135
+ puts "Done"
136
+
137
+ ch.close
138
+ # close the connection
139
+ conn.close
140
+ ```
141
+
142
+
143
+ ## Documentation
144
+
145
+ ### Getting Started
146
+
147
+ For a 15 minute tutorial using more practical examples, see [Getting Started with RabbitMQ and Ruby using Bunny](http://rubybunny.info/articles/getting_started.html).
148
+
149
+ ### Guides
150
+
151
+ Bunny documentation guides are available at [rubybunny.info](http://rubybunny.info):
152
+
153
+ * [Queues and Consumers](http://rubybunny.info/articles/queues.html)
154
+ * [Exchanges and Publishers](http://rubybunny.info/articles/exchanges.html)
155
+ * [AMQP 0.9.1 Model Explained](http://www.rabbitmq.com/tutorials/amqp-concepts.html)
156
+ * [Connecting to RabbitMQ](http://rubybunny.info/articles/connecting.html)
157
+ * [Error Handling and Recovery](http://rubybunny.info/articles/error_handling.html)
158
+ * [TLS/SSL Support](http://rubybunny.info/articles/tls.html)
159
+ * [Bindings](http://rubybunny.info/articles/bindings.html)
160
+ * [Using RabbitMQ Extensions with Bunny](http://rubybunny.info/articles/extensions.html)
161
+ * [Durability and Related Matters](http://rubybunny.info/articles/durability.html)
162
+
163
+ Some highly relevant RabbitMQ documentation guides:
164
+
165
+ * [Connections](https://www.rabbitmq.com/connections.html)
166
+ * [Channels](https://www.rabbitmq.com/channels.html)
167
+ * [Queues](https://www.rabbitmq.com/queues.html)
168
+ * [Publishers](https://www.rabbitmq.com/publishers.html)
169
+ * [Consumers](https://www.rabbitmq.com/consumers.html)
170
+ * Data safety: publisher and consumer [Confirmations](https://www.rabbitmq.com/confirms.html)
171
+ * [Production Checklist](https://www.rabbitmq.com/production-checklist.html)
172
+
173
+ ### API Reference
174
+
175
+ [Bunny API Reference](http://reference.rubybunny.info/).
176
+
177
+
178
+ ## Community and Getting Help
179
+
180
+ ### Mailing List
181
+
182
+ [Bunny has a mailing list](http://groups.google.com/group/ruby-amqp). Please use it for all questions,
183
+ investigations, and discussions. GitHub issues should be used for specific, well understood, actionable
184
+ maintainers and contributors can work on.
185
+
186
+ We encourage you to also join the [RabbitMQ mailing list](https://groups.google.com/forum/#!forum/rabbitmq-users)
187
+ mailing list. Feel free to ask any questions that you may have.
188
+
189
+
190
+ ## Continuous Integration
191
+
192
+ [![Build Status](https://travis-ci.org/ruby-amqp/bunny.svg)](https://travis-ci.org/ruby-amqp/bunny/)
193
+
194
+
195
+ ### News & Announcements on Twitter
196
+
197
+ To subscribe for announcements of releases, important changes and so on, please follow [@rubyamqp](https://twitter.com/#!/rubyamqp) on Twitter.
198
+
199
+ More detailed announcements can be found in the [RabbitMQ Ruby clients blog](http://blog.rubyrabbitmq.info).
200
+
201
+
202
+ ### Reporting Issues
203
+
204
+ If you find a bug you understand well, poor default, incorrect or unclear piece of documentation,
205
+ or missing feature, please [file an
206
+ issue](http://github.com/ruby-amqp/bunny/issues) on GitHub.
207
+
208
+ Please use [Bunny's mailing list](http://groups.google.com/group/ruby-amqp) for questions,
209
+ investigations, and discussions. GitHub issues should be used for specific, well understood, actionable
210
+ maintainers and contributors can work on.
211
+
212
+ When filing an issue, please specify which Bunny and RabbitMQ versions you
213
+ are using, provide recent RabbitMQ log file contents, full exception stack traces,
214
+ and steps to reproduce (or failing test cases).
215
+
216
+
217
+ ## Other Ruby RabbitMQ Clients
218
+
219
+ The other widely used Ruby RabbitMQ client is [March Hare](http://rubymarchhare.info) (JRuby-only).
220
+ It's a mature library that require RabbitMQ 3.3.x or later.
221
+
222
+
223
+ ## Contributing
224
+
225
+ See [CONTRIBUTING.md](./CONTRIBUTING.md) for more information
226
+ about running various test suites.
227
+
228
+
229
+ ## License
230
+
231
+ Released under the MIT license.
@@ -0,0 +1,16 @@
1
+ # @private
2
+ module AMQ
3
+ # @private
4
+ module Protocol
5
+ # @private
6
+ class Basic
7
+ # Extended to allow wrapping delivery tag into
8
+ # a versioned one.
9
+ #
10
+ # @private
11
+ class GetOk
12
+ attr_writer :delivery_tag
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,55 @@
1
+ module Bunny
2
+ # Contains credentials encoding implementations for various
3
+ # authentication strategies.
4
+ module Authentication
5
+ # Base credentials encoder. Subclasses implement credentials encoding for
6
+ # a particular authentication mechanism (PLAIN, EXTERNAL, etc).
7
+ #
8
+ # @api plugin
9
+ class CredentialsEncoder
10
+
11
+ #
12
+ # API
13
+ #
14
+
15
+ # Session that uses this encoder
16
+ # @return [Bunny::Session]
17
+ attr_reader :session
18
+
19
+ # Instantiates a new encoder for the authentication mechanism
20
+ # used by the provided session.
21
+ #
22
+ # @return [Bunny::CredentialsEncoder]
23
+ def self.for_session(session)
24
+ registry[session.mechanism].new(session)
25
+ end
26
+
27
+ # @private
28
+ def self.registry
29
+ @@registry ||= Hash.new { raise NotImplementedError }
30
+ end
31
+
32
+ # Registers an encoder for authentication mechanism
33
+ # @api plugin
34
+ def self.auth_mechanism(*mechanisms)
35
+ mechanisms.each do |m|
36
+ registry[m] = self
37
+ end
38
+ end
39
+
40
+ # Encodes provided credentials according to the specific authentication
41
+ # mechanism
42
+ # @return [String] Encoded credentials
43
+ def encode_credentials(username, challenge)
44
+ raise NotImplementedError.new("Subclasses must override this method")
45
+ end
46
+
47
+ protected
48
+
49
+ def initialize(session)
50
+ @session = session
51
+ end
52
+
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,27 @@
1
+ require "bunny/authentication/credentials_encoder"
2
+
3
+ module Bunny
4
+ module Authentication
5
+ # Encodes credentials using the EXTERNAL mechanism
6
+ class ExternalMechanismEncoder < CredentialsEncoder
7
+
8
+ auth_mechanism "EXTERNAL", "external"
9
+
10
+ # Encodes a username and password for the EXTERNAL mechanism. Since
11
+ # authentication is handled by an encapsulating protocol like SSL or
12
+ # UNIX domain sockets, EXTERNAL doesn't pass along any username or
13
+ # password information at all and this method always returns the
14
+ # empty string.
15
+ #
16
+ # @param [String] username The username to encode. This parameter is
17
+ # ignored.
18
+ # @param [String] password The password to encode. This parameter is
19
+ # ignored.
20
+ # @return [String] The username and password, encoded for the
21
+ # EXTERNAL mechanism. This is always the empty string.
22
+ def encode_credentials(username, password)
23
+ ""
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,19 @@
1
+ require "bunny/authentication/credentials_encoder"
2
+
3
+ module Bunny
4
+ module Authentication
5
+ # Encodes credentials using the PLAIN mechanism
6
+ class PlainMechanismEncoder < CredentialsEncoder
7
+
8
+ auth_mechanism "PLAIN", "plain"
9
+
10
+ # Encodes provided credentials as described in RFC 2595
11
+ # @api public
12
+ # @see http://tools.ietf.org/rfc/rfc2595.txt RFC 2595
13
+ def encode_credentials(username, password)
14
+ "\0#{username}\0#{password}"
15
+ end
16
+
17
+ end
18
+ end
19
+ end