bunny 1.0.7 → 1.1.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 644fb83ebe90f39169723ddefd72ec581e7e055f
4
- data.tar.gz: f359455c828d498288f5a1ac5aa1a34d008e6982
3
+ metadata.gz: 840a6fefa94a5fef22bdc0a24178ba01498160bb
4
+ data.tar.gz: 98b792aa4957d2109ce984742f7cb50551b6503d
5
5
  SHA512:
6
- metadata.gz: 8ed7e1beffc8b2c86a509009664d9a648cd65afca1c4eebb2d049a157664135d53082a8032ce84373a505d2f964a042c117b46d16f106ee09ba6bbe71bbb0969
7
- data.tar.gz: ef055f07569c758663bd0ed0507430d94062b5d4ab7bae8258bc475d9945f775df0b8f74463fbb2044bd63a9a785509a976b37e2fa58d51e89221116c4ff262c
6
+ metadata.gz: 2f50640dcc07103b1f4d6c54230d27ad658bc8b6870874d781718cfca9910abca7c489bbd44acfb8f6f42a237ddf24afe7c484d6a36ab820d18ad846d1ae5585
7
+ data.tar.gz: 40d9d577e9b65e43882011714cf5f956804818fc692b7d30adc5e131e97ee51ab5b1bcee07434dceb097a571436917bc602078aed331594b32231ef54a8bb2cc
@@ -1,103 +1,18 @@
1
- ## Changes between Bunny 1.0.6 and 1.0.7
1
+ ## Changes between Bunny 1.0.0 and 1.1.0.pre1
2
2
 
3
- ### amq-protocol Update
4
-
5
- Minimum `amq-protocol` version is now `1.9.2` which includes
6
- bug fixes around singed 8 and 16 bit integer decoding.
7
-
8
-
9
-
10
- ## Changes between Bunny 1.0.5 and 1.0.6
11
-
12
- ### Better Exception Handling in Consumers
13
-
14
- Consumer work pools will now correctly catch all exceptions
15
- when dispatching submitted operations, not just `Bunny::Exception`
16
- subclasses.
17
-
18
- ### TLS Without Peer Verification
19
-
20
- Bunny now successfully performs TLS upgrade when peer verification
21
- is disabled.
22
-
23
- Contribute by Jordan Curzon.
24
-
25
- ### Bunny::Session#with_channel Ensures the Channel is Closed
26
-
27
- `Bunny::Session#with_channel` now makes sure the channel is closed
28
- even if provided block raises an exception
3
+ ### User-Provided Loggers
29
4
 
30
- Contributed by Carl Hoerberg.
5
+ Bunny now can use any logger that provides the same API as Ruby standard library's `Logger`:
31
6
 
