bunny 1.7.1 → 2.0.0.rc1

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 (74) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CONTRIBUTING.md +14 -0
  4. data/ChangeLog.md +21 -6
  5. data/Gemfile +1 -1
  6. data/LICENSE +1 -1
  7. data/README.md +22 -23
  8. data/bunny.gemspec +1 -1
  9. data/lib/bunny/channel.rb +12 -0
  10. data/lib/bunny/concurrent/continuation_queue.rb +30 -13
  11. data/lib/bunny/exchange.rb +0 -5
  12. data/lib/bunny/jruby/socket.rb +1 -2
  13. data/lib/bunny/queue.rb +9 -0
  14. data/lib/bunny/session.rb +7 -6
  15. data/lib/bunny/version.rb +1 -1
  16. data/spec/higher_level_api/integration/basic_ack_spec.rb +9 -9
  17. data/spec/higher_level_api/integration/basic_cancel_spec.rb +4 -4
  18. data/spec/higher_level_api/integration/basic_consume_spec.rb +22 -22
  19. data/spec/higher_level_api/integration/basic_consume_with_objects_spec.rb +1 -1
  20. data/spec/higher_level_api/integration/basic_get_spec.rb +2 -2
  21. data/spec/higher_level_api/integration/basic_nack_spec.rb +6 -6
  22. data/spec/higher_level_api/integration/basic_publish_spec.rb +14 -14
  23. data/spec/higher_level_api/integration/basic_qos_spec.rb +11 -2
  24. data/spec/higher_level_api/integration/basic_recover_spec.rb +2 -2
  25. data/spec/higher_level_api/integration/basic_reject_spec.rb +6 -6
  26. data/spec/higher_level_api/integration/basic_return_spec.rb +1 -1
  27. data/spec/higher_level_api/integration/channel_close_spec.rb +2 -2
  28. data/spec/higher_level_api/integration/channel_open_spec.rb +11 -11
  29. data/spec/higher_level_api/integration/connection_recovery_spec.rb +52 -52
  30. data/spec/higher_level_api/integration/connection_spec.rb +83 -83
  31. data/spec/higher_level_api/integration/connection_stop_spec.rb +11 -11
  32. data/spec/higher_level_api/integration/consistent_hash_exchange_spec.rb +2 -2
  33. data/spec/higher_level_api/integration/consumer_cancellation_notification_spec.rb +3 -3
  34. data/spec/higher_level_api/integration/dead_lettering_spec.rb +6 -6
  35. data/spec/higher_level_api/integration/exchange_bind_spec.rb +1 -1
  36. data/spec/higher_level_api/integration/exchange_declare_spec.rb +20 -20
  37. data/spec/higher_level_api/integration/exchange_delete_spec.rb +11 -11
  38. data/spec/higher_level_api/integration/exchange_unbind_spec.rb +2 -2
  39. data/spec/higher_level_api/integration/merry_go_round_spec.rb +2 -2
  40. data/spec/higher_level_api/integration/message_properties_access_spec.rb +27 -27
  41. data/spec/higher_level_api/integration/predeclared_exchanges_spec.rb +1 -1
  42. data/spec/higher_level_api/integration/publisher_confirms_spec.rb +19 -19
  43. data/spec/higher_level_api/integration/publishing_edge_cases_spec.rb +9 -9
  44. data/spec/higher_level_api/integration/queue_bind_spec.rb +13 -13
  45. data/spec/higher_level_api/integration/queue_declare_spec.rb +23 -23
  46. data/spec/higher_level_api/integration/queue_delete_spec.rb +1 -1
  47. data/spec/higher_level_api/integration/queue_purge_spec.rb +2 -2
  48. data/spec/higher_level_api/integration/queue_unbind_spec.rb +2 -2
  49. data/spec/higher_level_api/integration/read_only_consumer_spec.rb +3 -3
  50. data/spec/higher_level_api/integration/sender_selected_distribution_spec.rb +4 -4
  51. data/spec/higher_level_api/integration/tls_connection_spec.rb +5 -5
  52. data/spec/higher_level_api/integration/with_channel_spec.rb +1 -1
  53. data/spec/issues/issue100_spec.rb +9 -10
  54. data/spec/issues/issue141_spec.rb +11 -12
  55. data/spec/issues/issue224_spec.rb +2 -2
  56. data/spec/issues/issue78_spec.rb +14 -18
  57. data/spec/issues/issue83_spec.rb +5 -6
  58. data/spec/issues/issue97_spec.rb +25 -26
  59. data/spec/lower_level_api/integration/basic_cancel_spec.rb +15 -16
  60. data/spec/lower_level_api/integration/basic_consume_spec.rb +19 -20
  61. data/spec/stress/channel_open_stress_spec.rb +1 -1
  62. data/spec/stress/channel_open_stress_with_single_threaded_connection_spec.rb +6 -7
  63. data/spec/stress/concurrent_consumers_stress_spec.rb +6 -7
  64. data/spec/stress/concurrent_publishers_stress_spec.rb +6 -7
  65. data/spec/stress/connection_open_close_spec.rb +6 -6
  66. data/spec/stress/long_running_consumer_spec.rb +6 -7
  67. data/spec/unit/bunny_spec.rb +5 -5
  68. data/spec/unit/concurrent/atomic_fixnum_spec.rb +6 -6
  69. data/spec/unit/concurrent/condition_spec.rb +3 -3
  70. data/spec/unit/concurrent/linked_continuation_queue_spec.rb +2 -2
  71. data/spec/unit/concurrent/synchronized_sorted_set_spec.rb +16 -16
  72. data/spec/unit/system_timer_spec.rb +2 -2
  73. data/spec/unit/version_delivery_tag_spec.rb +3 -3
  74. metadata +8 -7
