coney_island 0.11.4 → 0.11.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/coney_island.rb +3 -10
- data/lib/coney_island/submitter.rb +56 -11
- data/lib/coney_island/version.rb +1 -1
- data/lib/coney_island/worker.rb +21 -16
- data/test/coney_island_test.rb +0 -27
- data/test/dummy/log/test.log +98 -0
- data/test/submitter_test.rb +25 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b37b8094a18bf7583baf60304ba81a02cc89b28
|
4
|
+
data.tar.gz: f459132ee4aba56f789743faceaa867e098cecae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83cd0ca590537117bf88e426b16f926df260737d5ec911848b15880bbaf79f77ebe6bd7717db2b0295334de1286046b1a87b551cda8f09c944aebd541466dcfc
|
7
|
+
data.tar.gz: 9d92651a39c4c41e35606a69bb27c3e9c70440d901e07b566621ba579e391f95504fdcb35c0d84179b5bafcf74c817e500012908dc392008097ce3f9752bf959
|
data/lib/coney_island.rb
CHANGED
@@ -14,14 +14,6 @@ module ConeyIsland
|
|
14
14
|
@amqp_parameters
|
15
15
|
end
|
16
16
|
|
17
|
-
def self.tcp_connection_retries=(number)
|
18
|
-
@tcp_connection_retries = number
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.tcp_connection_retries
|
22
|
-
@tcp_connection_retries
|
23
|
-
end
|
24
|
-
|
25
17
|
def self.tcp_connection_retry_limit=(limit)
|
26
18
|
@tcp_connection_retry_limit = limit
|
27
19
|
end
|
@@ -30,8 +22,8 @@ module ConeyIsland
|
|
30
22
|
@tcp_connection_retry_limit ||= 6
|
31
23
|
end
|
32
24
|
|
33
|
-
def self.tcp_connection_retry_interval
|
34
|
-
self.tcp_connection_retry_seed **
|
25
|
+
def self.tcp_connection_retry_interval(retries)
|
26
|
+
self.tcp_connection_retry_seed ** retries
|
35
27
|
end
|
36
28
|
|
37
29
|
def self.tcp_connection_retry_seed=(seed)
|
@@ -135,3 +127,4 @@ require 'coney_island/submitter'
|
|
135
127
|
require 'coney_island/job_argument_error'
|
136
128
|
require 'coney_island/railtie' if defined?(Rails)
|
137
129
|
require 'coney_island/performer'
|
130
|
+
require 'bunny'
|
@@ -13,6 +13,14 @@ module ConeyIsland
|
|
13
13
|
@run_inline
|
14
14
|
end
|
15
15
|
|
16
|
+
def self.tcp_connection_retries=(number)
|
17
|
+
@tcp_connection_retries = number
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.tcp_connection_retries
|
21
|
+
@tcp_connection_retries
|
22
|
+
end
|
23
|
+
|
16
24
|
def self.submit(*args)
|
17
25
|
if RequestStore.store[:cache_jobs]
|
18
26
|
job_id = SecureRandom.uuid
|
@@ -51,10 +59,26 @@ module ConeyIsland
|
|
51
59
|
end
|
52
60
|
end
|
53
61
|
|
62
|
+
def self.connection=(conn)
|
63
|
+
@connection = conn
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.connection
|
67
|
+
@connection
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.start_connection
|
71
|
+
@connection.start
|
72
|
+
end
|
73
|
+
|
54
74
|
def self.channel
|
55
75
|
@channel
|
56
76
|
end
|
57
77
|
|
78
|
+
def self.create_channel
|
79
|
+
@channel = self.connection.create_channel
|
80
|
+
end
|
81
|
+
|
58
82
|
def self.exchange
|
59
83
|
@exchange
|
60
84
|
end
|
@@ -76,27 +100,48 @@ module ConeyIsland
|
|
76
100
|
end
|
77
101
|
|
78
102
|
def self.handle_connection
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
103
|
+
Rails.logger.info("ConeyIsland::Submitter.handle_connection connecting...")
|
104
|
+
self.connection = Bunny.new(self.amqp_parameters)
|
105
|
+
self.start_connection
|
106
|
+
|
107
|
+
rescue Bunny::TCPConnectionFailed, Bunny::PossibleAuthenticationFailureError => e
|
108
|
+
self.tcp_connection_retries ||= 0
|
109
|
+
self.tcp_connection_retries += 1
|
110
|
+
if self.tcp_connection_retries >= ConeyIsland.tcp_connection_retry_limit
|
111
|
+
message = "Submitter Failed to connect to RabbitMQ #{ConeyIsland.tcp_connection_retry_limit} times, bailing out"
|
85
112
|
Rails.logger.error(message)
|
86
113
|
ConeyIsland.poke_the_badger(e, {
|
87
114
|
code_source: 'ConeyIsland::Submitter.handle_connection',
|
88
115
|
reason: message}
|
89
116
|
)
|
117
|
+
@connection = nil
|
90
118
|
else
|
91
|
-
message = "Failed to connecto to RabbitMQ Attempt ##{
|
119
|
+
message = "Failed to connecto to RabbitMQ Attempt ##{self.tcp_connection_retries} time(s), trying again in #{ConeyIsland.tcp_connection_retry_interval(self.tcp_connection_retries)} seconds..."
|
92
120
|
Rails.logger.error(message)
|
93
|
-
sleep(
|
121
|
+
sleep(ConeyIsland.tcp_connection_retry_interval(self.tcp_connection_retries))
|
94
122
|
retry
|
95
123
|
end
|
124
|
+
rescue Bunny::ConnectionLevelException => e
|
125
|
+
Rails.logger.error "Submitter Handling a connection-level exception."
|
126
|
+
# Rails.logger.error "Bunny class id : #{e.connection_close.class_id}"
|
127
|
+
# Rails.logger.error "Bunny method id: #{e.connection_close.method_id}"
|
128
|
+
# Rails.logger.error "Status code : #{e.connection_close.reply_code}"
|
129
|
+
# Rails.logger.error "Error message : #{e.connection_close.reply_text}"
|
130
|
+
rescue Bunny::ChannelLevelException => e
|
131
|
+
Rails.logger.error "Submitter Handling a channel-level exception."
|
132
|
+
Rails.logger.error "Bunny class id : #{e.channel_close.class_id}"
|
133
|
+
Rails.logger.error "Bunny method id: #{e.channel_close.method_id}"
|
134
|
+
Rails.logger.error "Status code : #{e.channel_close.reply_code}"
|
135
|
+
Rails.logger.error "Error message : #{e.channel_close.reply_text}"
|
96
136
|
else
|
97
|
-
|
98
|
-
|
99
|
-
|
137
|
+
self.initialize_rabbit
|
138
|
+
self.tcp_connection_retries = 0
|
139
|
+
end
|
140
|
+
|
141
|
+
def self.initialize_rabbit
|
142
|
+
self.create_channel
|
143
|
+
@exchange = self.channel.topic('coney_island')
|
144
|
+
@delay_exchange = self.channel.topic('coney_island_delay')
|
100
145
|
@delay_queue = {}
|
101
146
|
end
|
102
147
|
|
data/lib/coney_island/version.rb
CHANGED
data/lib/coney_island/worker.rb
CHANGED
@@ -17,6 +17,14 @@ module ConeyIsland
|
|
17
17
|
@log = log_thing
|
18
18
|
end
|
19
19
|
|
20
|
+
def self.tcp_connection_retries=(number)
|
21
|
+
@tcp_connection_retries = number
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.tcp_connection_retries
|
25
|
+
@tcp_connection_retries
|
26
|
+
end
|
27
|
+
|
20
28
|
def self.running_jobs
|
21
29
|
@running_jobs ||= []
|
22
30
|
end
|
@@ -114,10 +122,9 @@ module ConeyIsland
|
|
114
122
|
end
|
115
123
|
|
116
124
|
AMQP.connect(self.amqp_parameters) do |connection|
|
117
|
-
self.log.info("Connected to AMQP broker. Running #{AMQP::VERSION}")
|
125
|
+
self.log.info("Worker Connected to AMQP broker. Running #{AMQP::VERSION}")
|
118
126
|
connection.on_error do |conn, connection_close|
|
119
|
-
self.log.error "Handling a connection-level exception."
|
120
|
-
self.log.error
|
127
|
+
self.log.error "Worker Handling a connection-level exception."
|
121
128
|
self.log.error "AMQP class id : #{connection_close.class_id}"
|
122
129
|
self.log.error "AMQP method id: #{connection_close.method_id}"
|
123
130
|
self.log.error "Status code : #{connection_close.reply_code}"
|
@@ -125,23 +132,18 @@ module ConeyIsland
|
|
125
132
|
end
|
126
133
|
#Handle a lost connection to rabbitMQ
|
127
134
|
connection.on_tcp_connection_loss do |connection, settings|
|
128
|
-
# since we lost the connection, rabbitMQ will resend all jobs we didn't finish
|
129
|
-
# so drop them and restart
|
130
135
|
self.log.warn("Lost rabbit connection, attempting to reconnect...")
|
131
136
|
connection.reconnect(true, 1)
|
132
137
|
self.initialize_rabbit(connection)
|
133
|
-
# unless @shutting_down
|
134
|
-
# self.abandon_and_shutdown
|
135
|
-
# end
|
136
138
|
end
|
137
139
|
|
138
140
|
self.initialize_rabbit(connection)
|
139
141
|
end
|
140
142
|
end
|
141
143
|
rescue AMQP::TCPConnectionFailed, AMQP::PossibleAuthenticationFailureError => e
|
142
|
-
|
143
|
-
|
144
|
-
if
|
144
|
+
self.tcp_connection_retries ||= 0
|
145
|
+
self.tcp_connection_retries += 1
|
146
|
+
if self.tcp_connection_retries >= ConeyIsland.tcp_connection_retry_limit
|
145
147
|
message = "Failed to connect to RabbitMQ #{ConeyIsland.tcp_connection_retry_limit} times, bailing out"
|
146
148
|
self.log.error(message)
|
147
149
|
ConeyIsland.poke_the_badger(e, {
|
@@ -150,9 +152,9 @@ module ConeyIsland
|
|
150
152
|
)
|
151
153
|
self.abandon_and_shutdown
|
152
154
|
else
|
153
|
-
message = "Failed to connecto to RabbitMQ Attempt ##{
|
155
|
+
message = "Worker Failed to connecto to RabbitMQ Attempt ##{self.tcp_connection_retries} time(s), trying again in #{ConeyIsland.tcp_connection_retry_interval(self.tcp_connection_retries)} seconds..."
|
154
156
|
self.log.error(message)
|
155
|
-
sleep(ConeyIsland.tcp_connection_retry_interval)
|
157
|
+
sleep(ConeyIsland.tcp_connection_retry_interval(self.tcp_connection_retries))
|
156
158
|
retry
|
157
159
|
end
|
158
160
|
end
|
@@ -161,9 +163,8 @@ module ConeyIsland
|
|
161
163
|
def self.initialize_rabbit(connection)
|
162
164
|
self.log.info('initializing rabbit connection with channel and queue...')
|
163
165
|
@channel = AMQP::Channel.new(connection)
|
164
|
-
channel.on_error do |ch, channel_close|
|
165
|
-
self.log.error "Handling a channel-level exception."
|
166
|
-
self.log.error
|
166
|
+
@channel.on_error do |ch, channel_close|
|
167
|
+
self.log.error "Worker Handling a channel-level exception."
|
167
168
|
self.log.error "AMQP class id : #{channel_close.class_id}"
|
168
169
|
self.log.error "AMQP method id: #{channel_close.method_id}"
|
169
170
|
self.log.error "Status code : #{channel_close.reply_code}"
|
@@ -180,9 +181,13 @@ module ConeyIsland
|
|
180
181
|
self.channel.prefetch @prefetch_count
|
181
182
|
@queue = self.channel.queue(@full_instance_name, auto_delete: false, durable: true)
|
182
183
|
@queue.bind(self.exchange, routing_key: 'carousels.' + @ticket + '.#')
|
184
|
+
if ConeyIsland::Submitter.amqp_connection.respond_to?(:connected?) && !ConeyIsland::Submitter.amqp_connection.connected?
|
185
|
+
ConeyIsland::Submitter.handle_connection
|
186
|
+
end
|
183
187
|
@queue.subscribe(:ack => true) do |metadata,payload|
|
184
188
|
self.handle_incoming_message(metadata,payload)
|
185
189
|
end
|
190
|
+
self.tcp_connection_retries = 0
|
186
191
|
end
|
187
192
|
|
188
193
|
def self.handle_incoming_message(metadata,payload)
|
data/test/coney_island_test.rb
CHANGED
@@ -3,18 +3,6 @@ require 'test_helper'
|
|
3
3
|
class ConeyIslandTest < MiniTest::Test
|
4
4
|
describe "ConeyIsland running jobs" do
|
5
5
|
|
6
|
-
def force_tcp_error
|
7
|
-
lambda do |params|
|
8
|
-
@attempts ||= 0
|
9
|
-
@attempts += 1
|
10
|
-
if @attempts == 1
|
11
|
-
raise AMQP::TCPConnectionFailed.new({host: '127.0.0.1'})
|
12
|
-
else
|
13
|
-
return true
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
6
|
it "runs inline" do
|
19
7
|
ConeyIsland.run_inline
|
20
8
|
my_array = []
|
@@ -34,20 +22,5 @@ class ConeyIslandTest < MiniTest::Test
|
|
34
22
|
ConeyIsland.stop_caching_jobs
|
35
23
|
end
|
36
24
|
|
37
|
-
it "retries on TCP connection errors" do
|
38
|
-
ConeyIsland.stop_running_inline
|
39
|
-
ConeyIsland.tcp_connection_retry_seed = 0
|
40
|
-
@fake_channel = MiniTest::Mock.new
|
41
|
-
@fake_channel.expect :topic, nil, [String]
|
42
|
-
@fake_channel.expect :topic, nil, [String]
|
43
|
-
AMQP::Channel.stub(:new,@fake_channel) do
|
44
|
-
AMQP.stub(:connect, force_tcp_error) do
|
45
|
-
ConeyIsland::Submitter.handle_connection
|
46
|
-
end
|
47
|
-
end
|
48
|
-
@fake_channel.verify
|
49
|
-
ConeyIsland.tcp_connection_retries.must_equal 1
|
50
|
-
end
|
51
|
-
|
52
25
|
end
|
53
26
|
end
|
data/test/dummy/log/test.log
CHANGED
@@ -37,3 +37,101 @@ ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
|
37
37
|
Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
|
38
38
|
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
39
39
|
Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
|
40
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
41
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
42
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
43
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
44
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
45
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
46
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
47
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
48
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
49
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
50
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
51
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
52
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
53
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
54
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
55
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
56
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
57
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
58
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
59
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
60
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
61
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
62
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
63
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
64
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
65
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
66
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
67
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
68
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
69
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
70
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
71
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
72
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
73
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
74
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
75
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
76
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
77
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
78
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
79
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
80
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
81
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
82
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
83
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
84
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
85
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
86
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
87
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
88
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
89
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
90
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
91
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
92
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
93
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
94
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
95
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
96
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
97
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
98
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
99
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
100
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
101
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
102
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
103
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
104
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
105
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
106
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
107
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
108
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
109
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
110
|
+
Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
|
111
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
112
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
113
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
114
|
+
Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
|
115
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
116
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
117
|
+
Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
|
118
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
119
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
120
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
121
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
122
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
123
|
+
Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
|
124
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
125
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
126
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
127
|
+
Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
|
128
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
129
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
130
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
131
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
132
|
+
Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
|
133
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
134
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
135
|
+
Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
|
136
|
+
ConeyIsland::Submitter.handle_connection connecting...
|
137
|
+
ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
|
data/test/submitter_test.rb
CHANGED
@@ -32,6 +32,30 @@ class SubmitterTest < MiniTest::Test
|
|
32
32
|
ConeyIsland::Submitter.publish_job([:not_a_class, :add_to_list, args: [[]]])
|
33
33
|
end
|
34
34
|
end
|
35
|
+
it "retries on TCP connection errors" do
|
36
|
+
ConeyIsland.stop_running_inline
|
37
|
+
ConeyIsland.tcp_connection_retry_seed = 0
|
38
|
+
@fake_channel = Minitest::Mock.new
|
39
|
+
@fake_channel.expect :topic, nil, [String]
|
40
|
+
@fake_channel.expect :topic, nil, [String]
|
41
|
+
force_tcp_error = ->{
|
42
|
+
@attempts ||= 0
|
43
|
+
@attempts += 1
|
44
|
+
if @attempts == 1
|
45
|
+
raise Bunny::TCPConnectionFailed.new({host: '127.0.0.1'})
|
46
|
+
else
|
47
|
+
return true
|
48
|
+
end
|
49
|
+
}
|
50
|
+
ConeyIsland::Submitter.stub(:start_connection,force_tcp_error) do
|
51
|
+
ConeyIsland::Submitter.stub(:create_channel, nil) do
|
52
|
+
ConeyIsland::Submitter.stub(:channel, @fake_channel) do
|
53
|
+
ConeyIsland::Submitter.handle_connection
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
@attempts.must_equal 2
|
58
|
+
end
|
35
59
|
end
|
36
60
|
|
37
61
|
def setup_mock(klass, method, args, expected_work_queue, work_queue=nil)
|
@@ -74,6 +98,7 @@ class SubmitterTest < MiniTest::Test
|
|
74
98
|
end
|
75
99
|
|
76
100
|
end
|
101
|
+
|
77
102
|
end
|
78
103
|
|
79
104
|
class DummyPerformer
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coney_island
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Draut
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-05-
|
13
|
+
date: 2015-05-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -40,6 +40,20 @@ dependencies:
|
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: 1.5.0
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: bunny
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 1.7.0
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 1.7.0
|
43
57
|
- !ruby/object:Gem::Dependency
|
44
58
|
name: request_store
|
45
59
|
requirement: !ruby/object:Gem::Requirement
|