7
+ ``` ruby
8
+ require "logger"
9
+ require "stringio"
32
10
 
33
- ### Channel Number = 0 is Rejected
34
-
35
- `Bunny::Session#create_channel` will now reject channel number 0.
36
-
37
-
38
-
39
- ## Changes between Bunny 1.0.4 and 1.0.5
40
-
41
- ### Single Threaded Mode Fixes
42
-
43
- Single threaded mode no longer fails with
44
-
45
- ```
46
- undefined method `event_loop'
11
+ io = StringIO.new
12
+ # will log to `io`
13
+ Bunny.new(:logger => Logger.new(io))
47
14
  ```
48
15
 
49
- ### connection.tune.channel_max No Longer Overflows
50
-
51
- `connection.tune.channel_max` could previously be configured to values
52
- greater than 2^16 - 1 (65535). This would result in a silent overflow
53
- during serialization. The issue was harmless in practice but is still
54
- a bug that can be quite confusing.
55
-
56
- Bunny now caps max number of channels to 65535. This allows it to be
57
- forward compatible with future RabbitMQ versions that may allow limiting
58
- total # of open channels via server configuration.
59
-
60
- ### Thread Leaks Fixes
61
-
62
- Bunny will now correctly release heartbeat sender when allocating
63
- a new one (usually happens only when connection recovers from a network
64
- failure).
65
-
66
- ### amq-protocol Update
67
-
68
- Minimum `amq-protocol` version is now `1.9.0` which includes
69
- bug fixes and performance improvements for channel ID allocator.
70
-
71
-
72
-
73
- ## Changes between Bunny 1.0.3 and 1.0.4
74
-
75
- ### Versioned Delivery Tag Fix
76
-
77
- Versioned delivery tag now ensures all the arguments it operates
78
- (original delivery tag, atomic fixnum instances, etc) are coerced to `Integer`
79
- before comparison.
80
-
81
- GitHub issues: #171.
82
-
83
- ## Changes between Bunny 1.0.2 and 1.0.3
84
-
85
- ### Eliminated Errouneous Debug Statement
86
-
87
- `1.0.3` eliminates a debug log message that should have
88
- never made it into a commit.
89
-
90
-
91
- ## Changes between Bunny 1.0.1 and 1.0.2
92
-
93
- ### Fixes CPU Burn on JRuby
94
-
95
- A silly mistake in `1.0.1` testing process ended up reverting
96
- the fix for #165 and #166. This release corrects it.
97
-
98
-
99
- ## Changes between Bunny 1.0.0 and 1.0.1
100
-
101
16
  ### Default CA's Paths Are Disabled on JRuby
102
17
 
103
18
  Bunny uses OpenSSL provided CA certificate paths. This
@@ -115,6 +30,7 @@ certain period of time (the frequency of `EWOULDBLOCK` being raised spiked
115
30
  sharply).
116
31
 
117
32
 
33
+
118
34
  ## Changes between Bunny 1.0.0.rc2 and 1.0.0.rc3
119
35
 
120
36
  ### [Authentication Failure Notification](http://www.rabbitmq.com/auth-notification.html) Support
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
29
29
  map { |mail| Base64.decode64(mail) }
30
30
 
31
31
  # Dependencies
32
- s.add_dependency "amq-protocol", ">= 1.9.2"
32
+ s.add_dependency "amq-protocol", ">= 1.8.0"
33
33
 
34
34
  # Files.
35
35
  s.has_rdoc = true
@@ -1681,7 +1681,7 @@ module Bunny
1681
1681
  @threads_waiting_on_basic_get_continuations.delete(t)
1682
1682
  end
1683
1683
  else
1684
- connection.reader_loop.run_once until @basic_get_continuations.length > 0
1684
+ connection.event_loop.run_once until @basic_get_continuations.length > 0
1685
1685
 
1686
1686
  @basic_get_continuations.pop
1687
1687
  end
@@ -1699,7 +1699,7 @@ module Bunny
1699
1699
  @threads_waiting_on_confirms_continuations.delete(t)
1700
1700
  end
1701
1701
  else
1702
- connection.reader_loop.run_once until @confirms_continuations.length > 0
1702
+ connection.event_loop.run_once until @confirms_continuations.length > 0
1703
1703
 
1704
1704
  @confirms_continuations.pop
1705
1705
  end
@@ -82,10 +82,10 @@ module Bunny
82
82
 
83
83
  begin
84
84
  callable.call
85
- rescue ::Exception => e
86
- # TODO: use connection logger
87
- $stderr.puts e.class.name
88
- $stderr.puts e.message
85
+ rescue Exception => e
86
+ # TODO
87
+ puts e.class.name
88
+ puts e.message
89
89
  end
90
90
  end
91
91
  end
@@ -42,18 +42,6 @@ module Bunny
42
42
  end
43
43
  end
44
44
 
45
- # Can indicate either a channel or connection-level issue
46
- class NotAllowedError < Exception
47
- attr_reader :connection, :connection_close
48
-
49
- def initialize(message, connection, connection_close = nil)
50
- super(message)
51
-
52
- @connection = connection
53
- @connection_close = connection_close
54
- end
55
- end
56
-
57
45
 
58
46
  # Raised when TCP connection to RabbitMQ fails because of an unresolved
59
47
  # hostname, connectivity problem, etc
@@ -36,10 +36,6 @@ module Bunny
36
36
  DEFAULT_HEARTBEAT = :server
37
37
  # @private
38
38
  DEFAULT_FRAME_MAX = 131072
39
- # 2^16 - 1, maximum representable signed 16 bit integer.
40
- # @private
41
- CHANNEL_MAX_LIMIT = 65535
42
- DEFAULT_CHANNEL_MAX = CHANNEL_MAX_LIMIT
43
39
 
44
40
  # backwards compatibility
45
41
  # @private
@@ -82,7 +78,7 @@ module Bunny
82
78
 
83
79
  # @return [Bunny::Transport]
84
80
  attr_reader :transport
85
- attr_reader :status, :host, :port, :heartbeat, :user, :pass, :vhost, :frame_max, :channel_max, :threaded
81
+ attr_reader :status, :host, :port, :heartbeat, :user, :pass, :vhost, :frame_max, :threaded
86
82
  attr_reader :server_capabilities, :server_properties, :server_authentication_mechanisms, :server_locales
87
83
  attr_reader :default_channel
88
84
  attr_reader :channel_id_allocator
@@ -110,6 +106,7 @@ module Bunny
110
106
  # @option connection_string_or_opts [String] :tls_key (nil) Path to client TLS/SSL private key file (.pem)
111
107
  # @option connection_string_or_opts [Array<String>] :tls_ca_certificates Array of paths to TLS/SSL CA files (.pem), by default detected from OpenSSL configuration
112
108
  # @option connection_string_or_opts [Integer] :continuation_timeout (4000) Timeout for client operations that expect a response (e.g. {Bunny::Queue#get}), in milliseconds.
109
+ # @option connection_string_or_opts [Integer] :connection_timeout (5) Timeout in seconds for connecting to the server.
113
110
  #
114
111
  # @option optz [String] :auth_mechanism ("PLAIN") Authentication mechanism, PLAIN or EXTERNAL
115
112
  # @option optz [String] :locale ("PLAIN") Locale RabbitMQ should use
@@ -136,7 +133,7 @@ module Bunny
136
133
  @logfile = opts[:log_file] || opts[:logfile] || STDOUT
137
134
  @threaded = opts.fetch(:threaded, true)
138
135
 
139
- self.init_logger(opts[:log_level] || ENV["BUNNY_LOG_LEVEL"] || Logger::WARN)
136
+ @logger = opts.fetch(:logger, init_logger(opts[:log_level] || ENV["BUNNY_LOG_LEVEL"] || Logger::WARN))
140
137
 
141
138
  # should automatic recovery from network failures be used?
142
139
  @automatically_recover = if opts[:automatically_recover].nil? && opts[:automatic_recovery].nil?
@@ -153,9 +150,7 @@ module Bunny
153
150
 
154
151
  # these are negotiated with the broker during the connection tuning phase
155
152
  @client_frame_max = opts.fetch(:frame_max, DEFAULT_FRAME_MAX)
156
- @client_channel_max = normalize_client_channel_max(opts.fetch(:channel_max, DEFAULT_CHANNEL_MAX))
157
- # will be-renegotiated during connection tuning steps. MK.
158
- @channel_max = @client_channel_max
153
+ @client_channel_max = opts.fetch(:channel_max, 65536)
159
154
  @client_heartbeat = self.heartbeat_from(opts)
160
155
 
161
156
  @client_properties = opts[:properties] || DEFAULT_CLIENT_PROPERTIES
@@ -272,8 +267,6 @@ module Bunny
272
267
  #
273
268
  # @return [Bunny::Channel] Newly opened channel
274
269
  def create_channel(n = nil, consumer_pool_size = 1)
275
- raise ArgumentError, "channel number 0 is reserved in the protocol and cannot be used" if 0 == n
276
-
277
270
  if n && (ch = @channels[n])
278
271
  ch
279
272
  else
@@ -307,11 +300,8 @@ module Bunny
307
300
  # @return [Bunny::Session] self
308
301
  def with_channel(n = nil)
309
302
  ch = create_channel(n)
310
- begin
311
- yield ch
312
- ensure
313
- ch.close if ch.open?
314
- end
303
+ yield ch
304
+ ch.close if ch.open?
315
305
 
316
306
  self
317
307
  end
@@ -657,8 +647,6 @@ module Bunny
657
647
  UnexpectedFrame
658
648
  when 506 then
659
649
  ResourceError
660
- when 530 then
661
- NotAllowedError
662
650
  when 541 then
663
651
  InternalError
664
652
  else
@@ -950,25 +938,7 @@ module Bunny
950
938
  initialize_heartbeat_sender
951
939
  end
952
940
 
953
- unless connection_open_ok.is_a?(AMQ::Protocol::Connection::OpenOk)
954
- if connection_open_ok.is_a?(AMQ::Protocol::Connection::Close)
955
- e = instantiate_connection_level_exception(connection_open_ok)
956
- begin
957
- shut_down_all_consumer_work_pools!
958
- maybe_shutdown_reader_loop
959
- rescue ShutdownSignal => sse
960
- # no-op
961
- rescue Exception => e
962
- @logger.warn "Caught an exception when cleaning up after receiving connection.close: #{e.message}"
963
- ensure
964
- close_transport
965
- end
966
-
967
- @origin_thread.raise(e)
968
- else
969
- raise "could not open connection: server did not respond with connection.open-ok but #{connection_open_ok.inspect} instead"
970
- end
971
- end
941
+ raise "could not open connection: server did not respond with connection.open-ok" unless connection_open_ok.is_a?(AMQ::Protocol::Connection::OpenOk)
972
942
  end
973
943
 
974
944
  def heartbeat_disabled?(val)
@@ -988,7 +958,6 @@ module Bunny
988
958
 
989
959
  # @private
990
960
  def initialize_heartbeat_sender
991
- maybe_shutdown_heartbeat_sender
992
961
  @logger.debug "Initializing heartbeat sender..."
993
962
  @heartbeat_sender = HeartbeatSender.new(@transport, @logger)
994
963
  @heartbeat_sender.start(@heartbeat)
@@ -1050,11 +1019,11 @@ module Bunny
1050
1019
 
1051
1020
  # @private
1052
1021
  def init_logger(level)
1053
- @logger = ::Logger.new(@logfile)
1054
- @logger.level = normalize_log_level(level)
1055
- @logger.progname = self.to_s
1022
+ lgr = ::Logger.new(@logfile)
1023
+ lgr.level = normalize_log_level(level)
1024
+ lgr.progname = self.to_s
1056
1025
 
1057
- @logger
1026
+ lgr
1058
1027
  end
1059
1028
 
1060
1029
  # @private
@@ -1069,24 +1038,6 @@ module Bunny
1069
1038
  Logger::WARN
1070
1039
  end
1071
1040
  end
1072
-
1073
- # @private
1074
- def shut_down_all_consumer_work_pools!
1075
- @channels.each do |_, ch|
1076
- ch.maybe_kill_consumer_work_pool!
1077
- end
1078
- end
1079
-
1080
- def normalize_client_channel_max(n)
1081
- return CHANNEL_MAX_LIMIT if n > CHANNEL_MAX_LIMIT
1082
-
1083
- case n
1084
- when 0 then
1085
- CHANNEL_MAX_LIMIT
1086
- else
1087
- n
1088
- end
1089
- end
1090
1041
  end # Session
1091
1042
 
1092
1043
  # backwards compatibility
@@ -368,14 +368,7 @@ module Bunny
368
368
  # setting TLS/SSL version only works correctly when done
369
369
  # vis set_params. MK.
370
370
  ctx.set_params(:ssl_version => @opts.fetch(:tls_protocol, DEFAULT_TLS_PROTOCOL))
371
-
372
- verify_mode = if @verify_peer
373
- OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT
374
- else
375
- OpenSSL::SSL::VERIFY_NONE
376
- end
377
-
378
- ctx.set_params(:verify_mode => verify_mode)
371
+ ctx.set_params(:verify_mode => OpenSSL::SSL::VERIFY_PEER|OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT) if @verify_peer
379
372
 
380
373
  ctx
381
374
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Bunny
4
4
  # @return [String] Version of the library
5
- VERSION = "1.0.7"
5
+ VERSION = "1.1.0.pre1"
6
6
  end
@@ -21,15 +21,6 @@ describe Bunny::Channel, "when opened" do
21
21
  end
22
22
  end
23
23
 
24
- context "with an explicitly provided id = 0" do
25
- it "raises ArgumentError" do
26
- connection.should be_connected
27
- expect {
28
- connection.create_channel(0)
29
- }.to raise_error(ArgumentError)
30
- end
31
- end
32
-
33
24
 
34
25
  context "with explicitly provided id" do
35
26
  it "uses that id and is successfully opened" do
@@ -147,25 +147,6 @@ describe Bunny::Session do
147
147
  end
148
148
  end
149
149
 
150
- context "initialized with :channel_max => 4096" do
151
- after :each do
152
- subject.close if subject.open?
153
- end
154
-
155
- let(:channel_max) { 1024 }
156
- let(:subject) { described_class.new(:channel_max => channel_max) }
157
-
158
- # this assumes RabbitMQ has no lower value configured. In 3.2
159
- # it is 0 (no limit) by default and 1024 is still a fairly low value
160
- # for future releases. MK.
161
- it "negotiates channel max to be 1024" do
162
- subject.start
163
- subject.channel_max.should == channel_max
164
-
165
- subject.close
166
- end
167
- end
168
-
169
150
  context "initialized with :ssl => true" do
170
151
  let(:subject) do
171
152
  described_class.new(:user => "bunny_gem",
@@ -367,7 +348,7 @@ describe Bunny::Session do
367
348
  end
368
349
 
369
350
 
370
- context "initialized with a disconnected host" do
351
+ context "initialized with unreachable host or port" do
371
352
  it "fails to connect" do
372
353
  lambda do
373
354
  c = described_class.new(:port => 38000)
@@ -397,4 +378,19 @@ describe Bunny::Session do
397
378
  subject.should_not be_open
398
379
  end
399
380
  end
381
+
382
+
383
+ context "initialized with a custom logger object" do
384
+ let(:io) { StringIO.new }
385
+ let(:logger) { ::Logger.new(io) }
386
+
387
+ it "uses provided logger" do
388
+ conn = described_class.new(:hostname => "localhost", :logger => logger)
389
+ conn.start
390
+
391
+ io.string.length.should > 100
392
+
393
+ conn.close
394
+ end
395
+ end
400
396
  end
@@ -38,40 +38,4 @@ describe Bunny::Channel do
38
38
  ch.close
39
39
  end
40
40
  end
41
-
42
-
43
- context "with a single-threaded connection" do
44
- let(:connection) do
45
- c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed", :continuation_timeout => 10000, :threaded => false)
46
- c.start
47
- c
48
- end
49
-
50
-
51
- context "when publishing with confirms enabled" do
52
- it "increments delivery index" do
53
- ch = connection.create_channel
54
- ch.should_not be_using_publisher_confirmations
55
-
56
- ch.confirm_select
57
- ch.should be_using_publisher_confirmations
58
-
59
- q = ch.queue("", :exclusive => true)
60
- x = ch.default_exchange
61
-
62
- n.times do
63
- x.publish("xyzzy", :routing_key => q.name)
64
- end
65
-
66
- ch.next_publish_seq_no.should == n + 1
67
- ch.wait_for_confirms.should be_true
68
- sleep 0.25
69
-
70
- q.message_count.should == n
71
- q.purge
72
-
73
- ch.close
74
- end
75
- end
76
- end
77
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bunny
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.1.0.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Duncan
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-12-23 00:00:00.000000000 Z
15
+ date: 2013-11-18 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: amq-protocol
@@ -20,14 +20,14 @@ dependencies:
20
20
  requirements:
21
21
  - - '>='
22
22
  - !ruby/object:Gem::Version
23
- version: 1.9.2
23
+ version: 1.8.0
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
28
  - - '>='
29
29
  - !ruby/object:Gem::Version
30
- version: 1.9.2
30
+ version: 1.8.0
31
31
  description: Easy to use, feature complete Ruby client for RabbitMQ 2.0 and later
32
32
  versions.
33
33
  email:
@@ -177,7 +177,6 @@ files:
177
177
  - spec/higher_level_api/integration/tls_connection_spec.rb
178
178
  - spec/higher_level_api/integration/tx_commit_spec.rb
179
179
  - spec/higher_level_api/integration/tx_rollback_spec.rb
180
- - spec/higher_level_api/integration/with_channel_spec.rb
181
180
  - spec/issues/issue100_spec.rb
182
181
  - spec/issues/issue141_spec.rb
183
182
  - spec/issues/issue78_spec.rb
@@ -220,12 +219,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
220
219
  version: '0'
221
220
  required_rubygems_version: !ruby/object:Gem::Requirement
222
221
  requirements:
223
- - - '>='
222
+ - - '>'
224
223
  - !ruby/object:Gem::Version
225
- version: '0'
224
+ version: 1.3.1
226
225
  requirements: []
227
226
  rubyforge_project:
228
- rubygems_version: 2.1.11
227
+ rubygems_version: 2.1.6
229
228
  signing_key:
230
229
  specification_version: 4
231
230
  summary: Popular easy to use Ruby client for RabbitMQ
@@ -273,7 +272,6 @@ test_files:
273
272
  - spec/higher_level_api/integration/tls_connection_spec.rb
274
273
  - spec/higher_level_api/integration/tx_commit_spec.rb
275
274
  - spec/higher_level_api/integration/tx_rollback_spec.rb
276
- - spec/higher_level_api/integration/with_channel_spec.rb
277
275
  - spec/issues/issue100_spec.rb
278
276
  - spec/issues/issue141_spec.rb
279
277
  - spec/issues/issue78_spec.rb
@@ -1,25 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Bunny::Channel, "#with_channel" do
4
- let(:connection) do
5
- c = Bunny.new(:user => "bunny_gem", :password => "bunny_password", :vhost => "bunny_testbed")
6
- c.start
7
- c
8
- end
9
-
10
- after :each do
11
- connection.close if connection.open?
12
- end
13
-
14
- it "closes if the block throws an exception" do
15
- ch = nil
16
- begin
17
- connection.with_channel do |wch|
18
- ch = wch
19
- raise Exception.new
20
- end
21
- rescue Exception
22
- end
23
- ch.should be_closed
24
- end
25
- end