bunny 1.0.7 → 2.24.0
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.
- checksums.yaml +5 -5
- data/README.md +92 -87
- data/lib/amq/protocol/extensions.rb +2 -0
- data/lib/bunny/authentication/credentials_encoder.rb +2 -0
- data/lib/bunny/authentication/external_mechanism_encoder.rb +2 -0
- data/lib/bunny/authentication/plain_mechanism_encoder.rb +2 -0
- data/lib/bunny/channel.rb +485 -186
- data/lib/bunny/channel_id_allocator.rb +8 -4
- data/lib/bunny/concurrent/atomic_fixnum.rb +2 -0
- data/lib/bunny/concurrent/condition.rb +2 -0
- data/lib/bunny/concurrent/continuation_queue.rb +37 -13
- data/lib/bunny/concurrent/synchronized_sorted_set.rb +2 -0
- data/lib/bunny/consumer.rb +20 -13
- data/lib/bunny/consumer_tag_generator.rb +6 -2
- data/lib/bunny/consumer_work_pool.rb +37 -7
- data/lib/bunny/cruby/socket.rb +51 -22
- data/lib/bunny/cruby/ssl_socket.rb +68 -5
- data/lib/bunny/delivery_info.rb +3 -1
- data/lib/bunny/exceptions.rb +27 -4
- data/lib/bunny/exchange.rb +35 -29
- data/lib/bunny/framing.rb +2 -0
- data/lib/bunny/get_response.rb +85 -0
- data/lib/bunny/heartbeat_sender.rb +9 -6
- data/lib/bunny/message_properties.rb +2 -0
- data/lib/bunny/queue.rb +89 -41
- data/lib/bunny/reader_loop.rb +72 -28
- data/lib/bunny/return_info.rb +2 -0
- data/lib/bunny/session.rb +621 -225
- data/lib/bunny/socket.rb +7 -12
- data/lib/bunny/ssl_socket.rb +7 -12
- data/lib/bunny/test_kit.rb +15 -0
- data/lib/bunny/timeout.rb +3 -12
- data/lib/bunny/timestamp.rb +24 -0
- data/lib/bunny/transport.rb +223 -98
- data/lib/bunny/version.rb +2 -1
- data/lib/bunny/versioned_delivery_tag.rb +2 -0
- data/lib/bunny.rb +54 -8
- metadata +38 -224
- data/.gitignore +0 -22
- data/.rspec +0 -3
- data/.ruby-version +0 -1
- data/.travis.yml +0 -23
- data/.yardopts +0 -8
- data/ChangeLog.md +0 -1092
- data/Gemfile +0 -54
- data/LICENSE +0 -21
- data/benchmarks/basic_publish/with_128K_messages.rb +0 -35
- data/benchmarks/basic_publish/with_1k_messages.rb +0 -35
- data/benchmarks/basic_publish/with_4K_messages.rb +0 -35
- data/benchmarks/basic_publish/with_64K_messages.rb +0 -35
- data/benchmarks/channel_open.rb +0 -28
- data/benchmarks/mutex_and_monitor.rb +0 -42
- data/benchmarks/queue_declare.rb +0 -29
- data/benchmarks/queue_declare_and_bind.rb +0 -29
- data/benchmarks/queue_declare_bind_and_delete.rb +0 -29
- data/benchmarks/synchronized_sorted_set.rb +0 -53
- data/benchmarks/write_vs_write_nonblock.rb +0 -49
- data/bin/ci/before_build.sh +0 -31
- data/bunny.gemspec +0 -40
- data/examples/connection/authentication_failure.rb +0 -16
- data/examples/connection/automatic_recovery_with_basic_get.rb +0 -40
- data/examples/connection/automatic_recovery_with_client_named_queues.rb +0 -36
- data/examples/connection/automatic_recovery_with_multiple_consumers.rb +0 -46
- data/examples/connection/automatic_recovery_with_server_named_queues.rb +0 -35
- data/examples/connection/channel_level_exception.rb +0 -35
- data/examples/connection/disabled_automatic_recovery.rb +0 -34
- data/examples/connection/heartbeat.rb +0 -17
- data/examples/connection/manually_reconnecting_consumer.rb +0 -23
- data/examples/connection/manually_reconnecting_publisher.rb +0 -28
- data/examples/connection/unknown_host.rb +0 -16
- data/examples/guides/exchanges/direct_exchange_routing.rb +0 -36
- data/examples/guides/exchanges/fanout_exchange_routing.rb +0 -28
- data/examples/guides/exchanges/headers_exchange_routing.rb +0 -31
- data/examples/guides/exchanges/mandatory_messages.rb +0 -30
- data/examples/guides/extensions/alternate_exchange.rb +0 -28
- data/examples/guides/extensions/basic_nack.rb +0 -33
- data/examples/guides/extensions/connection_blocked.rb +0 -35
- data/examples/guides/extensions/consumer_cancellation_notification.rb +0 -39
- data/examples/guides/extensions/dead_letter_exchange.rb +0 -32
- data/examples/guides/extensions/exchange_to_exchange_bindings.rb +0 -29
- data/examples/guides/extensions/per_message_ttl.rb +0 -36
- data/examples/guides/extensions/per_queue_message_ttl.rb +0 -36
- data/examples/guides/extensions/publisher_confirms.rb +0 -28
- data/examples/guides/extensions/queue_lease.rb +0 -26
- data/examples/guides/extensions/sender_selected_distribution.rb +0 -32
- data/examples/guides/getting_started/blabbr.rb +0 -27
- data/examples/guides/getting_started/hello_world.rb +0 -20
- data/examples/guides/getting_started/weathr.rb +0 -47
- data/examples/guides/queues/one_off_consumer.rb +0 -23
- data/examples/guides/queues/redeliveries.rb +0 -79
- data/lib/bunny/compatibility.rb +0 -24
- data/lib/bunny/concurrent/linked_continuation_queue.rb +0 -61
- data/lib/bunny/jruby/socket.rb +0 -40
- data/lib/bunny/jruby/ssl_socket.rb +0 -53
- data/lib/bunny/system_timer.rb +0 -20
- data/profiling/basic_publish/with_4K_messages.rb +0 -33
- data/repl +0 -3
- data/spec/compatibility/queue_declare_spec.rb +0 -44
- data/spec/compatibility/queue_declare_with_default_channel_spec.rb +0 -33
- data/spec/higher_level_api/integration/basic_ack_spec.rb +0 -71
- data/spec/higher_level_api/integration/basic_cancel_spec.rb +0 -76
- data/spec/higher_level_api/integration/basic_consume_spec.rb +0 -225
- data/spec/higher_level_api/integration/basic_consume_with_objects_spec.rb +0 -54
- data/spec/higher_level_api/integration/basic_get_spec.rb +0 -48
- data/spec/higher_level_api/integration/basic_nack_spec.rb +0 -79
- data/spec/higher_level_api/integration/basic_publish_spec.rb +0 -89
- data/spec/higher_level_api/integration/basic_qos_spec.rb +0 -29
- data/spec/higher_level_api/integration/basic_recover_spec.rb +0 -18
- data/spec/higher_level_api/integration/basic_reject_spec.rb +0 -74
- data/spec/higher_level_api/integration/basic_return_spec.rb +0 -33
- data/spec/higher_level_api/integration/channel_close_spec.rb +0 -25
- data/spec/higher_level_api/integration/channel_flow_spec.rb +0 -21
- data/spec/higher_level_api/integration/channel_open_spec.rb +0 -57
- data/spec/higher_level_api/integration/confirm_select_spec.rb +0 -19
- data/spec/higher_level_api/integration/connection_spec.rb +0 -400
- data/spec/higher_level_api/integration/connection_stop_spec.rb +0 -26
- data/spec/higher_level_api/integration/consistent_hash_exchange_spec.rb +0 -50
- data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +0 -128
- data/spec/higher_level_api/integration/dead_lettering_spec.rb +0 -52
- data/spec/higher_level_api/integration/exchange_bind_spec.rb +0 -31
- data/spec/higher_level_api/integration/exchange_declare_spec.rb +0 -204
- data/spec/higher_level_api/integration/exchange_delete_spec.rb +0 -105
- data/spec/higher_level_api/integration/exchange_unbind_spec.rb +0 -40
- data/spec/higher_level_api/integration/exclusive_queue_spec.rb +0 -28
- data/spec/higher_level_api/integration/heartbeat_spec.rb +0 -31
- data/spec/higher_level_api/integration/merry_go_round_spec.rb +0 -85
- data/spec/higher_level_api/integration/message_properties_access_spec.rb +0 -95
- data/spec/higher_level_api/integration/predeclared_exchanges_spec.rb +0 -24
- data/spec/higher_level_api/integration/publisher_confirms_spec.rb +0 -77
- data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +0 -65
- data/spec/higher_level_api/integration/queue_bind_spec.rb +0 -109
- data/spec/higher_level_api/integration/queue_declare_spec.rb +0 -190
- data/spec/higher_level_api/integration/queue_delete_spec.rb +0 -41
- data/spec/higher_level_api/integration/queue_purge_spec.rb +0 -30
- data/spec/higher_level_api/integration/queue_unbind_spec.rb +0 -54
- data/spec/higher_level_api/integration/read_only_consumer_spec.rb +0 -60
- data/spec/higher_level_api/integration/sender_selected_distribution_spec.rb +0 -36
- data/spec/higher_level_api/integration/tls_connection_spec.rb +0 -127
- data/spec/higher_level_api/integration/tx_commit_spec.rb +0 -21
- data/spec/higher_level_api/integration/tx_rollback_spec.rb +0 -21
- data/spec/higher_level_api/integration/with_channel_spec.rb +0 -25
- data/spec/issues/issue100_spec.rb +0 -42
- data/spec/issues/issue141_spec.rb +0 -44
- data/spec/issues/issue78_spec.rb +0 -75
- data/spec/issues/issue83_spec.rb +0 -31
- data/spec/issues/issue97_attachment.json +0 -1
- data/spec/issues/issue97_spec.rb +0 -176
- data/spec/lower_level_api/integration/basic_cancel_spec.rb +0 -69
- data/spec/lower_level_api/integration/basic_consume_spec.rb +0 -100
- data/spec/spec_helper.rb +0 -64
- data/spec/stress/channel_open_stress_spec.rb +0 -51
- data/spec/stress/channel_open_stress_with_single_threaded_connection_spec.rb +0 -28
- data/spec/stress/concurrent_consumers_stress_spec.rb +0 -69
- data/spec/stress/concurrent_publishers_stress_spec.rb +0 -57
- data/spec/stress/connection_open_close_spec.rb +0 -40
- data/spec/stress/long_running_consumer_spec.rb +0 -83
- data/spec/tls/cacert.pem +0 -18
- data/spec/tls/client_cert.pem +0 -18
- data/spec/tls/client_key.pem +0 -27
- data/spec/tls/server_cert.pem +0 -18
- data/spec/tls/server_key.pem +0 -27
- data/spec/unit/bunny_spec.rb +0 -15
- data/spec/unit/concurrent/atomic_fixnum_spec.rb +0 -35
- data/spec/unit/concurrent/condition_spec.rb +0 -82
- data/spec/unit/concurrent/linked_continuation_queue_spec.rb +0 -35
- data/spec/unit/concurrent/synchronized_sorted_set_spec.rb +0 -73
- data/spec/unit/system_timer_spec.rb +0 -10
- data/spec/unit/version_delivery_tag_spec.rb +0 -28
data/Gemfile
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
# Use local clones if possible.
|
6
|
-
# If you want to use your local copy, just symlink it to vendor.
|
7
|
-
# See http://blog.101ideas.cz/posts/custom-gems-in-gemfile.html
|
8
|
-
extend Module.new {
|
9
|
-
def gem(name, *args)
|
10
|
-
options = args.last.is_a?(Hash) ? args.last : Hash.new
|
11
|
-
|
12
|
-
local_path = File.expand_path("../vendor/#{name}", __FILE__)
|
13
|
-
if File.exist?(local_path)
|
14
|
-
super name, options.merge(:path => local_path).
|
15
|
-
delete_if { |key, _| [:git, :branch].include?(key) }
|
16
|
-
else
|
17
|
-
super name, *args
|
18
|
-
end
|
19
|
-
end
|
20
|
-
}
|
21
|
-
|
22
|
-
gem "SystemTimer", "~> 1.2.3", :platform => :ruby_18
|
23
|
-
|
24
|
-
gem "rake", ">= 10.0.4"
|
25
|
-
gem "effin_utf8"
|
26
|
-
|
27
|
-
group :development do
|
28
|
-
gem "yard"
|
29
|
-
|
30
|
-
gem "redcarpet", :platform => :mri
|
31
|
-
gem "ruby-prof", :platform => :mri
|
32
|
-
|
33
|
-
gem "json", :platform => :ruby_18
|
34
|
-
end
|
35
|
-
|
36
|
-
group :test do
|
37
|
-
gem "rspec", ">= 2.13.0"
|
38
|
-
end
|
39
|
-
|
40
|
-
gemspec
|
41
|
-
|
42
|
-
# Use local clones if possible.
|
43
|
-
# If you want to use your local copy, just symlink it to vendor.
|
44
|
-
def custom_gem(name, options = Hash.new)
|
45
|
-
local_path = File.expand_path("../vendor/#{name}", __FILE__)
|
46
|
-
if File.exist?(local_path)
|
47
|
-
# puts "Using #{name} from #{local_path}..."
|
48
|
-
gem name, options.merge(:path => local_path).delete_if { |key, _| [:git, :branch].include?(key) }
|
49
|
-
else
|
50
|
-
gem name, options
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
custom_gem "amq-protocol", :git => "git://github.com/ruby-amqp/amq-protocol.git", :branch => "master"
|
data/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
Copyright (c) 2009 – 2013 Chris Duncan, Jakub Stastny aka botanicus,
|
2
|
-
Michael S. Klishin, Eric Lindvall, Stefan Kaes and contributors.
|
3
|
-
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
a copy of this software and associated documentation files (the
|
6
|
-
"Software"), to deal in the Software without restriction, including
|
7
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be
|
13
|
-
included in all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,35 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
require "rubygems"
|
5
|
-
require "bunny"
|
6
|
-
require "benchmark"
|
7
|
-
|
8
|
-
conn = Bunny.new
|
9
|
-
conn.start
|
10
|
-
|
11
|
-
puts
|
12
|
-
puts "-" * 80
|
13
|
-
puts "Benchmarking on #{RUBY_DESCRIPTION}"
|
14
|
-
|
15
|
-
n = 50_000
|
16
|
-
ch = conn.create_channel
|
17
|
-
x = ch.default_exchange
|
18
|
-
s = "z" * (1024 * 128)
|
19
|
-
|
20
|
-
# warm up the JIT, etc
|
21
|
-
puts "Doing a warmup run..."
|
22
|
-
16000.times { x.publish(s, :routing_key => "anything") }
|
23
|
-
|
24
|
-
# give OS, the server and so on some time to catch
|
25
|
-
# up
|
26
|
-
sleep 2.0
|
27
|
-
|
28
|
-
t = Benchmark.realtime do
|
29
|
-
n.times { x.publish(s, :routing_key => "anything") }
|
30
|
-
end
|
31
|
-
r = (n.to_f/t.to_f)
|
32
|
-
|
33
|
-
puts "Publishing rate with #{s.bytesize} bytes/msg: #{(r / 1000).round(2)} KGHz"
|
34
|
-
puts
|
35
|
-
puts "-" * 80
|
@@ -1,35 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
require "rubygems"
|
5
|
-
require "bunny"
|
6
|
-
require "benchmark"
|
7
|
-
|
8
|
-
conn = Bunny.new
|
9
|
-
conn.start
|
10
|
-
|
11
|
-
puts
|
12
|
-
puts "-" * 80
|
13
|
-
puts "Benchmarking on #{RUBY_DESCRIPTION}"
|
14
|
-
|
15
|
-
n = 50_000
|
16
|
-
ch = conn.create_channel
|
17
|
-
x = ch.default_exchange
|
18
|
-
s = "z" * 1024
|
19
|
-
|
20
|
-
# warm up the JIT, etc
|
21
|
-
puts "Doing a warmup run..."
|
22
|
-
16000.times { x.publish(s, :routing_key => "anything") }
|
23
|
-
|
24
|
-
# give OS, the server and so on some time to catch
|
25
|
-
# up
|
26
|
-
sleep 2.0
|
27
|
-
|
28
|
-
t = Benchmark.realtime do
|
29
|
-
n.times { x.publish(s, :routing_key => "anything") }
|
30
|
-
end
|
31
|
-
r = (n.to_f/t.to_f)
|
32
|
-
|
33
|
-
puts "Publishing rate with #{s.bytesize} bytes/msg: #{(r / 1000).round(2)} KGHz"
|
34
|
-
puts
|
35
|
-
puts "-" * 80
|
@@ -1,35 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
require "rubygems"
|
5
|
-
require "bunny"
|
6
|
-
require "benchmark"
|
7
|
-
|
8
|
-
conn = Bunny.new
|
9
|
-
conn.start
|
10
|
-
|
11
|
-
puts
|
12
|
-
puts "-" * 80
|
13
|
-
puts "Benchmarking on #{RUBY_DESCRIPTION}"
|
14
|
-
|
15
|
-
n = 50_000
|
16
|
-
ch = conn.create_channel
|
17
|
-
x = ch.default_exchange
|
18
|
-
s = "z" * 4096
|
19
|
-
|
20
|
-
# warm up the JIT, etc
|
21
|
-
puts "Doing a warmup run..."
|
22
|
-
16000.times { x.publish(s, :routing_key => "anything") }
|
23
|
-
|
24
|
-
# give OS, the server and so on some time to catch
|
25
|
-
# up
|
26
|
-
sleep 2.0
|
27
|
-
|
28
|
-
t = Benchmark.realtime do
|
29
|
-
n.times { x.publish(s, :routing_key => "anything") }
|
30
|
-
end
|
31
|
-
r = (n.to_f/t.to_f)
|
32
|
-
|
33
|
-
puts "Publishing rate with #{s.bytesize} bytes/msg: #{(r / 1000).round(2)} KGHz"
|
34
|
-
puts
|
35
|
-
puts "-" * 80
|
@@ -1,35 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
require "rubygems"
|
5
|
-
require "bunny"
|
6
|
-
require "benchmark"
|
7
|
-
|
8
|
-
conn = Bunny.new
|
9
|
-
conn.start
|
10
|
-
|
11
|
-
puts
|
12
|
-
puts "-" * 80
|
13
|
-
puts "Benchmarking on #{RUBY_DESCRIPTION}"
|
14
|
-
|
15
|
-
n = 50_000
|
16
|
-
ch = conn.create_channel
|
17
|
-
x = ch.default_exchange
|
18
|
-
s = "z" * (1024 * 64)
|
19
|
-
|
20
|
-
# warm up the JIT, etc
|
21
|
-
puts "Doing a warmup run..."
|
22
|
-
16000.times { x.publish(s, :routing_key => "anything") }
|
23
|
-
|
24
|
-
# give OS, the server and so on some time to catch
|
25
|
-
# up
|
26
|
-
sleep 2.0
|
27
|
-
|
28
|
-
t = Benchmark.realtime do
|
29
|
-
n.times { x.publish(s, :routing_key => "anything") }
|
30
|
-
end
|
31
|
-
r = (n.to_f/t.to_f)
|
32
|
-
|
33
|
-
puts "Publishing rate with #{s.bytesize} bytes/msg: #{(r / 1000).round(2)} KGHz"
|
34
|
-
puts
|
35
|
-
puts "-" * 80
|
data/benchmarks/channel_open.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
require "rubygems"
|
5
|
-
require "bunny"
|
6
|
-
require "benchmark"
|
7
|
-
|
8
|
-
conn = Bunny.new
|
9
|
-
conn.start
|
10
|
-
|
11
|
-
puts
|
12
|
-
puts "-" * 80
|
13
|
-
puts "Benchmarking on #{RUBY_DESCRIPTION}"
|
14
|
-
|
15
|
-
n = 500
|
16
|
-
|
17
|
-
# warm up the JIT, etc
|
18
|
-
puts "Doing a warmup run..."
|
19
|
-
1000.times { conn.create_channel }
|
20
|
-
|
21
|
-
t = Benchmark.realtime do
|
22
|
-
n.times { conn.create_channel }
|
23
|
-
end
|
24
|
-
r = (n.to_f/t.to_f)
|
25
|
-
|
26
|
-
puts "channel.open rate: #{(r / 1000).round(2)} KGHz"
|
27
|
-
puts
|
28
|
-
puts "-" * 80
|
@@ -1,42 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
require "rubygems"
|
5
|
-
require "set"
|
6
|
-
require "thread"
|
7
|
-
require "benchmark"
|
8
|
-
require "monitor"
|
9
|
-
|
10
|
-
puts
|
11
|
-
puts "-" * 80
|
12
|
-
puts "Benchmarking on #{RUBY_DESCRIPTION}"
|
13
|
-
|
14
|
-
n = 2_000_000
|
15
|
-
mx = Mutex.new
|
16
|
-
mt = Monitor.new
|
17
|
-
|
18
|
-
# warm up the JIT, etc
|
19
|
-
puts "Doing a warmup run..."
|
20
|
-
n.times do |i|
|
21
|
-
mx.synchronize { 1 }
|
22
|
-
mt.synchronize { 1 }
|
23
|
-
end
|
24
|
-
|
25
|
-
t1 = Benchmark.realtime do
|
26
|
-
n.times do |i|
|
27
|
-
mx.synchronize { 1 }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
r1 = (n.to_f/t1.to_f)
|
31
|
-
|
32
|
-
t2 = Benchmark.realtime do
|
33
|
-
n.times do |i|
|
34
|
-
mt.synchronize { 1 }
|
35
|
-
end
|
36
|
-
end
|
37
|
-
r2 = (n.to_f/t2.to_f)
|
38
|
-
|
39
|
-
puts "Mutex#synchronize, rate: #{(r1 / 1000).round(2)} KGHz"
|
40
|
-
puts "Monitor#synchronize, rate: #{(r2 / 1000).round(2)} KGHz"
|
41
|
-
puts
|
42
|
-
puts "-" * 80
|
data/benchmarks/queue_declare.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
require "rubygems"
|
5
|
-
require "bunny"
|
6
|
-
require "benchmark"
|
7
|
-
|
8
|
-
conn = Bunny.new
|
9
|
-
conn.start
|
10
|
-
ch = conn.create_channel
|
11
|
-
|
12
|
-
puts
|
13
|
-
puts "-" * 80
|
14
|
-
puts "Benchmarking on #{RUBY_DESCRIPTION}"
|
15
|
-
|
16
|
-
n = 4000
|
17
|
-
|
18
|
-
# warm up the JIT, etc
|
19
|
-
puts "Doing a warmup run..."
|
20
|
-
n.times { ch.queue("", :exclusive => true) }
|
21
|
-
|
22
|
-
t = Benchmark.realtime do
|
23
|
-
n.times { ch.queue("", :exclusive => true) }
|
24
|
-
end
|
25
|
-
r = (n.to_f/t.to_f)
|
26
|
-
|
27
|
-
puts "queue.declare (server-named, exclusive = true) rate: #{(r / 1000).round(2)} KGHz"
|
28
|
-
puts
|
29
|
-
puts "-" * 80
|
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
require "rubygems"
|
5
|
-
require "bunny"
|
6
|
-
require "benchmark"
|
7
|
-
|
8
|
-
conn = Bunny.new
|
9
|
-
conn.start
|
10
|
-
ch = conn.create_channel
|
11
|
-
|
12
|
-
puts
|
13
|
-
puts "-" * 80
|
14
|
-
puts "Benchmarking on #{RUBY_DESCRIPTION}"
|
15
|
-
|
16
|
-
n = 4000
|
17
|
-
|
18
|
-
# warm up the JIT, etc
|
19
|
-
puts "Doing a warmup run..."
|
20
|
-
n.times { ch.queue("", :exclusive => true).bind("amq.fanout") }
|
21
|
-
|
22
|
-
t = Benchmark.realtime do
|
23
|
-
n.times { ch.queue("", :exclusive => true).bind("amq.fanout") }
|
24
|
-
end
|
25
|
-
r = (n.to_f/t.to_f)
|
26
|
-
|
27
|
-
puts "queue.declare + queue.bind rate: #{(r / 1000).round(2)} KGHz"
|
28
|
-
puts
|
29
|
-
puts "-" * 80
|
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
require "rubygems"
|
5
|
-
require "bunny"
|
6
|
-
require "benchmark"
|
7
|
-
|
8
|
-
conn = Bunny.new
|
9
|
-
conn.start
|
10
|
-
ch = conn.create_channel
|
11
|
-
|
12
|
-
puts
|
13
|
-
puts "-" * 80
|
14
|
-
puts "Benchmarking on #{RUBY_DESCRIPTION}"
|
15
|
-
|
16
|
-
n = 4000
|
17
|
-
|
18
|
-
# warm up the JIT, etc
|
19
|
-
puts "Doing a warmup run..."
|
20
|
-
n.times { ch.queue("", :exclusive => true).bind("amq.fanout").delete }
|
21
|
-
|
22
|
-
t = Benchmark.realtime do
|
23
|
-
n.times { ch.queue("", :exclusive => true).bind("amq.fanout").delete }
|
24
|
-
end
|
25
|
-
r = (n.to_f/t.to_f)
|
26
|
-
|
27
|
-
puts "queue.declare + queue.bind + queue.delete rate: #{(r / 1000).round(2)} KGHz"
|
28
|
-
puts
|
29
|
-
puts "-" * 80
|
@@ -1,53 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
require "rubygems"
|
5
|
-
require "set"
|
6
|
-
require "thread"
|
7
|
-
require "benchmark"
|
8
|
-
|
9
|
-
require "bunny/concurrent/synchronized_sorted_set"
|
10
|
-
|
11
|
-
puts
|
12
|
-
puts "-" * 80
|
13
|
-
puts "Benchmarking on #{RUBY_DESCRIPTION}"
|
14
|
-
|
15
|
-
n = 2_000_000
|
16
|
-
s = SortedSet.new
|
17
|
-
|
18
|
-
# warm up the JIT, etc
|
19
|
-
puts "Doing a warmup run..."
|
20
|
-
n.times do |i|
|
21
|
-
s << 1
|
22
|
-
s << i
|
23
|
-
s.delete i
|
24
|
-
s << i
|
25
|
-
end
|
26
|
-
|
27
|
-
t1 = Benchmark.realtime do
|
28
|
-
n.times do |i|
|
29
|
-
s << 1
|
30
|
-
s << i
|
31
|
-
s.delete i
|
32
|
-
s << i
|
33
|
-
s.length
|
34
|
-
end
|
35
|
-
end
|
36
|
-
r1 = (n.to_f/t1.to_f)
|
37
|
-
|
38
|
-
s2 = SynchronizedSortedSet.new
|
39
|
-
t2 = Benchmark.realtime do
|
40
|
-
n.times do |i|
|
41
|
-
s2 << 1
|
42
|
-
s2 << i
|
43
|
-
s2.delete i
|
44
|
-
s2 << i
|
45
|
-
s2.length
|
46
|
-
end
|
47
|
-
end
|
48
|
-
r2 = (n.to_f/t2.to_f)
|
49
|
-
|
50
|
-
puts "Mixed sorted set ops, rate: #{(r1 / 1000).round(2)} KGHz"
|
51
|
-
puts "Mixed synchronized sorted set ops, rate: #{(r2 / 1000).round(2)} KGHz"
|
52
|
-
puts
|
53
|
-
puts "-" * 80
|
@@ -1,49 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "benchmark"
|
4
|
-
|
5
|
-
# This tests demonstrates throughput difference of
|
6
|
-
# IO#write and IO#write_nonblock. Note that the two
|
7
|
-
# may not be equivalent depending on your
|
8
|
-
|
9
|
-
r, w = IO.pipe
|
10
|
-
|
11
|
-
# buffer size
|
12
|
-
b = 65536
|
13
|
-
|
14
|
-
read_loop = Thread.new do
|
15
|
-
loop do
|
16
|
-
begin
|
17
|
-
r.read_nonblock(b)
|
18
|
-
rescue Errno::EWOULDBLOCK, Errno::EAGAIN => e
|
19
|
-
IO.select([r])
|
20
|
-
retry
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
n = 10_000
|
26
|
-
# 7 KB
|
27
|
-
s = "a" * (7 * 1024)
|
28
|
-
Benchmark.bm do |meter|
|
29
|
-
meter.report("write:") do
|
30
|
-
n.times { w.write(s.dup) }
|
31
|
-
end
|
32
|
-
meter.report("write + flush:") do
|
33
|
-
n.times { w.write(s.dup); w.flush }
|
34
|
-
end
|
35
|
-
meter.report("write_nonblock:") do
|
36
|
-
n.times do
|
37
|
-
s2 = s.dup
|
38
|
-
begin
|
39
|
-
while !s2.empty?
|
40
|
-
written = w.write_nonblock(s2)
|
41
|
-
s2.slice!(0, written)
|
42
|
-
end
|
43
|
-
rescue Errno::EWOULDBLOCK, Errno::EAGAIN
|
44
|
-
IO.select([], [w])
|
45
|
-
retry
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
data/bin/ci/before_build.sh
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
|
3
|
-
${RABBITMQCTL:="sudo rabbitmqctl"}
|
4
|
-
${RABBITMQ_PLUGINS:="sudo rabbitmq-plugins"}
|
5
|
-
|
6
|
-
# guest:guest has full access to /
|
7
|
-
|
8
|
-
$RABBITMQCTL add_vhost /
|
9
|
-
$RABBITMQCTL add_user guest guest
|
10
|
-
$RABBITMQCTL set_permissions -p / guest ".*" ".*" ".*"
|
11
|
-
|
12
|
-
|
13
|
-
# bunny_gem:bunny_password has full access to bunny_testbed
|
14
|
-
|
15
|
-
$RABBITMQCTL add_vhost bunny_testbed
|
16
|
-
$RABBITMQCTL add_user bunny_gem bunny_password
|
17
|
-
$RABBITMQCTL set_permissions -p bunny_testbed bunny_gem ".*" ".*" ".*"
|
18
|
-
|
19
|
-
|
20
|
-
# guest:guest has full access to bunny_testbed
|
21
|
-
|
22
|
-
$RABBITMQCTL set_permissions -p bunny_testbed guest ".*" ".*" ".*"
|
23
|
-
|
24
|
-
|
25
|
-
# bunny_reader:reader_password has read access to bunny_testbed
|
26
|
-
|
27
|
-
$RABBITMQCTL add_user bunny_reader reader_password
|
28
|
-
$RABBITMQCTL set_permissions -p bunny_testbed bunny_reader "^---$" "^---$" ".*"
|
29
|
-
|
30
|
-
# requires RabbitMQ 3.0+
|
31
|
-
# $RABBITMQ_PLUGINS enable rabbitmq_consistent_hash_exchange
|
data/bunny.gemspec
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
#!/usr/bin/env gem build
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
require "base64"
|
5
|
-
require File.expand_path("../lib/bunny/version", __FILE__)
|
6
|
-
|
7
|
-
Gem::Specification.new do |s|
|
8
|
-
s.name = "bunny"
|
9
|
-
s.version = Bunny::VERSION.dup
|
10
|
-
s.homepage = "http://rubybunny.info"
|
11
|
-
s.summary = "Popular easy to use Ruby client for RabbitMQ"
|
12
|
-
s.description = "Easy to use, feature complete Ruby client for RabbitMQ 2.0 and later versions."
|
13
|
-
s.license = "MIT"
|
14
|
-
|
15
|
-
# Sorted alphabetically.
|
16
|
-
s.authors = [
|
17
|
-
"Chris Duncan",
|
18
|
-
"Eric Lindvall",
|
19
|
-
"Jakub Stastny aka botanicus",
|
20
|
-
"Michael S. Klishin",
|
21
|
-
"Stefan Kaes"]
|
22
|
-
|
23
|
-
s.email = [
|
24
|
-
"Y2VsbGRlZUBnbWFpbC5jb20=\n",
|
25
|
-
"ZXJpY0A1c3RvcHMuY29t\n",
|
26
|
-
"c3Rhc3RueUAxMDFpZGVhcy5jeg==\n",
|
27
|
-
"bWljaGFlbEBub3ZlbWJlcmFpbi5jb20=\n",
|
28
|
-
"c2thZXNAcmFpbHNleHByZXNzLmRl\n"].
|
29
|
-
map { |mail| Base64.decode64(mail) }
|
30
|
-
|
31
|
-
# Dependencies
|
32
|
-
s.add_dependency "amq-protocol", ">= 1.9.2"
|
33
|
-
|
34
|
-
# Files.
|
35
|
-
s.has_rdoc = true
|
36
|
-
s.extra_rdoc_files = ["README.md"]
|
37
|
-
s.files = `git ls-files`.split("\n")
|
38
|
-
s.test_files = `git ls-files -- spec/*`.split("\n")
|
39
|
-
s.require_paths = ["lib"]
|
40
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
require "bundler"
|
5
|
-
Bundler.setup
|
6
|
-
|
7
|
-
$:.unshift(File.expand_path("../../../lib", __FILE__))
|
8
|
-
|
9
|
-
require 'bunny'
|
10
|
-
|
11
|
-
begin
|
12
|
-
conn = Bunny.new("amqp://guest8we78w7e8:guest2378278@127.0.0.1")
|
13
|
-
conn.start
|
14
|
-
rescue Bunny::PossibleAuthenticationFailureError => e
|
15
|
-
puts "Could not authenticate as #{conn.username}"
|
16
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
require "bundler"
|
5
|
-
Bundler.setup
|
6
|
-
|
7
|
-
$:.unshift(File.expand_path("../../../lib", __FILE__))
|
8
|
-
|
9
|
-
require 'bunny'
|
10
|
-
|
11
|
-
conn = Bunny.new(:heartbeat_interval => 8)
|
12
|
-
conn.start
|
13
|
-
|
14
|
-
ch = conn.create_channel
|
15
|
-
x = ch.topic("bunny.examples.recovery.topic", :durable => false)
|
16
|
-
q = ch.queue("bunny.examples.recovery.client_named_queue2", :durable => true)
|
17
|
-
q.purge
|
18
|
-
|
19
|
-
q.bind(x, :routing_key => "abc").bind(x, :routing_key => "def")
|
20
|
-
|
21
|
-
loop do
|
22
|
-
sleep 8
|
23
|
-
body = rand.to_s
|
24
|
-
|
25
|
-
begin
|
26
|
-
x.publish(body, :routing_key => ["abc", "def"].sample)
|
27
|
-
puts "Published #{body}"
|
28
|
-
# happens when a message is published before the connection
|
29
|
-
# is recovered
|
30
|
-
rescue Exception => e
|
31
|
-
end
|
32
|
-
|
33
|
-
sleep 1.5
|
34
|
-
_, _, payload = q.pop
|
35
|
-
if payload
|
36
|
-
puts "Consumed #{payload}"
|
37
|
-
else
|
38
|
-
puts "Consumed nothing"
|
39
|
-
end
|
40
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
require "bundler"
|
5
|
-
Bundler.setup
|
6
|
-
|
7
|
-
$:.unshift(File.expand_path("../../../lib", __FILE__))
|
8
|
-
|
9
|
-
require 'bunny'
|
10
|
-
|
11
|
-
conn = Bunny.new(:heartbeat_interval => 8)
|
12
|
-
conn.start
|
13
|
-
|
14
|
-
ch = conn.create_channel
|
15
|
-
x = ch.topic("bunny.examples.recovery.topic", :durable => false)
|
16
|
-
q = ch.queue("bunny.examples.recovery.client_named_queue1", :durable => false)
|
17
|
-
|
18
|
-
q.bind(x, :routing_key => "abc").bind(x, :routing_key => "def")
|
19
|
-
|
20
|
-
q.subscribe do |delivery_info, metadata, payload|
|
21
|
-
puts "Consumed #{payload}"
|
22
|
-
end
|
23
|
-
|
24
|
-
loop do
|
25
|
-
sleep 2
|
26
|
-
data = rand.to_s
|
27
|
-
rk = ["abc", "def"].sample
|
28
|
-
|
29
|
-
begin
|
30
|
-
x.publish(rand.to_s, :routing_key => rk)
|
31
|
-
puts "Published #{data}, routing key: #{rk}"
|
32
|
-
# happens when a message is published before the connection
|
33
|
-
# is recovered
|
34
|
-
rescue Exception => e
|
35
|
-
end
|
36
|
-
end
|