rjob 0.5.2 → 0.5.4

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: 3499587dfa6fa5db867d088dfc0f48757a204df0cd07a252c3f880ce827effe6
4
- data.tar.gz: 6ff88dc58d9e39eb337980b4fe1241bd3afb493cd15aff370ab463e4b2d086b6
3
+ metadata.gz: a449a71e4bc05ab0aa01d605cfd96ef3e1133377829750749c2c8cf0759a11d2
4
+ data.tar.gz: 0fbe17674cc2dbb924c85b431a0160afc85eee4cc9598923c2bf6c61a5af9530
5
5
  SHA512:
6
- metadata.gz: 77d9c95f465434e5efc942b5dca1a98c64bc2f15c2c12691b258f993569c68c29f1146958e8856633e9bee32bcc82119d687b3ee37a29eb6fa5163238eeacf08
7
- data.tar.gz: 523ff1e067f99d9fb632c248d7b07157112d0d6197574e717d319900f76e8c646698f692388760dccb521abfbf36f88fe01b5c01614ec71f0b28fcf7319c5a71
6
+ metadata.gz: b3079717e2b8cf013a383b4026794af68c2b52aece9633be7bc1aa3880161091b78dd4a9d717754a0e61de1cfe6492969ab2bd92781c948beb03cda7258c3a7e
7
+ data.tar.gz: 3a7578b5135a1b7932e6c88b40111bf529068b950f71497ea423a1ae85d3ee502cca5e505bd1a2bafadaa34378e71a7fb970e0c54d963c53566f0a9625cd21f9
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
@@ -14,7 +14,7 @@ class Rjob::Scripts::EnqueueJob < Rjob::Scripts::RedisScript
14
14
  local job_id = r.call('incr', prefix .. ':next')
15
15
  local bucket = job_id % bucket_count
16
16
  r.call('lpush', prefix .. ':jobs:' .. bucket, job_id .. '!0!' .. job_data)
17
- r.call('publish', prefix .. ':jobs', bucket)
17
+ r.call('publish', prefix .. ':jobs', tostring(bucket))
18
18
  return job_id
19
19
  LUA
20
20
  end
@@ -14,7 +14,7 @@ class Rjob::Scripts::ScanBuckets < Rjob::Scripts::RedisScript
14
14
  for i=0,bucket_count-1 do
15
15
  local len = r.call('llen', prefix .. ':jobs:' .. i)
16
16
  if len > 0 then
17
- r.call('publish', prefix .. ':jobs', i)
17
+ r.call('publish', prefix .. ':jobs', tostring(i))
18
18
  end
19
19
  end
20
20
  return 1
data/lib/rjob/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Rjob
3
- VERSION = "0.5.2".freeze
3
+ VERSION = "0.5.4".freeze
4
4
  end
@@ -81,12 +81,10 @@ class Rjob::WorkerProcess
81
81
  begin
82
82
  @pubsub_redis.subscribe("#{@prefix}:jobs") do |on|
83
83
  on.message do |_, bucket_no|
84
- loop do
85
- break unless @state == :running
84
+ @pubsub_redis.unsubscribe unless @state == :running
86
85
 
87
- @subscription_mutex.synchronize do
88
- break unless start_processing_message_from_bucket(bucket_no)
89
- end
86
+ @subscription_mutex.synchronize do
87
+ start_processing_message_from_bucket(bucket_no)
90
88
  end
91
89
  end
92
90
  end
@@ -250,6 +248,7 @@ class Rjob::WorkerProcess
250
248
 
251
249
  if job_processor.stop_retry?
252
250
  move_job_to_dead(job_processor.job_str, bucket, error)
251
+ notify_job_is_dead(job_processor, error)
253
252
  return
254
253
  end
255
254
 
@@ -272,6 +271,24 @@ class Rjob::WorkerProcess
272
271
  end
273
272
 
274
273
  move_job_to_dead(job_processor.job_str, bucket, error)
274
+ notify_job_is_dead(job_processor, error)
275
+ end
276
+
277
+ def notify_job_is_dead(job_processor, error)
278
+ if defined?(Honeybadger)
279
+ job = job_processor.job
280
+
281
+ Honeybadger.notify(error, context: {
282
+ what: 'RJOB_MOVED_TO_DEAD',
283
+ rjob_class: job.worker_class_name,
284
+ rjob_args: job.worker_args
285
+ })
286
+ end
287
+ rescue StandardError => e
288
+ if @context.logger.respond_to?(:error)
289
+ s = job_processor.respond_to?(:job_str) ? job_processor.job_str : '<unknown>'
290
+ @context.logger.error("UGHH! Error while notifying dead job error: #{s}")
291
+ end
275
292
  end
276
293
 
277
294
  # 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.2
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - André D. Piske
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-08 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
@@ -131,7 +131,7 @@ homepage: https://gitlab.com/andrepiske/rjob
131
131
  licenses:
132
132
  - Apache-2.0
133
133
  metadata: {}
134
- post_install_message:
134
+ post_install_message:
135
135
  rdoc_options: []
136
136
  require_paths:
137
137
  - lib
@@ -146,8 +146,8 @@ 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
150
- signing_key:
149
+ rubygems_version: 3.4.20
150
+ signing_key:
151
151
  specification_version: 4
152
152
  summary: Asynchronous job processing
153
153
  test_files: []