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 +4 -4
- data/CHANGELOG.md +6 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/lib/sidekiq/lock/redis_lock.rb +5 -1
- data/lib/sidekiq/lock/version.rb +1 -1
- data/test/lib/lock_test.rb +5 -4
- data/test/lib/middleware_test.rb +3 -2
- data/test/lib/worker_test.rb +20 -31
- data/test/test_helper.rb +1 -3
- data/test/test_workers.rb +1 -0
- metadata +5 -89
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9c3099623c0436cfe8cbd6eb0d3f56168ac0fda088b7167a0211ca4cba6e530
|
4
|
+
data.tar.gz: b5105d14dd29c9374b43a46cba4cfd6c576f086808051949bf4729c9163be05e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/README.md
CHANGED
@@ -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
|
-
|
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
|
|
data/lib/sidekiq/lock/version.rb
CHANGED
data/test/lib/lock_test.rb
CHANGED
@@ -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
|
-
|
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(
|
16
|
+
Timeout.timeout(3) do
|
17
17
|
until stdout.eof? do
|
18
|
-
|
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,
|
27
|
+
assert_match(/\s?Middleware:.*Sidekiq::Lock::Middleware/i, buffer_out)
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|
data/test/lib/middleware_test.rb
CHANGED
@@ -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
|
data/test/lib/worker_test.rb
CHANGED
@@ -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
|
-
|
29
|
-
Sidekiq.lock_method = :custom_lock_name
|
21
|
+
Sidekiq.lock_method = :custom_lock_name
|
30
22
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
23
|
+
class WorkerWithCustomLockName
|
24
|
+
include Sidekiq::Worker
|
25
|
+
include Sidekiq::Lock::Worker
|
26
|
+
end
|
35
27
|
|
36
|
-
|
28
|
+
set_lock_variable! "custom_name"
|
37
29
|
|
38
|
-
|
30
|
+
assert_equal "custom_name", WorkerWithCustomLockName.new.custom_lock_name
|
39
31
|
|
40
|
-
|
41
|
-
|
32
|
+
reset_lock_variable!
|
33
|
+
ensure
|
42
34
|
|
43
|
-
|
44
|
-
end
|
35
|
+
Sidekiq.lock_method = Sidekiq::Lock::METHOD_NAME
|
45
36
|
end
|
46
37
|
|
47
38
|
it 'allows container configuration' do
|
48
|
-
|
49
|
-
|
50
|
-
Sidekiq.lock_container = container
|
39
|
+
container = CustomContainer.new
|
40
|
+
Sidekiq.lock_container = container
|
51
41
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
42
|
+
class WorkerWithCustomContainer
|
43
|
+
include Sidekiq::Worker
|
44
|
+
include Sidekiq::Lock::Worker
|
45
|
+
end
|
56
46
|
|
57
|
-
|
47
|
+
container.store "lock-variable"
|
58
48
|
|
59
|
-
|
60
|
-
|
61
|
-
|
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
data/test/test_workers.rb
CHANGED
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.
|
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:
|
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:
|
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:
|
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.
|
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
|