@@ -20,9 +20,9 @@ describe Bunny::Session do
20
20
  c.start
21
21
  ch = c.create_channel
22
22
 
23
- c.should be_connected
23
+ expect(c).to be_connected
24
24
  c.stop
25
- c.should be_closed
25
+ expect(c).to be_closed
26
26
  end
27
27
 
28
28
  it "can be closed twice (Session#close is idempotent)" do
@@ -30,11 +30,11 @@ describe Bunny::Session do
30
30
  c.start
31
31
  ch = c.create_channel
32
32
 
33
- c.should be_connected
33
+ expect(c).to be_connected
34
34
  c.stop
35
- c.should be_closed
35
+ expect(c).to be_closed
36
36
  c.stop
37
- c.should be_closed
37
+ expect(c).to be_closed
38
38
  end
39
39
 
40
40
  describe "in a single threaded mode" do
@@ -43,9 +43,9 @@ describe Bunny::Session do
43
43
  c.start
44
44
  ch = c.create_channel
45
45
 
46
- c.should be_connected
46
+ expect(c).to be_connected
47
47
  c.stop
48
- c.should be_closed
48
+ expect(c).to be_closed
49
49
  end
50
50
  end
51
51
 
@@ -56,14 +56,14 @@ describe Bunny::Session do
56
56
  c.start
57
57
  ch = c.create_channel
58
58
 
59
- c.should be_open
59
+ expect(c).to be_open
60
60
  close_connection(c.local_port)
61
61
  sleep 0.2
62
- c.should_not be_open
62
+ expect(c).not_to be_open
63
63
 
64
64
  wait_for_recovery
65
- c.should be_open
66
- ch.should be_open
65
+ expect(c).to be_open
66
+ expect(ch).to be_open
67
67
 
68
68
  c.close
69
69
  end
@@ -41,8 +41,8 @@ unless ENV["CI"]
41
41
  end
42
42
 
43
43
  sleep 2.0
44
- q1.message_count.should be > 100
45
- q2.message_count.should be > 100
44
+ expect(q1.message_count).to be > 100
45
+ expect(q2.message_count).to be > 100
46
46
 
47
47
  ch.close
48
48
  end
@@ -34,7 +34,7 @@ describe Bunny::Channel do
34
34
  ch.queue(queue_name, :auto_delete => true).delete
