coney_island 0.12.4 → 0.12.5

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: 3ebf4aa13f64b3592f798c759e5a28a5e17c84ab
4
- data.tar.gz: b22573d2f20af9c3e212351632615e38e2b39aae
3
+ metadata.gz: 050d03c1dc851560dddc25519b8617422ff2adb5
4
+ data.tar.gz: ab3a5e5547555b561cead2a49974d328515759bc
5
5
  SHA512:
6
- metadata.gz: e31f447e805176a230c56540099b49dfc5f348287a9cfd957398cd8ebd7017debf9a5c605d650cbb6999d6acdd10d8b134642763d981f5febd30d9ef8da811ee
7
- data.tar.gz: 767d5f3ef2575904e57cf6b53f2da1f48e6aba5e6e74efa5e476064ef4f601812ca017ac0dbbe533f4274306669699f67f3b28fde51abe98fcd66f09faf57e0f
6
+ metadata.gz: 5a5831c75657774b8ed15ba2f2433cb56f11f712e1c886afa4be2f50176f1e73f0c2cbf09cf6ee6e38278e5bed33e00f67dbc2c0e4be8433424ab16ea13e7594
7
+ data.tar.gz: b7eec6034c0934a255be9c66bbc885e5f8d38189543ab43a3db90714b4d258dc5f312593dbccaaa22927f99202e73c8be41a93feedba0e081853ec0228664f15
@@ -65,18 +65,7 @@ module ConeyIsland
65
65
 
66
66
  def handle_job
67
67
  ConeyIsland::Worker.running_jobs << self
68
- Timeout::timeout(timeout) do
69
- execute_job_method
70
- end
71
- rescue Timeout::Error => e
72
- if self.attempts >= self.retry_limit
73
- log.error("Request #{self.id} timed out after #{self.timeout} seconds, bailing out after 3 attempts")
74
- ConeyIsland.poke_the_badger(e, {work_queue: self.ticket, job_payload: self.args, reason: 'Bailed out after 3 attempts'})
75
- else
76
- log.error("Request #{self.id} timed out after #{self.timeout} seconds on attempt number #{self.attempts}, retrying...")
77
- self.attempts += 1
78
- ConeyIsland.submit(self.klass, self.method_name, self.resubmit_args)
79
- end
68
+ execute_job_method
80
69
  rescue StandardError => e
81
70
  log.error("Error executing #{self.class_name}##{self.method_name} #{self.id} for id #{self.instance_id} with args #{self.args}:")
82
71
  log.error(e.message)
@@ -1,4 +1,6 @@
1
1
  module ConeyIsland
2
+ # TODO: Refactor this to instantiate and use instance methods for
3
+ # ease of testing and thread safety.
2
4
  class Submitter
3
5
 
4
6
  def self.run_inline
@@ -98,6 +100,10 @@ module ConeyIsland
98
100
  end
99
101
  end
100
102
 
103
+ def self.connected?
104
+ !!connection && connection.connected?
105
+ end
106
+
101
107
  def self.handle_connection
102
108
  Rails.logger.info("ConeyIsland::Submitter.handle_connection connecting...")
103
109
  self.connection = Bunny.new(self.amqp_parameters)
@@ -179,6 +185,9 @@ module ConeyIsland
179
185
  work_queue ||= ConeyIsland.default_settings[:work_queue]
180
186
  delay ||= ConeyIsland.default_settings[:delay]
181
187
 
188
+ # Make sure we have a connection if we need one
189
+ handle_connection if !running_inline? && !connected?
190
+
182
191
  if self.running_inline?
183
192
  # Just run this inline if we're not threaded
184
193
  ConeyIsland::Job.new(nil, job_args).handle_job
@@ -1,3 +1,3 @@
1
1
  module ConeyIsland
2
- VERSION = "0.12.4"
2
+ VERSION = "0.12.5"
3
3
  end
@@ -168,3 +168,29 @@ ConeyIsland::Submitter.handle_connection connecting...
168
168
  Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
169
169
  ConeyIsland::Submitter.handle_connection connecting...
170
170
  ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
