sidekiq-ultimate 0.0.1.alpha.4 → 0.0.1.alpha.5

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: 48fa760a3af0b2e932d2a5415dc25b4d7cd86df32f17b47b86f2ba23d3968d34
4
- data.tar.gz: 9dc5bf6963d3f343e67fc9b59a1072adb1cb7959651d7262f8768dfda8b32ff3
3
+ metadata.gz: 3f0176019d0fa6bd44ec34fb292e7caafdaa78ab4c8d5dc33c03f2f933b5db74
4
+ data.tar.gz: ab8225dae6c14e67784ef3147cad83e1d1597df234626837207d6fd8ba783997
5
5
  SHA512:
6
- metadata.gz: e1d7e93bd40dab574eff3bc6455e23ef2a59946d41e220a81bac3716350e3a23036dfb0d9f5c1fe0fb6e546e96bc191adbbb6c7a8dc9fe286334a6d852c4c160
7
- data.tar.gz: 605d4e1d9d1a8250fb017a2ff005a2046ada578ff55938cf1126f574c78d42e518ab4d4f6843373b1a552e7686c52b9c0f910e3aed09af1a0ac00c844df933bb
6
+ metadata.gz: d222fcb849ad439eddb9957c6b4fc9c87010181e5b97dc217eaf512402902137671141f090ab3a431fba12d13c145e11d5c6bcd477c94319e267daebfcbfeb97
7
+ data.tar.gz: f5ec33ba4bbf1159ec79f12dc4c416f6a79b77f64c4f161bf85690f40173702c513e475884e84dc127a24bc6373b32dc8e84bd59e64dcab36cfd45e8b48ab946
@@ -1,9 +1,12 @@
1
+ local count = 0
2
+
1
3
  while true do
2
4
  local val = redis.call("LPOP", KEYS[1])
3
5
 
4
6
  if val then
7
+ count = count + 1
5
8
  redis.call("RPUSH", KEYS[2], val)
6
9
  else
7
- return
10
+ return count
8
11
  end
9
12
  end
@@ -51,6 +51,8 @@ module Sidekiq
51
51
  def resurrect!
52
52
  lock do
53
53
  casualties.each do |identity|
54
+ Sidekiq.logger.debug { "[#{self}] Resurrecting #{identity}" }
55
+
54
56
  queues = queues_of(identity).each { |queue| resurrect(queue) }
55
57
  cleanup(identity, queues.map(&:inproc))
56
58
  end
@@ -101,7 +103,15 @@ module Sidekiq
101
103
 
102
104
  def resurrect(queue)
103
105
  Sidekiq.redis do |redis|
104
- RESURRECT.eval(redis, :keys => [queue.inproc, queue.pending])
106
+ count = RESURRECT.eval(redis, {
107
+ :keys => [queue.inproc, queue.pending]
108
+ })
109
+
110
+ if count.positive?
111
+ Sidekiq.logger.info do
112
+ "[#{self}] Resurrected #{count} jobs of #{queue.inspect}"
113
+ end
114
+ end
105
115
  end
106
116
  end
107
117
 
@@ -0,0 +1,2 @@
1
+ redis.call(ARGV[1], KEYS[1], ARGV[2])
2
+ redis.call("LREM", KEYS[2], -1, ARGV[2])
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "redis/prescription"
4
+
3
5
  require "sidekiq/throttled"
4
6
 
5
7
  module Sidekiq
@@ -8,6 +10,10 @@ module Sidekiq
8
10
  #
9
11
  # @private
10
12
  class UnitOfWork
13
+ REQUEUE = Redis::Prescription.read \
14
+ "#{__dir__}/unit_of_work/requeue.lua"
15
+ private_constant :REQUEUE
16
+
11
17
  # JSON payload
12
18
  #
13
19
  # @return [String]
@@ -49,7 +55,7 @@ module Sidekiq
49
55
  #
50
56
  # @return [void]
51
57
  def requeue
52
- # do nothing
58
+ __requeue__("RPUSH")
53
59
  end
54
60
 
55
61
  # Pushes job back to the head of the queue, so that job won't be tried
@@ -60,12 +66,7 @@ module Sidekiq
60
66
  #
61
67
  # @return [void]
62
68
  def requeue_throttled
63
- Sidekiq.redis do |redis|
64
- redis.pipelined do
65
- redis.lpush(@queue.pending, @job)
66
- acknowledge
67
- end
68
- end
69
+ __requeue__("LPUSH")
69
70
  end
70
71
 
71
72
  # Tells whenever job should be pushed back to queue (throttled) or not.
@@ -75,6 +76,17 @@ module Sidekiq
75
76
  def throttled?
76
77
  Sidekiq::Throttled.throttled?(@job)
77
78
  end
79
+
80
+ private
81
+
82
+ def __requeue__(command)
83
+ Sidekiq.redis do |redis|
84
+ REQUEUE.eval(redis, {
85
+ :keys => [@queue.pending, @queue.inproc],
86
+ :argv => [command, @job]
87
+ })
88
+ end
89
+ end
78
90
  end
79
91
  end
80
92
  end
@@ -3,6 +3,6 @@
3
3
  module Sidekiq
4
4
  module Ultimate
5
5
  # Gem version.
6
- VERSION = "0.0.1.alpha.4"
6
+ VERSION = "0.0.1.alpha.5"
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-ultimate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha.4
4
+ version: 0.0.1.alpha.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Zapparov
@@ -119,6 +119,7 @@ files:
119
119
  - lib/sidekiq/ultimate/resurrector/resurrect.lua
120
120
  - lib/sidekiq/ultimate/resurrector/safeclean.lua
121
121
  - lib/sidekiq/ultimate/unit_of_work.rb
122
+ - lib/sidekiq/ultimate/unit_of_work/requeue.lua
122
123
  - lib/sidekiq/ultimate/version.rb
123
124
  - sidekiq-ultimate.gemspec
124
125
  homepage: https://github.com/sensortower/sidekiq-ultimate