35
35
 
36
36
  sleep 0.5
37
- cancelled.should be_true
37
+ expect(cancelled).to eq true
38
38
 
39
39
  ch.close
40
40
  end
@@ -75,7 +75,7 @@ describe Bunny::Channel do
75
75
  ch.queue(queue_name, :auto_delete => true).delete
76
76
 
77
77
  sleep 0.5
78
- consumer.should be_cancelled
78
+ expect(consumer).to be_cancelled
79
79
 
80
80
  ch.close
81
81
  end
@@ -120,7 +120,7 @@ describe Bunny::Channel do
120
120
  x.publish("abc", :routing_key => queue_name)
121
121
  sleep 0.5
122
122
  q = ch.queue("basic.consume.after_cancellation", :auto_delete => true)
123
- xs.should == ["abc"]
123
+ expect(xs).to eq ["abc"]
124
124
 
125
125
  ch.close
126
126
  end
@@ -23,15 +23,15 @@ describe "A message" do
23
23
  sleep 0.2
24
24
 
25
25
  delivery_info, _, _ = q.pop(:manual_ack => true)
26
- dlq.message_count.should be_zero
26
+ expect(dlq.message_count).to be_zero
27
27
  ch.nack(delivery_info.delivery_tag)
28
28
 
29
29
  sleep 0.2
30
- q.message_count.should be_zero
30
+ expect(q.message_count).to be_zero
31
31
 
32
32
  delivery, properties, body = dlq.pop
33
33
  ds = properties.headers["x-death"]
34
- ds.should_not be_empty
34
+ expect(ds).not_to be_empty
35
35
  expect(ds.first["reason"]).to eq("rejected")
36
36
 
37
37
  dlx.delete
@@ -48,8 +48,8 @@ describe "A message" do
48
48
  x.publish("")
49
49
  sleep 0.2
50
50
 
51
- q.message_count.should be_zero
52
- dlq.message_count.should == 1
51
+ expect(q.message_count).to be_zero
52
+ expect(dlq.message_count).to eq 1
53
53
 
54
54
  dlx.delete
55
55
  end
@@ -67,7 +67,7 @@ describe "A message" do
67
67
 
68
68
  delivery, properties, body = dlq.pop
69
69
  ds = properties.headers["x-death"]
70
- ds.should_not be_empty
70
+ expect(ds).not_to be_empty
71
71
  expect(ds.first["reason"]).to eq("expired")
72
72
 
73
73
  dlx.delete
@@ -24,7 +24,7 @@ describe Bunny::Exchange do
24
24
  source.publish("")
25
25
  sleep 0.5
26
26
 
27
- queue.message_count.should be > 0
27
+ expect(queue.message_count).to be > 0
28
28
 
29
29
  ch.close
30
30
  end
@@ -17,7 +17,7 @@ describe Bunny::Exchange do
17
17
 
18
18
  x = Bunny::Exchange.default(ch)
19
19
 
20
- x.name.should == ''
20
+ expect(x.name).to eq ''
21
21
  end
22
22
  end
23
23
 
@@ -28,7 +28,7 @@ describe Bunny::Exchange do
28
28
 
29
29
  name = "bunny.tests.exchanges.fanout#{rand}"
30
30
  x = ch.fanout(name)
31
- x.name.should == name
31
+ expect(x.name).to eq name
32
32
 
33
33
  x.delete
34
34
  ch.close
@@ -41,7 +41,7 @@ describe Bunny::Exchange do
41
41
 
42
42
  name = "amq.fanout"
43
43
  x = ch.fanout(name)
44
- x.name.should == name
44
+ expect(x.name).to eq name
45
45
 
46
46
  ch.close
47
47
  end
@@ -55,7 +55,7 @@ describe Bunny::Exchange do
55
55
  ch.fanout("amq.test")
56
56
  }.to raise_error(Bunny::AccessRefused)
57
57
 
58
- ch.should be_closed
58
+ expect(ch).to be_closed
59
59
  expect {
60
60
  ch.fanout("amq.test")
61
61
  }.to raise_error(Bunny::ChannelAlreadyClosed)
