sidekiq-lock 0.6.0 → 0.7.0

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: 94c0d6993d3e6f8c2acd6a63e2e78464ac974369138f6c20eeb91525d0b5ea13
4
- data.tar.gz: 75437ca38c53bc825d0e6e77b8dc2ef64c5c42bb8802746f5fbacf1f91c9e4f5
3
+ metadata.gz: b9c3099623c0436cfe8cbd6eb0d3f56168ac0fda088b7167a0211ca4cba6e530
4
+ data.tar.gz: b5105d14dd29c9374b43a46cba4cfd6c576f086808051949bf4729c9163be05e
5
5
  SHA512:
6
- metadata.gz: 463adf7d4dbf5d468a1c795105a716d94fd6f77141e7c7f3d77a84076e4e222cc2b6fb57f64d5286bca6fc8b9491c4de891190fb3d255f1766acd879253220d0
7
- data.tar.gz: c215cce1d79e99aaa28a04a5238aac165a8e5d36271a372b39067a80040109e5f64117114fdbfae227c5cb406f86cd46e554cfa6820978573abd1f08b04ada6d
6
+ metadata.gz: 18898eaacf8fd60adeee2dce1e53e96bf517878856541220cbb472338dd7e4f531463917fb059b0767bb411834fe42f23aac535cb078f814de76de4bda8c3bfc
7
+ data.tar.gz: 07ee42bde63d54ef88ad56625167f781b259943967507fefe4769735377f12fd12dbf28985b3c0a4cf5d4a950a3162367bdcc78ce17f5ff346003c22ff38ecab
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.7.0 (Feb 7, 2024)
2
+
3
+ - support for Sidekiq 7.2 (thanks for the issue report [9mm](https://github.com/9mm))
4
+ - dropped support for Sidekiq 5 and older [as it reached EOL](https://github.com/sidekiq/sidekiq/wiki/Commercial-Support#version-policy)
5
+ - removed `redis` as gem dependency (relying on sidekiq version you're using to choose the right one)
6
+
1
7
  ## 0.6.0 (May 27, 2023)
2
8
 
3
9
  - support for Sidekiq 7 (thanks to [@stympy](https://github.com/stympy))
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Rafal Wojsznis
1
+ Copyright (c) 2024 Rafal Wojsznis
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -18,7 +18,7 @@ time - it provides a `lock` method that you can use in whatever way you want.
18
18
 
19
19
  This gem requires at least:
20
20
  - redis 2.6.12
21
- - redis-rb 3.0.5 (support for extended SET method)
21
+ - sidekiq 6
22
22
 
23
23
  Add this line to your application's Gemfile:
24
24
 
@@ -23,7 +23,11 @@ module Sidekiq
23
23
  # this also requires redis-rb >= 3.0.5
24
24
  def acquire!
25
25
  @acquired ||= Sidekiq.redis do |r|
26
- r.set(name, value, nx: true, px: timeout)
26
+ if Sidekiq::VERSION >= '7.2'
27
+ r.set(name, value, 'nx', 'px', timeout)
28
+ else
29
+ r.set(name, value, nx: true, px: timeout)
30
+ end
27
31
  end
28
32
  end
29
33
 
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Lock
3
- VERSION = '0.6.0'
3
+ VERSION = '0.7.0'
4
4
  end
5
5
  end
@@ -7,23 +7,24 @@ module Sidekiq
7
7
  skip 'Sidekiq 7+ does not print out middleware information' if Sidekiq::VERSION >= '7'
8
8
 
9
9
  cmd = 'sidekiq -r ./test/test_workers.rb -v'
10
- buffer = ''
10
+ buffer_out = ''
11
11
 
12
12
  # very not fancy (https://78.media.tumblr.com/tumblr_lzkpw7DAl21qhy6c9o2_400.gif)
13
13
  # solution, but should do the job
14
14
  Open3.popen3(cmd) do |stdin, stdout, stderr, thread|
15
15
  begin
16
- Timeout.timeout(5) do
16
+ Timeout.timeout(3) do
17
17
  until stdout.eof? do
18
- buffer << stdout.read_nonblock(16)
18
+ buffer_out << stdout.read_nonblock(16)
19
19
  end
20
20
  end
21
+
21
22
  rescue Timeout::Error
22
23
  Process.kill('KILL', thread.pid)
23
24
  end
24
25
  end
25
26
 
26
- assert_match(/\s?Middleware:.*Sidekiq::Lock::Middleware/i, buffer)
27
+ assert_match(/\s?Middleware:.*Sidekiq::Lock::Middleware/i, buffer_out)
27
28
  end
28
29
  end
29
30
  end
@@ -15,9 +15,8 @@ module Sidekiq
15
15
  reset_lock_variable!
16
16
  end
17
17
 
18
- let(:handler) { Sidekiq::Lock::Middleware.new }
19
-
20
18
  it 'sets lock variable with provided static lock options' do
19
+ handler = Sidekiq::Lock::Middleware.new
21
20
  handler.call(LockWorker.new, { 'class' => LockWorker, 'args' => [] }, 'default') do
22
21
  true
23
22
  end
@@ -26,6 +25,7 @@ module Sidekiq
26
25
  end
27
26
 
28
27
  it 'sets lock variable with provided dynamic options' do
28
+ handler = Sidekiq::Lock::Middleware.new
29
29
  handler.call(DynamicLockWorker.new, { 'class' => DynamicLockWorker, 'args' => [1234, 1000] }, 'default') do
30
30
  true
31
31
  end
@@ -35,6 +35,7 @@ module Sidekiq
35
35
  end
36
36
 
37
37
  it 'sets nothing for workers without lock options' do
38
+ handler = Sidekiq::Lock::Middleware.new
38
39
  handler.call(RegularWorker.new, { 'class' => RegularWorker, 'args' => [] }, 'default') do
39
40
  true
40
41
  end
@@ -3,8 +3,6 @@ require 'test_helper'
3
3
  module Sidekiq
4
4
  module Lock
5
5
  describe Worker do
6
- # after { }
7
-
8
6
  class CustomContainer
9
7
  def initialize
10
8
  @lock = nil
@@ -19,47 +17,38 @@ module Sidekiq
19
17
  end
20
18
  end
21
19
 
22
- # it 'sets lock method that points to thread variable' do
23
- # set_lock_variable! "test"
24
- # assert_equal "test", LockWorker.new.lock
25
- # end
26
-
27
20
  it 'allows method name configuration' do
28
- begin
29
- Sidekiq.lock_method = :custom_lock_name
21
+ Sidekiq.lock_method = :custom_lock_name
30
22
 
31
- class WorkerWithCustomLockName
32
- include Sidekiq::Worker
33
- include Sidekiq::Lock::Worker
34
- end
23
+ class WorkerWithCustomLockName
24
+ include Sidekiq::Worker
25
+ include Sidekiq::Lock::Worker
26
+ end
35
27
 
36
- set_lock_variable! "custom_name"
28
+ set_lock_variable! "custom_name"
37
29
 
38
- assert_equal "custom_name", WorkerWithCustomLockName.new.custom_lock_name
30
+ assert_equal "custom_name", WorkerWithCustomLockName.new.custom_lock_name
39
31
 
40
- reset_lock_variable!
41
- ensure
32
+ reset_lock_variable!
33
+ ensure
42
34
 
43
- Sidekiq.lock_method = Sidekiq::Lock::METHOD_NAME
44
- end
35
+ Sidekiq.lock_method = Sidekiq::Lock::METHOD_NAME
45
36
  end
46
37
 
47
38
  it 'allows container configuration' do
48
- begin
49
- container = CustomContainer.new
50
- Sidekiq.lock_container = container
39
+ container = CustomContainer.new
40
+ Sidekiq.lock_container = container
51
41
 
52
- class WorkerWithCustomContainer
53
- include Sidekiq::Worker
54
- include Sidekiq::Lock::Worker
55
- end
42
+ class WorkerWithCustomContainer
43
+ include Sidekiq::Worker
44
+ include Sidekiq::Lock::Worker
45
+ end
56
46
 
57
- container.store "lock-variable"
47
+ container.store "lock-variable"
58
48
 
59
- assert_equal "lock-variable", WorkerWithCustomContainer.new.lock
60
- ensure
61
- Sidekiq.lock_container = Sidekiq::Lock::Container.new
62
- end
49
+ assert_equal "lock-variable", WorkerWithCustomContainer.new.lock
50
+ ensure
51
+ Sidekiq.lock_container = Sidekiq::Lock::Container.new
63
52
  end
64
53
  end
65
54
  end
data/test/test_helper.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  require 'minitest/autorun'
2
- require 'minitest/pride'
3
- require 'mocha/setup'
4
-
2
+ require 'mocha/minitest'
5
3
  require 'sidekiq'
6
4
  require 'test_workers'
7
5
 
data/test/test_workers.rb CHANGED
@@ -1,3 +1,4 @@
1
+ $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
1
2
  require 'sidekiq-lock'
2
3
 
3
4
  class LockWorker
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-lock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafal Wojsznis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-27 00:00:00.000000000 Z
11
+ date: 2024-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -16,98 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.14.0
19
+ version: '6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 2.14.0
27
- - !ruby/object:Gem::Dependency
28
- name: redis
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 3.0.5
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: 3.0.5
41
- - !ruby/object:Gem::Dependency
42
- name: bundler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: mocha
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 0.14.0
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 0.14.0
83
- - !ruby/object:Gem::Dependency
84
- name: minitest
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: appraisal
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
26
+ version: '6'
111
27
  description: Simple redis-based lock mechanism for your sidekiq workers
112
28
  email:
113
29
  - rafal.wojsznis@gmail.com
@@ -154,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
70
  - !ruby/object:Gem::Version
155
71
  version: '0'
156
72
  requirements: []
157
- rubygems_version: 3.3.7
73
+ rubygems_version: 3.4.10
158
74
  signing_key:
159
75
  specification_version: 4
160
76
  summary: Simple redis-based lock mechanism for your sidekiq workers