backburner-allq 1.0.12 → 1.0.18

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7876b8c587bb8dcd70760ec2f29395d5c37cb14c0e4980217a9a8b4e6c4163a5
4
- data.tar.gz: 40fbe69e88ab561358a19035ae102e345635891fc7bd9ff1c24b9d0beb033e4e
3
+ metadata.gz: a66b297949437303186f84d3ab4198416a72824de72142dd4727aa029365f119
4
+ data.tar.gz: b737ec4f3df6378167da3d5936c408ea6b1a92b05391c3c4ab9021160108492c
5
5
  SHA512:
6
- metadata.gz: 345458382a5f37e53b816d3ede71ae75ec3abf82fff70c5a2607184992303ee00b3f2351bfa8ff4b770191369aaddb7b82aeb9255cfc92d3f0c893f21ac4bb54
7
- data.tar.gz: 7fb582110bc654bf7645584e70c01a3c681c4c4137db190dead765c73146882931251f9292a291b2faab8976383e595b062df22bf1bacc88ddf3940575dd7671
6
+ metadata.gz: 02ec21561843632c02a39742c7eef8591f94a7320af93bc77d566bc6e5d390c089fdeef1b56b5df3865a3430ad3e7a350b51d9faebfdb2fcebd4944905c4150e
7
+ data.tar.gz: 51ffee578303fd24e70278788153cc6265a356ddab6882c8bd62c7447c8434f7949b7d4deb35affd8a14d7d4f295d1494d48d89dc27e0eec9bf4c06ee69093b0
data/deploy.sh CHANGED
@@ -1,3 +1,3 @@
1
1
  echo "Did you update the version?"
2
2
  gem build backburner-allq.gemspec
3
- gem push backburner-allq-1.0.12.gem
3
+ gem push backburner-allq-1.0.18.gem
@@ -13,14 +13,16 @@ module Backburner
13
13
 
14
14
  def watch
15
15
  Thread.new do
16
- ran = false
17
- job = @allq_wrapper.get(@tube_name)
18
- if job.body
19
- perform(job)
20
- ran = true
16
+ loop do
17
+ ran = false
18
+ job = @allq_wrapper.get(@tube_name)
19
+ if job.body
20
+ perform(job)
21
+ ran = true
22
+ end
23
+ # Wait if nothing returned
24
+ sleep(rand() * 3) unless ran
21
25
  end
22
- # Wait if nothing returned
23
- sleep(rand() * 3) unless ran
24
26
  end
25
27
  end
26
28
  end
@@ -123,6 +125,10 @@ module Backburner
123
125
  stats_hash.keys
124
126
  end
125
127
 
128
+ def tubes
129
+ tube_names
130
+ end
131
+
126
132
  def peek_buried(tube_name = 'default')
127
133
  job = nil
128
134
  job = @client.peek_get(tube_name, buried: true)
@@ -208,7 +214,7 @@ module Backburner
208
214
  priority: adjusted_priority,
209
215
  timeout: timeout,
210
216
  run_on_timeout: run_on_timeout,
211
- shard_key: options[:shard_key]
217
+ shard_key: options[:shard_key],
212
218
  limit: limit)
213
219
  new_parent_job
214
220
  end
@@ -250,6 +256,11 @@ module Backburner
250
256
  result
251
257
  end
252
258
 
259
+ def stats(tube)
260
+ final_stats = stats
261
+ final_stats[tube]
262
+ end
263
+
253
264
  def stats
254
265
  raw_stats = @admin.stats_get
255
266
  final_stats = {}
@@ -1,3 +1,3 @@
1
1
  module Backburner
2
- VERSION = "1.0.12"
2
+ VERSION = "1.0.18"
3
3
  end
@@ -134,35 +134,39 @@ module Backburner
134
134
  return
135
135
  end
136
136
 