@@ -68,9 +68,9 @@ describe Bunny::Exchange do
68
68
 
69
69
  name = "bunny.tests.exchanges.durable"
70
70
  x = ch.fanout(name, :durable => true)
71
- x.name.should == name
72
- x.should be_durable
73
- x.should_not be_auto_delete
71
+ expect(x.name).to eq name
72
+ expect(x).to be_durable
73
+ expect(x).not_to be_auto_delete
74
74
 
75
75
  x.delete
76
76
  ch.close
@@ -84,9 +84,9 @@ describe Bunny::Exchange do
84
84
 
85
85
  name = "bunny.tests.exchanges.auto-delete"
86
86
  x = ch.fanout(name, :auto_delete => true)
87
- x.name.should == name
88
- x.should_not be_durable
89
- x.should be_auto_delete
87
+ expect(x.name).to eq name
88
+ expect(x).not_to be_durable
89
+ expect(x).to be_auto_delete
90
90
 
91
91
  ch.exchange(name, :type => :fanout, :auto_delete => true)
92
92
 
@@ -106,7 +106,7 @@ describe Bunny::Exchange do
106
106
  ch.exchange_declare("bunny.tests.exchanges.fanout", :direct, :auto_delete => false, :durable => true)
107
107
  }.to raise_error(Bunny::PreconditionFailed)
108
108
 
109
- ch.should be_closed
109
+ expect(ch).to be_closed
110
110
  expect {
111
111
  ch.fanout("bunny.tests.exchanges.fanout", :auto_delete => true, :durable => false)
112
112
  }.to raise_error(Bunny::ChannelAlreadyClosed)
@@ -121,7 +121,7 @@ describe Bunny::Exchange do
121
121
 
122
122
  name = "bunny.tests.exchanges.direct"
123
123
  x = ch.direct(name)
124
- x.name.should == name
124
+ expect(x.name).to eq name
125
125
 
126
126
  ch.exchange(name, :type => :direct)
127
127
 
@@ -136,7 +136,7 @@ describe Bunny::Exchange do
136
136
 
137
137
  name = "amq.direct"
138
138
  x = ch.direct(name)
139
- x.name.should == name
139
+ expect(x.name).to eq name
140
140
 
141
141
  ch.close
142
142
  end
@@ -150,7 +150,7 @@ describe Bunny::Exchange do
150
150
 
151
151
  name = "bunny.tests.exchanges.topic"
152
152
  x = ch.topic(name)
153
- x.name.should == name
153
+ expect(x.name).to eq name
154
154
 
155
155
  ch.exchange(name, :type => :topic)
156
156
 
@@ -165,7 +165,7 @@ describe Bunny::Exchange do
165
165
 
166
166
  name = "amq.topic"
167
167
  x = ch.topic(name)
168
- x.name.should == name
168
+ expect(x.name).to eq name
169
169
 
170
170
  ch.close
171
171
  end
@@ -179,7 +179,7 @@ describe Bunny::Exchange do
179
179
 
180
180
  name = "bunny.tests.exchanges.headers"
181
181
  x = ch.headers(name)
182
- x.name.should == name
182
+ expect(x.name).to eq name
183
183
 
184
184
  x.delete
185
185
  ch.close
@@ -192,7 +192,7 @@ describe Bunny::Exchange do
192
192
 
193
193
  name = "amq.match"
194
194
  x = ch.headers(name)
195
- x.name.should == name
195
+ expect(x.name).to eq name
196
196
 
197
197
  ch.close
198
198
  end
@@ -204,7 +204,7 @@ describe Bunny::Exchange do
204
204
 
205
205
  name = "amq.headers"
206
206
  x = ch.headers(name)
207
- x.name.should == name
207
+ expect(x.name).to eq name
208
208
 
209
209
  ch.close
210
210
  end
@@ -216,7 +216,7 @@ describe Bunny::Exchange do
216
216
  it "can be declared" do
217
217
  ch = connection.create_channel
218
218
  x = ch.fanout("bunny.tests.exchanges.internal", :internal => true)
