sidekiq-unique-jobs 7.0.0.beta8 → 7.0.0.beta9

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.

Potentially problematic release.


This version of sidekiq-unique-jobs might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 613b92887d9b07c1e2c0e485a553c3abd9b9586cc3a7026562b20fb1da751459
4
- data.tar.gz: 3638999cdae0b55a4fdc1210ac38aa96782ac139dacb5167692921fd061f7a0f
3
+ metadata.gz: a24246a99460117c9ebacb054dc8d1860e3a330058f3c4f34d409125136ffc22
4
+ data.tar.gz: 662a626190317ed24ecc5453a936437824166bf5b08cbb9e96187bb63f1d091b
5
5
  SHA512:
6
- metadata.gz: 613e5e3feeb4e61eee2d2d64a6a648bcef199526b42ad0ef682ead1f91ba6efa8945d01f1ba0379ae5acc4f44e27377ab320990db68822449ab3dab0a4bbb85f
7
- data.tar.gz: 8802925c25b1f32552dcaf6329a90c4c9f825ea828f85c2c7570a2a359fa0cbf20f4102d5908c27e2ea210f671b7ac2b878096a1b6e905222faf5d1e357d3d5c
6
+ metadata.gz: a406b1f3f3f73a39f4c50b44417cbc1b6a83492c5e5c4dea71055cda9eca8c5139e667d2a1d4363e952f07e4e918b96455734cfd6285a753cdf3af026c2ab7eb
7
+ data.tar.gz: 99742c266e02ef86cfefd96a3c694b986f6d5610fca49877b7fd0f5d14ddcef4abadb6e65ae00b53de1fe71830d74210a9f7ff3237e3aecb141f9c9c5efdcf30
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## [v7.0.0.beta8](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta8) (2019-11-28)
4
+
5
+ [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta7...v7.0.0.beta8)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Allow worker to configure client and server strategies separately [\#402](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/402)
10
+ - Separate client and server on\_conflict [\#462](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/462) ([mhenrixon](https://github.com/mhenrixon))
11
+
12
+ **Fixed bugs:**
13
+
14
+ - `while\_executing` has problems at low concurrency [\#384](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/384)
15
+ - lock: :until\_and\_while\_executing not working for scheduled jobs [\#334](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/334)
16
+
17
+ **Closed issues:**
18
+
19
+ - Custom Locks with error [\#392](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/392)
20
+ - :until\_executed jobs get stuck every now and then [\#379](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/379)
21
+
3
22
  ## [v7.0.0.beta7](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta7) (2019-11-28)
4
23
 
5
24
  [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta6...v7.0.0.beta7)
@@ -177,7 +177,7 @@ module SidekiqUniqueJobs
177
177
  enqueue(conn) do
178
178
  primed_async(conn) do
179
179
  locked_token = call_script(:lock, key.to_a, argv, conn)
180
- return yield job_id if locked_token == job_id
180
+ return yield if locked_token == job_id
181
181
  end
182
182
  end
183
183
  ensure
@@ -195,7 +195,9 @@ module SidekiqUniqueJobs
195
195
  # @return [Object] whatever the block returns when lock was acquired
196
196
  #
197
197
  def primed_async(conn)
198
- return yield if Concurrent::Promises.future(conn) { |red_con| pop_queued(red_con) }.value
198
+ return yield if Concurrent::Promises
199
+ .future(conn) { |red_con| pop_queued(red_con) }
200
+ .value(drift(config.ttl))
199
201
 
200
202
  warn_about_timeout
201
203
  end
@@ -211,12 +213,12 @@ module SidekiqUniqueJobs
211
213
  # @yieldparam [String] job_id a Sidekiq JID
212
214
  #
213
215
  def lock_sync(conn)
214
- return yield job_id if locked?(conn)
216
+ return yield if locked?(conn)
215
217
 
216
218
  enqueue(conn) do
217
219
  primed_sync(conn) do
218
220
  locked_token = call_script(:lock, key.to_a, argv, conn)
219
- return yield job_id if locked_token == job_id
221
+ return yield if locked_token
220
222
  end
221
223
  end
222
224
  end
@@ -284,7 +286,7 @@ module SidekiqUniqueJobs
284
286
  return unless queued_token && (validity >= 0 || config.pttl.zero?)
285
287
 
286
288
  write_lock_info(conn)
287
- yield queued_token
289
+ yield
288
290
  end
289
291
 
290
292
  #
@@ -80,7 +80,7 @@ module SidekiqUniqueJobs
80
80
  @redis_pool = redis_pool
81
81
  return yield if unique_disabled?
82
82
 
83
- SidekiqUniqueJobs::Job.add_uniqueness(item)
83
+ SidekiqUniqueJobs::Job.add_uniqueness(item) unless item.key?(UNIQUE_DIGEST)
84
84
 
85
85
  with_logging_context do
86
86
  super
@@ -7,6 +7,8 @@ module SidekiqUniqueJobs
7
7
  # @author Mikael Henriksson <mikael@zoolutions.se>
8
8
  class Reschedule < OnConflict::Strategy
9
9
  include SidekiqUniqueJobs::SidekiqWorkerMethods
10
+ include SidekiqUniqueJobs::Logging
11
+ include SidekiqUniqueJobs::JSON
10
12
 
11
13
  # @param [Hash] item sidekiq job hash
12
14
  def initialize(item, redis_pool = nil)
@@ -17,7 +19,12 @@ module SidekiqUniqueJobs
17
19
  # Create a new job from the current one.
18
20
  # This will mess up sidekiq stats because a new job is created
19
21
  def call
20
- worker_class&.perform_in(5, *item[ARGS]) if sidekiq_worker_class?
22
+ if sidekiq_worker_class?
23
+ log_info("Rescheduling #{item[UNIQUE_DIGEST]}")
24
+ worker_class&.perform_in(5, *item[ARGS])
25
+ else
26
+ log_warn("Skip rescheduling of #{item[UNIQUE_DIGEST]} because #{worker_class} is not a Sidekiq::Worker")
27
+ end
21
28
  end
22
29
  end
23
30
  end
@@ -21,6 +21,7 @@ module SidekiqUniqueJobs
21
21
  #
22
22
  def start # rubocop:disable
23
23
  return if registered?
24
+ return if disabled?
24
25
 
25
26
  with_logging_context do
26
27
  register_reaper_process
@@ -73,6 +74,13 @@ module SidekiqUniqueJobs
73
74
  timeout_interval: reaper_timeout }
74
75
  end
75
76
 
77
+ #
78
+ # @see SidekiqUniqueJobs::Config#reaper
79
+ #
80
+ def reaper
81
+ SidekiqUniqueJobs.config.reaper
82
+ end
83
+
76
84
  #
77
85
  # @see SidekiqUniqueJobs::Config#reaper_interval
78
86
  #
@@ -112,6 +120,10 @@ module SidekiqUniqueJobs
112
120
  redis { |conn| conn.get(UNIQUE_REAPER) }.to_i == 1
113
121
  end
114
122
 
123
+ def disabled?
124
+ reaper == :none
125
+ end
126
+
115
127
  #
116
128
  # Writes a mutex key to redis
117
129
  #
@@ -34,12 +34,12 @@ module SidekiqUniqueJobs
34
34
 
35
35
  def self.start
36
36
  Thread.current[:_method_profiler] = {
37
- __start: Process.clock_gettime(Process::CLOCK_MONOTONIC),
37
+ __start: current_timestamp,
38
38
  }
39
39
  end
40
40
 
41
41
  def self.stop
42
- finish = Process.clock_gettime(Process::CLOCK_MONOTONIC)
42
+ finish = current_timestamp
43
43
  return unless (data = Thread.current[:_method_profiler])
44
44
 
45
45
  Thread.current[:_method_profiler] = nil
@@ -47,5 +47,9 @@ module SidekiqUniqueJobs
47
47
  data[:total_duration] = finish - start
48
48
  data
49
49
  end
50
+
51
+ def self.current_timestamp
52
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
53
+ end
50
54
  end
51
55
  end
@@ -3,5 +3,5 @@
3
3
  module SidekiqUniqueJobs
4
4
  #
5
5
  # @return [String] the current SidekiqUniqueJobs version
6
- VERSION = "7.0.0.beta8"
6
+ VERSION = "7.0.0.beta9"
7
7
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  begin
4
4
  require "sidekiq/web"
5
- rescue LoadError # rubocop:disable Lint/HandleExceptions
5
+ rescue LoadError # rubocop:disable Lint/SuppressedException
6
6
  # client-only usage
7
7
  end
8
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-unique-jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0.beta8
4
+ version: 7.0.0.beta9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-28 00:00:00.000000000 Z
11
+ date: 2019-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: brpoplpush-redis_script