171
+ ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
172
+ ConeyIsland::Submitter.handle_connection connecting...
173
+ ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
174
+ ConeyIsland::Submitter.handle_connection connecting...
175
+ Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
176
+ ConeyIsland::Submitter.handle_connection connecting...
177
+ ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
178
+ ConeyIsland::Submitter.handle_connection connecting...
179
+ Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
180
+ ConeyIsland::Submitter.handle_connection connecting...
181
+ ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
182
+ ConeyIsland::Submitter.handle_connection connecting...
183
+ Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
184
+ ConeyIsland::Submitter.handle_connection connecting...
185
+ ConeyIsland::Submitter.handle_connection connecting...
186
+ Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
187
+ ConeyIsland::Submitter.handle_connection connecting...
188
+ ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
189
+ ConeyIsland::Submitter.handle_connection connecting...
190
+ Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
191
+ ConeyIsland::Submitter.handle_connection connecting...
192
+ ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
193
+ ConeyIsland::Submitter.submit! about to iterate over this many jobs: 1
194
+ ConeyIsland::Submitter.handle_connection connecting...
195
+ Failed to connecto to RabbitMQ Attempt #1 time(s), trying again in 0 seconds...
196
+ ConeyIsland::Submitter.handle_connection connecting...
data/test/job_test.rb CHANGED
@@ -8,42 +8,6 @@ class JobTest < MiniTest::Test
8
8
  @metadata.expect :ack, nil
9
9
  end
10
10
 
11
- it "retries on timeout with correct initial attempt_count and delay" do
12
- job = ConeyIsland::Job.new(@metadata,
13
- { 'klass' => 'TestModel',
14
- 'method_name' => :take_too_long,
15
- 'timeout' => 0.0001 }
16
- )
17
- capture_submissions = lambda { |klass,method_name,options|
18
- ::JobTest.messages[:job_options] ||= []
19
- ::JobTest.messages[:job_options] << options
20
- }
21
- ConeyIsland.stub(:submit, capture_submissions) do
22
- job.handle_job
23
- end
24
- ::JobTest.messages[:job_options].last['attempt_count'].must_equal 2
25
- ::JobTest.messages[:job_options].last['delay'].must_equal 2
26
- end
27
-
28
- it "retries on timeout with correct subsequent attempt_count and delay" do
29
- job = ConeyIsland::Job.new(@metadata,
30
- { 'klass' => 'TestModel',
31
- 'method_name' => :take_too_long,
32
- 'timeout' => 0.0001,
33
- 'attempt_count' => 2,
34
- 'delay' => 2 }
35
- )
36
- capture_submissions = lambda { |klass,method_name,options|
37
- ::JobTest.messages[:job_options] ||= []
38
- ::JobTest.messages[:job_options] << options
39
- }
40
- ConeyIsland.stub(:submit, capture_submissions) do
41
- job.handle_job
42
- end
43
- ::JobTest.messages[:job_options].last['attempt_count'].must_equal 3
44
- ::JobTest.messages[:job_options].last['delay'].must_equal 4
45
- end
46
-
47
11
  it "bails out on timeout if retry limit reached" do
48
12
  ConeyIsland.stop_running_inline
49
13
  job = ConeyIsland::Job.new(@metadata,
@@ -151,4 +115,4 @@ class JobTest < MiniTest::Test
151
115
 
152
116
  end
153
117
  end
154
- end
118
+ end
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.12.4
4
+ version: 0.12.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-28 00:00:00.000000000 Z
13
+ date: 2015-08-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -44,16 +44,16 @@ dependencies:
44
44
  name: bunny
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ">="
47
+ - - "<"
48
48
  - !ruby/object:Gem::Version
49
- version: 1.7.0
49
+ version: '2.0'
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - ">="
54
+ - - "<"
55
55
  - !ruby/object:Gem::Version
56
- version: 1.7.0
56
+ version: '2.0'
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: request_store
59
59
  requirement: !ruby/object:Gem::Requirement
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
194
  version: '0'
195
195
  requirements: []
196
196
  rubyforge_project:
197
- rubygems_version: 2.2.2
197
+ rubygems_version: 2.4.5
198
198
  signing_key:
199
199
  specification_version: 4
200
200
  summary: Want guaranteed delivery between your queue and your workers using ACKs?