219
- x.should be_internal
219
+ expect(x).to be_internal
220
220
  x.delete
221
221
 
222
222
  ch.close
@@ -227,7 +227,7 @@ describe Bunny::Exchange do
227
227
  it "is not internal" do
228
228
  ch = connection.create_channel
229
229
  x = ch.fanout("bunny.tests.exchanges.non-internal")
230
- x.should_not be_internal
230
+ expect(x).not_to be_internal
231
231
  x.delete
232
232
 
233
233
  ch.close
@@ -21,7 +21,7 @@ describe Bunny::Exchange, "#delete" do
21
21
  # no exception as of RabbitMQ 3.2. MK.
22
22
  x.delete
23
23
 
24
- ch.exchanges.size.should == 0
24
+ expect(ch.exchanges.size).to eq 0
25
25
  end
26
26
  end
27
27
 
@@ -43,7 +43,7 @@ describe Bunny::Exchange, "#delete" do
43
43
  ch = connection.create_channel
44
44
  x = ch.direct('amq.direct')
45
45
 
46
- x.delete.should == nil
46
+ expect(x.delete).to eq nil
47
47
  end
48
48
  end
49
49
 
@@ -52,7 +52,7 @@ describe Bunny::Exchange, "#delete" do
52
52
  ch = connection.create_channel
53
53
  x = ch.fanout('amq.fanout')
54
54
 
55
- x.delete.should == nil
55
+ expect(x.delete).to eq nil
56
56
  end
57
57
  end
58
58
 
@@ -61,7 +61,7 @@ describe Bunny::Exchange, "#delete" do
61
61
  ch = connection.create_channel
62
62
  x = ch.topic('amq.topic')
63
63
 
64
- x.delete.should == nil
64
+ expect(x.delete).to eq nil
65
65
  end
66
66
  end
67
67
 
@@ -70,7 +70,7 @@ describe Bunny::Exchange, "#delete" do
70
70
  ch = connection.create_channel
71
71
  x = ch.headers('amq.headers')
72
72
 
73
- x.delete.should == nil
73
+ expect(x.delete).to eq nil
74
74
  end
75
75
  end
76
76
 
@@ -79,7 +79,7 @@ describe Bunny::Exchange, "#delete" do
79
79
  ch = connection.create_channel
80
80
  x = ch.headers('amq.match')
81
81
 
82
- x.delete.should == nil
82
+ expect(x.delete).to eq nil
83
83
  end
84
84
  end
85
85
 
@@ -89,16 +89,16 @@ describe Bunny::Exchange, "#delete" do
89
89
  it "returns true" do
90
90
  ch = connection.create_channel
91
91
 
92
- connection.exchange_exists?("amq.fanout").should be_true
93
- connection.exchange_exists?("amq.direct").should be_true
94
- connection.exchange_exists?("amq.topic").should be_true
95
- connection.exchange_exists?("amq.match").should be_true
92
+ expect(connection.exchange_exists?("amq.fanout")).to eq true
93
+ expect(connection.exchange_exists?("amq.direct")).to eq true
94
+ expect(connection.exchange_exists?("amq.topic")).to eq true
95
+ expect(connection.exchange_exists?("amq.match")).to eq true
96
96
  end
97
97
  end
98
98
 
99
99
  context "when a exchange DOES NOT exist" do
100
100
  it "returns false" do
101
- connection.exchange_exists?("suf89u9a4jo3ndnakls##{Time.now.to_i}").should be_false
101
+ expect(connection.exchange_exists?("suf89u9a4jo3ndnakls##{Time.now.to_i}")).to eq false
102
102
  end
103
103
  end
104
104
  end
@@ -24,14 +24,14 @@ describe Bunny::Exchange do
24
24
  source.publish("")
25
25
  sleep 0.5
26
26
 
27
- queue.message_count.should be == 1
27
+ expect(queue.message_count).to eq 1
28
28
  queue.pop(:manual_ack => true)
29
29
 
30
30
  destination.unbind(source)
31
31
  source.publish("")