137
- self.log_job_begin(job.name, job.args)
138
- job.process
139
- self.log_job_end(job.name)
140
-
141
- rescue Backburner::Job::JobFormatInvalid => e
142
- self.log_error self.exception_message(e)
143
- rescue => e # Error occurred processing job
144
- self.log_error self.exception_message(e) unless e.is_a?(Backburner::Job::RetryJob)
145
-
146
- unless job
147
- self.log_error "Error occurred before we were able to assign a job. Giving up without retrying!"
148
- return
149
- end
150
-
151
- # NB: There's a slight chance here that the connection to allq has
152
- # gone down between the time we reserved / processed the job and here.
153
- num_retries = job.releases
154
- max_job_retries = resolve_max_job_retries(job.job_class)
155
- retry_status = "failed: attempt #{num_retries+1} of #{max_job_retries+1}"
156
- retry_delay = resolve_retry_delay(job.job_class)
157
- delay = resolve_retry_delay_proc(job.job_class).call(retry_delay, num_retries) rescue retry_delay
158
- if num_retries + 1 > max_job_retries
159
- job.bury
160
- else
161
- job.release(delay)
137
+ if job
138
+ begin
139
+ self.log_job_begin(job.name, job.args)
140
+ job.process
141
+ self.log_job_end(job.name)
142
+ rescue Backburner::Job::JobFormatInvalid => e
143
+ self.log_error self.exception_message(e)
144
+ rescue => e # Error occurred processing job
145
+ self.log_error self.exception_message(e) unless e.is_a?(Backburner::Job::RetryJob)
146
+
147
+ unless job
148
+ self.log_error "Error occurred before we were able to assign a job. Giving up without retrying!"
149
+ return
150
+ end
151
+
152
+ # NB: There's a slight chance here that the connection to allq has
153
+ # gone down between the time we reserved / processed the job and here.
154
+ num_retries = job.releases
155
+ max_job_retries = resolve_max_job_retries(job.job_class)
156
+ retry_status = "failed: attempt #{num_retries+1} of #{max_job_retries+1}"
157
+ retry_delay = resolve_retry_delay(job.job_class)
158
+ delay = resolve_retry_delay_proc(job.job_class).call(retry_delay, num_retries) rescue retry_delay
159
+ if num_retries + 1 > max_job_retries
160
+ job.bury
161
+ else
162
+ job.release(delay)
163
+ end
164
+ self.log_job_end(job.name, "#{retry_status}, retrying in #{delay}s") if job_started_at
165
+
166
+ handle_error(e, job.name, job.args, job)
167
+ end
162
168
  end
163
- self.log_job_end(job.name, "#{retry_status}, retrying in #{delay}s") if job_started_at
164
-
165
- handle_error(e, job.name, job.args, job)
169
+ job
166
170
  end
167
171
 
168
172
 
@@ -175,7 +179,9 @@ module Backburner
175
179
 
176
180
  # Reserve a job from the watched queues
177
181
  def reserve_job(conn, reserve_timeout = Backburner.configuration.reserve_timeout)
178
- Backburner::Job.new(conn.get(@tube_names.sample))
182
+ job = conn.get(@tube_names.sample)
183
+ return nil if job.body == nil?
184
+ Backburner::Job.new(job)
179
185
  end
180
186
 
181
187
  # Returns a list of all tubes known within the system
@@ -207,7 +207,9 @@ module Backburner
207
207
  def run_while_can(conn = connection)
208
208
  while @garbage_after.nil? or @garbage_after > @runs
209
209
  @runs += 1 # FIXME: Likely race condition
210
- work_one_job(conn)
210
+ ran_job = work_one_job(conn)
211
+ # Wait a second if we didn't find a job
212
+ sleep(rand() * 3) unless ran_job
211
213
  end
212
214
  end
213
215
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backburner-allq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.12
4
+ version: 1.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Malcolm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-22 00:00:00.000000000 Z
11
+ date: 2021-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: allq_rest