rjob 0.5.3 → 0.5.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
  SHA256:
3
- metadata.gz: 364e6b6c660f7b3fc31a24a1bd86942a7900aed84146ecf0a5fa3799653966b9
4
- data.tar.gz: d450f1b80a5854b59d49c9bd9ca3f8df1c05b4dffe5d7e202efb95d15740e5e9
3
+ metadata.gz: 1de4a3b3e8be5af5e5f17b5c569c3851b9ed5c7ee94cd38fc7d7b61b1f6035ea
4
+ data.tar.gz: 5bc34fa2eee95a23a667c21c5373318e48e16eaa559f123b05d41be3525ac9a1
5
5
  SHA512:
6
- metadata.gz: 2c2f0b54f42c2eaa8aac6b2b09dcb12adffce5763be7d89878971c9afc22460f73b4728f1bab42756fbf13bb4fe92d47a86f7ae41e759710faca153f958e861d
7
- data.tar.gz: 06e74cef1bb61d06eaaa005dcf13be78465d016308025fde8af8a7035259645aadbbc2561fbf68db8745465500525495342ecd30db94915f4501dc2a09b4e0f2
6
+ metadata.gz: de1b0664b64a4503cc525be2c37e5abc200f0b92505100917f1aacdffb16a5a68f7f708e90abf64a0fd07530afb72c44a16aee64e9fd192706529af768cf7391
7
+ data.tar.gz: b37d75d2595f979ce02f8279fbd38a4ccea283e4baaeee303402a969424c473567e907c581302a6f826f02a765570bfd4f200d043485a5825327f8bcb0bb1ca0
data/lib/rjob/context.rb CHANGED
@@ -58,6 +58,27 @@ class Rjob::Context
58
58
  load_redis_scripts
59
59
  end
60
60
 
61
+ def dead_job_count()
62
+ redis { |r| r.llen("#{@prefix}:dead") }
63
+ end
64
+
65
+ def get_dead_jobs(count=1, offset=0, keyname: 'ohh-dead')
66
+ redis do |r|
67
+ # dead_jobs = r.lrange("#{@prefix}:dead", offset, count < 0 ? -1 : (offset + count - 1))
68
+ dead_jobs = r.lrange(keyname, offset, count < 0 ? -1 : (offset + count - 1))
69
+ dead_jobs.map do |error_payload|
70
+ payload = MessagePack.unpack(error_payload)
71
+
72
+ {
73
+ job: Rjob::Job.deserialize(self, payload['job']),
74
+ when: Time.at(payload['when']),
75
+ error_class: payload['error_class'],
76
+ full_message: payload['message'],
77
+ }
78
+ end
79
+ end
80
+ end
81
+
61
82
  def redis(&block)
62
83
  @pool.with(&block)
63
84
  end
data/lib/rjob/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Rjob
3
- VERSION = "0.5.3".freeze
3
+ VERSION = "0.5.5".freeze
4
4
  end
@@ -248,12 +248,17 @@ class Rjob::WorkerProcess
248
248
 
249
249
  if job_processor.stop_retry?
250
250
  move_job_to_dead(job_processor.job_str, bucket, error)
251
+ notify_job_is_dead(job_processor, error)
251
252
  return
252
253
  end
253
254
 
254
255
  retry_options = job.worker_class.retry_options
255
256
 
256
257
  if retry_options[:retry]
258
+ if retry_options[:retry].is_a?(Hash)
259
+ retry_options = retry_options.merge(retry: true).merge(retry_options[:retry])
260
+ end
261
+
257
262
  exceptions = retry_options.fetch(:exceptions, [StandardError])
258
263
  should_handle = exceptions.any? { |e| e >= error[:error_class] }
259
264
 
@@ -270,6 +275,24 @@ class Rjob::WorkerProcess
270
275
  end
271
276
 
272
277
  move_job_to_dead(job_processor.job_str, bucket, error)
278
+ notify_job_is_dead(job_processor, error)
279
+ end
280
+
281
+ def notify_job_is_dead(job_processor, error)
282
+ if defined?(Honeybadger)
283
+ job = job_processor.job
284
+
285
+ Honeybadger.notify(error, context: {
286
+ what: 'RJOB_MOVED_TO_DEAD',
287
+ rjob_class: job.worker_class_name,
288
+ rjob_args: job.worker_args
289
+ })
290
+ end
291
+ rescue StandardError => e
292
+ if @context.logger.respond_to?(:error)
293
+ s = job_processor.respond_to?(:job_str) ? job_processor.job_str : '<unknown>'
294
+ @context.logger.error("UGHH! Error while notifying dead job error: #{s}")
295
+ end
273
296
  end
274
297
 
275
298
  # TODO: this should probably be in a single redis pipelined operation
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rjob
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - André D. Piske
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-16 00:00:00.000000000 Z
11
+ date: 2023-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  - !ruby/object:Gem::Version
147
147
  version: '0'
148
148
  requirements: []
149
- rubygems_version: 3.3.11
149
+ rubygems_version: 3.4.20
150
150
  signing_key:
151
151
  specification_version: 4
152
152
  summary: Asynchronous job processing