32
32
  sleep 0.5
33
33
 
34
- queue.message_count.should be == 0
34
+ expect(queue.message_count).to eq 0
35
35
 
36
36
  source.delete
37
37
  destination.delete
@@ -79,7 +79,7 @@ describe "A message that is proxied by multiple intermediate consumers" do
79
79
  puts "About to sleep for #{t} seconds..."
80
80
  sleep(t)
81
81
 
82
- xs.size.should == n
83
- xs.last.should == "msg #{n - 1}"
82
+ expect(xs.size).to eq n
83
+ expect(xs.last).to eq "msg #{n - 1}"
84
84
  end
85
85
  end
@@ -57,38 +57,38 @@ describe Bunny::Queue, "#subscribe" do
57
57
 
58
58
  sleep 0.7
59
59
 
60
- metadata.content_type.should == "application/octet-stream"
61
- metadata.priority.should == 8
60
+ expect(metadata.content_type).to eq "application/octet-stream"
61
+ expect(metadata.priority).to eq 8
62
62
 
63
63
  time = metadata.headers["time"]
64
- time.year.should == @now.year
65
- time.month.should == @now.month
66
- time.day.should == @now.day
67
- time.hour.should == @now.hour
68
- time.min.should == @now.min
69
- time.sec.should == @now.sec
64
+ expect(time.year).to eq @now.year
65
+ expect(time.month).to eq @now.month
66
+ expect(time.day).to eq @now.day
67
+ expect(time.hour).to eq @now.hour
68
+ expect(time.min).to eq @now.min
69
+ expect(time.sec).to eq @now.sec
70
70
 
71
- metadata.headers["coordinates"]["latitude"].should == 59.35
72
- metadata.headers["participants"].should == 11
73
- metadata.headers["venue"].should == "Stockholm"
74
- metadata.headers["true_field"].should == true
75
- metadata.headers["false_field"].should == false
76
- metadata.headers["nil_field"].should be_nil
77
- metadata.headers["ary_field"].should == ["one", 2.0, 3, [{ "abc" => 123}]]
71
+ expect(metadata.headers["coordinates"]["latitude"]).to eq 59.35
72
+ expect(metadata.headers["participants"]).to eq 11
73
+ expect(metadata.headers["venue"]).to eq "Stockholm"
74
+ expect(metadata.headers["true_field"]).to eq true
75
+ expect(metadata.headers["false_field"]).to eq false
76
+ expect(metadata.headers["nil_field"]).to be_nil
77
+ expect(metadata.headers["ary_field"]).to eq ["one", 2.0, 3, [{ "abc" => 123}]]
78
78
 
79
- metadata.timestamp.should == Time.at(@now.to_i)
80
- metadata.type.should == "kinda.checkin"
81
- metadata.reply_to.should == "a.sender"
82
- metadata.correlation_id.should == "r-1"
83
- metadata.message_id.should == "m-1"
84
- metadata.app_id.should == "bunny.example"
79
+ expect(metadata.timestamp).to eq Time.at(@now.to_i)
80
+ expect(metadata.type).to eq "kinda.checkin"
81
+ expect(metadata.reply_to).to eq "a.sender"
82
+ expect(metadata.correlation_id).to eq "r-1"
83
+ expect(metadata.message_id).to eq "m-1"
84
+ expect(metadata.app_id).to eq "bunny.example"
85
85
 
86
- envelope.consumer_tag.should_not be_nil
87
- envelope.consumer_tag.should_not be_empty
88
- envelope.should_not be_redelivered
89
- envelope.delivery_tag.should == 1
90
- envelope.routing_key.should == queue_name
91
- envelope.exchange.should == ""
86
+ expect(envelope.consumer_tag).not_to be_nil
87
+ expect(envelope.consumer_tag).not_to be_empty
88
+ expect(envelope).not_to be_redelivered
89
+ expect(envelope.delivery_tag).to eq 1
90
+ expect(envelope.routing_key).to eq queue_name
91
+ expect(envelope.exchange).to eq ""
92
92
 
93
93
  ch.close
94
94
  end