sidekiq-limit_fetch 4.0.0 → 4.3.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: 88e19126b173869fae0b5046533e8615d2785fb903f01b979cbcdea65e7824b5
4
- data.tar.gz: 212cfdcf179fa2aceb6eb065e7bd384109f3afbf2ff08da27699197a300cf044
3
+ metadata.gz: 1e1c022a896ec81cb597f174e844fae80fc2c3c642fbf0872d87c00b0651a378
4
+ data.tar.gz: b80c13c01232fac37df35c85353974eed389d353fd84c842d368e844a350a8b9
5
5
  SHA512:
6
- metadata.gz: 0f0c99a5e6d183f9ce41c7bfd85f74926efad1515f29d88d24c7c1076b108121ed9c963ea60d76406c4a006e9b49dcb09239d9fe5b14e59e8f3702b7e4591689
7
- data.tar.gz: 888322ef2940592c4d65095b136a4a4cf27cfe7f9bb470cb071fe3a47028cd095fc9b4c30392cb3d25be26536126851f357a61f6b31145dfb31add97f9250bec
6
+ metadata.gz: 2c4e5565fff18225cf65f1ef86ace76375fa7c36cd895a132e19ad06d02ba50e3cecfc34d961fa9183374257895b3fb49300d7cda7eeb9bd8875b2e0baac6cc1
7
+ data.tar.gz: 550341eeafa2a83bc5236223148ca0ffcab8774f4ebcf6832386d7fe0a07e6f7176c5feb8e3c79db333ee5aed6fedf6f6a16124b39e45aab83ded720922e071a
@@ -14,8 +14,8 @@ jobs:
14
14
  strategy:
15
15
  fail-fast: false
16
16
  matrix:
17
- ruby: ["2.6", "2.7", "3.0", "3.1", jruby-9.3]
18
- appraisal: ['5.0', '5.1', '5.2', '6.0', '6.1', '6.2', '6.3', '6.4']
17
+ ruby: ["2.7", "3.0", "3.1"]
18
+ appraisal: ['6.0', '6.1', '6.2', '6.3', '6.4', '6.5', 'master']
19
19
  services:
20
20
  redis:
21
21
  image: redis
data/Appraisals CHANGED
@@ -1,15 +1,3 @@
1
- appraise 'sidekiq-5.0' do
2
- gem 'sidekiq', '~> 5.0.0'
3
- end
4
-
5
- appraise 'sidekiq-5.1' do
6
- gem 'sidekiq', '~> 5.1.0'
7
- end
8
-
9
- appraise 'sidekiq-5.2' do
10
- gem 'sidekiq', '~> 5.2.0'
11
- end
12
-
13
1
  appraise 'sidekiq-6.0' do
14
2
  gem 'sidekiq', '~> 6.0.0'
15
3
  end
@@ -30,6 +18,10 @@ appraise 'sidekiq-6.4' do
30
18
  gem 'sidekiq', '~> 6.4.0'
31
19
  end
32
20
 
21
+ appraise 'sidekiq-6.5' do
22
+ gem 'sidekiq', '~> 6.5.0'
23
+ end
24
+
33
25
  appraise 'sidekiq-master' do
34
26
  gem 'sidekiq', github: 'mperham/sidekiq'
35
27
  end
data/CHANGELOG.md ADDED
@@ -0,0 +1,22 @@
1
+ # Changelog
2
+
3
+ ## [4.3.0] - 2022-08-16
4
+
5
+ - #135 - Some extra fixes for Sidekiq 6.5 (fixes #128, #130, #131) from [@BobbyMcWho](https://github.com/BobbyMcWho)
6
+
7
+ ## [4.2.0] - 2022-06-09
8
+
9
+ - #127 - Fix for Sidekiq 6.5 internal change vias PR #128 from [@evgeniradev][https://github.com/evgeniradev]
10
+ - testing changes: stop supporting Sidekiq < 6, add tests for Sidekiq 6.5, stop testing on ruby 2.6 EOL
11
+
12
+ ## [4.1.0] - 2022-03-29
13
+
14
+ - #101 - Fix stuck queues bug on Redis restart from [@907th](https://github.com/907th).
15
+
16
+ ## [4.0.0] - 2022-03-26
17
+
18
+ This project was taken over by [@deanpcmad](https://github.com/deanpcmad)
19
+
20
+ - #120 - Migrate CI to GitHub Actions from [@petergoldstein](https://github.com/petergoldstein).
21
+ - #124 - Fixed redis v4.6.0 pipelines deprecation warning from [@iurev](https://github.com/iurev).
22
+ - #83 - Processing dynamic queues from [@alexey-yanchenko](https://github.com/alexey-yanchenko).
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Dean Perry
4
+ Copyright (c) 2013 brainopia
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## Description
2
2
 
3
- *This project is currently being taken over by [@deanpcmad](https://github.com/deanpcmad) and will be updated soon*
3
+ *This project has been taken over by [@deanpcmad](https://github.com/deanpcmad)*
4
4
 
5
5
  Sidekiq strategy to support a granular queue control – limiting, pausing, blocking, querying.
6
6
 
@@ -11,7 +11,11 @@ Sidekiq strategy to support a granular queue control – limiting, pausing, bloc
11
11
 
12
12
  Add this line to your application's Gemfile:
13
13
 
14
- gem 'sidekiq-limit_fetch'
14
+ ```
15
+ gem 'sidekiq-limit_fetch'
16
+ ```
17
+
18
+ Then `bundle install`.
15
19
 
16
20
  ### Limitations
17
21
 
@@ -31,19 +35,19 @@ To use this Gem in other Ruby projects, just add `require 'sidekiq-limit_fetch'`
31
35
  Specify limits which you want to place on queues inside sidekiq.yml:
32
36
 
33
37
  ```yaml
34
- :limits:
35
- queue_name1: 5
36
- queue_name2: 10
38
+ :limits:
39
+ queue_name1: 5
40
+ queue_name2: 10
37
41
  ```
38
42
 
39
43
  Or set it dynamically in your code:
40
44
  ```ruby
41
- Sidekiq::Queue['queue_name1'].limit = 5
42
- Sidekiq::Queue['queue_name2'].limit = 10
45
+ Sidekiq::Queue['queue_name1'].limit = 5
46
+ Sidekiq::Queue['queue_name2'].limit = 10
43
47
  ```
44
48
 
45
- In these examples, tasks for the ```queue_name1``` will be run by at most 5
46
- workers at the same time and the ```queue_name2``` will have no more than 10
49
+ In these examples, tasks for the `queue_name1` will be run by at most 5
50
+ workers at the same time and the `queue_name2` will have no more than 10
47
51
  workers simultaneously.
48
52
 
49
53
  Ability to set limits dynamically allows you to resize worker
@@ -54,14 +58,14 @@ distribution among queues any time you want.
54
58
  If you use multiple sidekiq processes then you can specify limits per process:
55
59
 
56
60
  ```yaml
57
- :process_limits:
58
- queue_name: 2
61
+ :process_limits:
62
+ queue_name: 2
59
63
  ```
60
64
 
61
65
  Or set it in your code:
62
66
 
63
67
  ```ruby
64
- Sidekiq::Queue['queue_name'].process_limit = 2
68
+ Sidekiq::Queue['queue_name'].process_limit = 2
65
69
  ```
66
70
 
67
71
  ### Busy workers by queue
@@ -69,7 +73,7 @@ Or set it in your code:
69
73
  You can see how many workers currently handling a queue:
70
74
 
71
75
  ```ruby
72
- Sidekiq::Queue['name'].busy # number of busy workers
76
+ Sidekiq::Queue['name'].busy # number of busy workers
73
77
  ```
74
78
 
75
79
  ### Pauses
@@ -78,10 +82,10 @@ You can also pause your queues temporarily. Upon continuing their limits
78
82
  will be preserved.
79
83
 
80
84
  ```ruby
81
- Sidekiq::Queue['name'].pause # prevents workers from running tasks from this queue
82
- Sidekiq::Queue['name'].paused? # => true
83
- Sidekiq::Queue['name'].unpause # allows workers to use the queue
84
- Sidekiq::Queue['name'].pause_for_ms(1000) # will pause for a second
85
+ Sidekiq::Queue['name'].pause # prevents workers from running tasks from this queue
86
+ Sidekiq::Queue['name'].paused? # => true
87
+ Sidekiq::Queue['name'].unpause # allows workers to use the queue
88
+ Sidekiq::Queue['name'].pause_for_ms(1000) # will pause for a second
85
89
  ```
86
90
 
87
91
  ### Blocking queue mode
@@ -92,12 +96,12 @@ queue task is executing then no new task from lesser priority queues will
92
96
  be ran. Eg,
93
97
 
94
98
  ```yaml
95
- :queues:
96
- - a
97
- - b
98
- - c
99
- :blocking:
100
- - b
99
+ :queues:
100
+ - a
101
+ - b
102
+ - c
103
+ :blocking:
104
+ - b
101
105
  ```
102
106
 
103
107
  In this case when a task for `b` queue is ran no new task from `c` queue
@@ -106,9 +110,9 @@ will be started.
106
110
  You can also enable and disable blocking mode for queues on the fly:
107
111
 
108
112
  ```ruby
109
- Sidekiq::Queue['name'].block
110
- Sidekiq::Queue['name'].blocking? # => true
111
- Sidekiq::Queue['name'].unblock
113
+ Sidekiq::Queue['name'].block
114
+ Sidekiq::Queue['name'].blocking? # => true
115
+ Sidekiq::Queue['name'].unblock
112
116
  ```
113
117
 
114
118
  ### Advanced blocking queues
@@ -118,13 +122,13 @@ running only queues higher and queues from their blocking group can
118
122
  run. It will be easier to understand with an example:
119
123
 
120
124
  ```yaml
121
- :queues:
122
- - a
123
- - b
124
- - c
125
- - d
126
- :blocking:
127
- - [b, c]
125
+ :queues:
126
+ - a
127
+ - b
128
+ - c
129
+ - d
130
+ :blocking:
131
+ - [b, c]
128
132
  ```
129
133
 
130
134
  In this case tasks from `d` will be blocked when a task from queue `b` or `c` is executed.
@@ -132,7 +136,7 @@ In this case tasks from `d` will be blocked when a task from queue `b` or `c` is
132
136
  You can dynamically set exceptions for queue blocking:
133
137
 
134
138
  ```ruby
135
- Sidekiq::Queue['queue1'].block_except 'queue2'
139
+ Sidekiq::Queue['queue1'].block_except 'queue2'
136
140
  ```
137
141
 
138
142
  ### Dynamic queues
@@ -143,11 +147,11 @@ that have tasks pushed to them (usually with `Sidekiq::Client.push`)).
143
147
  To use this mode you need to specify a following line in sidekiq.yml:
144
148
 
145
149
  ```yaml
146
- :dynamic: true
150
+ :dynamic: true
147
151
  ```
148
152
 
149
153
  Dynamic queues will be ran at the lowest priority.
150
154
 
151
155
  ### Maintenance
152
156
 
153
- If you use ```flushdb```, restart the sidekiq process to re-populate the dynamic configuration.
157
+ If you use `flushdb`, restart the sidekiq process to re-populate the dynamic configuration.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- sidekiq-limit_fetch (3.4.0)
4
+ sidekiq-limit_fetch (4.3.0)
5
5
  redis (>= 4.6.0)
6
6
  sidekiq (>= 4)
7
7
 
@@ -14,7 +14,7 @@ GEM
14
14
  thor (>= 0.14.0)
15
15
  connection_pool (2.2.5)
16
16
  diff-lcs (1.5.0)
17
- rack (2.2.3)
17
+ rack (2.2.3.1)
18
18
  rack-protection (2.2.0)
19
19
  rack
20
20
  rake (13.0.6)
@@ -30,7 +30,7 @@ GEM
30
30
  rspec-expectations (3.11.0)
31
31
  diff-lcs (>= 1.2.0, < 2.0)
32
32
  rspec-support (~> 3.11.0)
33
- rspec-mocks (3.11.0)
33
+ rspec-mocks (3.11.1)
34
34
  diff-lcs (>= 1.2.0, < 2.0)
35
35
  rspec-support (~> 3.11.0)
36
36
  rspec-support (3.11.0)
@@ -53,4 +53,4 @@ DEPENDENCIES
53
53
  sidekiq-limit_fetch!
54
54
 
55
55
  BUNDLED WITH
56
- 2.3.6
56
+ 2.3.5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- sidekiq-limit_fetch (3.4.0)
4
+ sidekiq-limit_fetch (4.3.0)
5
5
  redis (>= 4.6.0)
6
6
  sidekiq (>= 4)
7
7
 
@@ -14,7 +14,7 @@ GEM
14
14
  thor (>= 0.14.0)
15
15
  connection_pool (2.2.5)
16
16
  diff-lcs (1.5.0)
17
- rack (2.2.3)
17
+ rack (2.2.3.1)
18
18
  rake (13.0.6)
19
19
  redis (4.6.0)
20
20
  redis-namespace (1.8.2)
@@ -28,7 +28,7 @@ GEM
28
28
  rspec-expectations (3.11.0)
29
29
  diff-lcs (>= 1.2.0, < 2.0)
30
30
  rspec-support (~> 3.11.0)
31
- rspec-mocks (3.11.0)
31
+ rspec-mocks (3.11.1)
32
32
  diff-lcs (>= 1.2.0, < 2.0)
33
33
  rspec-support (~> 3.11.0)
34
34
  rspec-support (3.11.0)
@@ -50,4 +50,4 @@ DEPENDENCIES
50
50
  sidekiq-limit_fetch!
51
51
 
52
52
  BUNDLED WITH
53
- 2.3.6
53
+ 2.3.5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- sidekiq-limit_fetch (3.4.0)
4
+ sidekiq-limit_fetch (4.3.0)
5
5
  redis (>= 4.6.0)
6
6
  sidekiq (>= 4)
7
7
 
@@ -14,7 +14,7 @@ GEM
14
14
  thor (>= 0.14.0)
15
15
  connection_pool (2.2.5)
16
16
  diff-lcs (1.5.0)
17
- rack (2.2.3)
17
+ rack (2.2.3.1)
18
18
  rake (13.0.6)
19
19
  redis (4.6.0)
20
20
  redis-namespace (1.8.2)
@@ -28,11 +28,11 @@ GEM
28
28
  rspec-expectations (3.11.0)
29
29
  diff-lcs (>= 1.2.0, < 2.0)
30
30
  rspec-support (~> 3.11.0)
31
- rspec-mocks (3.11.0)
31
+ rspec-mocks (3.11.1)
32
32
  diff-lcs (>= 1.2.0, < 2.0)
33
33
  rspec-support (~> 3.11.0)
34
34
  rspec-support (3.11.0)
35
- sidekiq (6.2.1)
35
+ sidekiq (6.2.2)
36
36
  connection_pool (>= 2.2.2)
37
37
  rack (~> 2.0)
38
38
  redis (>= 4.2.0)
@@ -50,4 +50,4 @@ DEPENDENCIES
50
50
  sidekiq-limit_fetch!
51
51
 
52
52
  BUNDLED WITH
53
- 2.3.6
53
+ 2.3.5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- sidekiq-limit_fetch (3.4.0)
4
+ sidekiq-limit_fetch (4.3.0)
5
5
  redis (>= 4.6.0)
6
6
  sidekiq (>= 4)
7
7
 
@@ -14,7 +14,7 @@ GEM
14
14
  thor (>= 0.14.0)
15
15
  connection_pool (2.2.5)
16
16
  diff-lcs (1.5.0)
17
- rack (2.2.3)
17
+ rack (2.2.3.1)
18
18
  rake (13.0.6)
19
19
  redis (4.6.0)
20
20
  redis-namespace (1.8.2)
@@ -28,7 +28,7 @@ GEM
28
28
  rspec-expectations (3.11.0)
29
29
  diff-lcs (>= 1.2.0, < 2.0)
30
30
  rspec-support (~> 3.11.0)
31
- rspec-mocks (3.11.0)
31
+ rspec-mocks (3.11.1)
32
32
  diff-lcs (>= 1.2.0, < 2.0)
33
33
  rspec-support (~> 3.11.0)
34
34
  rspec-support (3.11.0)
@@ -50,4 +50,4 @@ DEPENDENCIES
50
50
  sidekiq-limit_fetch!
51
51
 
52
52
  BUNDLED WITH
53
- 2.3.6
53
+ 2.3.5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- sidekiq-limit_fetch (3.4.0)
4
+ sidekiq-limit_fetch (4.3.0)
5
5
  redis (>= 4.6.0)
6
6
  sidekiq (>= 4)
7
7
 
@@ -14,7 +14,7 @@ GEM
14
14
  thor (>= 0.14.0)
15
15
  connection_pool (2.2.5)
16
16
  diff-lcs (1.5.0)
17
- rack (2.2.3)
17
+ rack (2.2.3.1)
18
18
  rake (13.0.6)
19
19
  redis (4.6.0)
20
20
  redis-namespace (1.8.2)
@@ -28,11 +28,11 @@ GEM
28
28
  rspec-expectations (3.11.0)
29
29
  diff-lcs (>= 1.2.0, < 2.0)
30
30
  rspec-support (~> 3.11.0)
31
- rspec-mocks (3.11.0)
31
+ rspec-mocks (3.11.1)
32
32
  diff-lcs (>= 1.2.0, < 2.0)
33
33
  rspec-support (~> 3.11.0)
34
34
  rspec-support (3.11.0)
35
- sidekiq (6.4.1)
35
+ sidekiq (6.4.2)
36
36
  connection_pool (>= 2.2.2)
37
37
  rack (~> 2.0)
38
38
  redis (>= 4.2.0)
@@ -50,4 +50,4 @@ DEPENDENCIES
50
50
  sidekiq-limit_fetch!
51
51
 
52
52
  BUNDLED WITH
53
- 2.3.6
53
+ 2.3.5
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "sidekiq", "~> 5.2.0"
5
+ gem "sidekiq", "~> 6.5.0"
6
6
 
7
7
  gemspec path: "../"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- sidekiq-limit_fetch (3.4.0)
4
+ sidekiq-limit_fetch (4.3.0)
5
5
  redis (>= 4.6.0)
6
6
  sidekiq (>= 4)
7
7
 
@@ -14,9 +14,7 @@ GEM
14
14
  thor (>= 0.14.0)
15
15
  connection_pool (2.2.5)
16
16
  diff-lcs (1.5.0)
17
- rack (2.0.9)
18
- rack-protection (2.2.0)
19
- rack
17
+ rack (2.2.3.1)
20
18
  rake (13.0.6)
21
19
  redis (4.6.0)
22
20
  redis-namespace (1.8.2)
@@ -30,15 +28,14 @@ GEM
30
28
  rspec-expectations (3.11.0)
31
29
  diff-lcs (>= 1.2.0, < 2.0)
32
30
  rspec-support (~> 3.11.0)
33
- rspec-mocks (3.11.0)
31
+ rspec-mocks (3.11.1)
34
32
  diff-lcs (>= 1.2.0, < 2.0)
35
33
  rspec-support (~> 3.11.0)
36
34
  rspec-support (3.11.0)
37
- sidekiq (5.2.8)
38
- connection_pool (~> 2.2, >= 2.2.2)
39
- rack (< 2.1.0)
40
- rack-protection (>= 1.5.0)
41
- redis (>= 3.3.5, < 5)
35
+ sidekiq (6.5.0)
36
+ connection_pool (>= 2.2.2)
37
+ rack (~> 2.0)
38
+ redis (>= 4.2.0)
42
39
  thor (1.2.1)
43
40
 
44
41
  PLATFORMS
@@ -49,8 +46,8 @@ DEPENDENCIES
49
46
  rake
50
47
  redis-namespace (~> 1.5, >= 1.5.2)
51
48
  rspec
52
- sidekiq (~> 5.2.0)
49
+ sidekiq (~> 6.5.0)
53
50
  sidekiq-limit_fetch!
54
51
 
55
52
  BUNDLED WITH
56
- 2.3.6
53
+ 2.3.5
@@ -1,8 +1,8 @@
1
1
  GIT
2
2
  remote: https://github.com/mperham/sidekiq.git
3
- revision: cf7b067c89ae3b1303e35d29408099cf40991f6d
3
+ revision: 277ea1888f25917e9dde8d00bdb866f86a55691f
4
4
  specs:
5
- sidekiq (6.4.2)
5
+ sidekiq (6.5.0)
6
6
  connection_pool (>= 2.2.2)
7
7
  rack (~> 2.0)
8
8
  redis (>= 4.2.0)
@@ -10,7 +10,7 @@ GIT
10
10
  PATH
11
11
  remote: ..
12
12
  specs:
13
- sidekiq-limit_fetch (3.4.0)
13
+ sidekiq-limit_fetch (4.3.0)
14
14
  redis (>= 4.6.0)
15
15
  sidekiq (>= 4)
16
16
 
@@ -23,7 +23,7 @@ GEM
23
23
  thor (>= 0.14.0)
24
24
  connection_pool (2.2.5)
25
25
  diff-lcs (1.5.0)
26
- rack (2.2.3)
26
+ rack (2.2.3.1)
27
27
  rake (13.0.6)
28
28
  redis (4.6.0)
29
29
  redis-namespace (1.8.2)
@@ -37,7 +37,7 @@ GEM
37
37
  rspec-expectations (3.11.0)
38
38
  diff-lcs (>= 1.2.0, < 2.0)
39
39
  rspec-support (~> 3.11.0)
40
- rspec-mocks (3.11.0)
40
+ rspec-mocks (3.11.1)
41
41
  diff-lcs (>= 1.2.0, < 2.0)
42
42
  rspec-support (~> 3.11.0)
43
43
  rspec-support (3.11.0)
@@ -55,4 +55,4 @@ DEPENDENCIES
55
55
  sidekiq-limit_fetch!
56
56
 
57
57
  BUNDLED WITH
58
- 2.3.6
58
+ 2.3.5
@@ -6,7 +6,8 @@ class Sidekiq::Manager
6
6
  end
7
7
 
8
8
  def start
9
- Sidekiq::LimitFetch::Queues.start options
9
+ # In sidekiq 6.5.0 the variable @options has been renamed to @config
10
+ Sidekiq::LimitFetch::Queues.start @options || @config
10
11
  Sidekiq::LimitFetch::Global::Monitor.start!
11
12
  super
12
13
  end
@@ -20,15 +20,17 @@ module Sidekiq::LimitFetch::Queues
20
20
  end
21
21
 
22
22
  def acquire
23
- selector.acquire(ordered_queues, namespace)
24
- .tap {|it| save it }
25
- .map {|it| "queue:#{it}" }
23
+ queues = saved
24
+ queues ||= Sidekiq::LimitFetch.redis_retryable do
25
+ selector.acquire(ordered_queues, namespace)
26
+ end
27
+ save queues
28
+ queues.map { |it| "queue:#{it}" }
26
29
  end
27
30
 
28
31
  def release_except(full_name)
29
32
  queues = restore
30
33
  queues.delete full_name[/queue:(.*)/, 1] if full_name
31
-
32
34
  Sidekiq::LimitFetch.redis_retryable do
33
35
  selector.release queues, namespace
34
36
  end
@@ -141,13 +143,17 @@ module Sidekiq::LimitFetch::Queues
141
143
  Sidekiq::LimitFetch::Global::Selector
142
144
  end
143
145
 
146
+ def saved
147
+ Thread.current[THREAD_KEY]
148
+ end
149
+
144
150
  def save(queues)
145
151
  Thread.current[THREAD_KEY] = queues
146
152
  end
147
153
 
148
154
  def restore
149
- Thread.current[THREAD_KEY] || []
155
+ saved || []
150
156
  ensure
151
- Thread.current[THREAD_KEY] = nil
157
+ save nil
152
158
  end
153
159
  end
@@ -1,7 +1,11 @@
1
1
  module Sidekiq
2
2
  class LimitFetch::UnitOfWork < BasicFetch::UnitOfWork
3
3
  def initialize(queue, job)
4
- super
4
+ if post_6_5?
5
+ super(queue, job, Sidekiq)
6
+ else
7
+ super
8
+ end
5
9
  redis_retryable { Queue[queue_name].increase_busy }
6
10
  end
7
11
 
@@ -17,6 +21,10 @@ module Sidekiq
17
21
 
18
22
  private
19
23
 
24
+ def post_6_5?
25
+ Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('6.5.0')
26
+ end
27
+
20
28
  def redis_retryable(&block)
21
29
  Sidekiq::LimitFetch.redis_retryable(&block)
22
30
  end
@@ -14,6 +14,8 @@ module Sidekiq::LimitFetch
14
14
  require_relative 'extensions/queue'
15
15
  require_relative 'extensions/manager'
16
16
 
17
+ TIMEOUT = Sidekiq::BasicFetch::TIMEOUT
18
+
17
19
  extend self
18
20
 
19
21
  def new(_)
@@ -26,26 +28,42 @@ module Sidekiq::LimitFetch
26
28
  UnitOfWork.new(queue, job) if job
27
29
  end
28
30
 
31
+ def config
32
+ # Post 6.5, Sidekiq.options is deprecated and replaced with passing Sidekiq directly
33
+ post_6_5? ? Sidekiq : Sidekiq.options
34
+ end
35
+
29
36
  # Backwards compatibility for sidekiq v6.1.0
30
37
  # @see https://github.com/mperham/sidekiq/pull/4602
31
38
  def bulk_requeue(*args)
32
39
  if Sidekiq::BasicFetch.respond_to?(:bulk_requeue) # < 6.1.0
33
40
  Sidekiq::BasicFetch.bulk_requeue(*args)
34
41
  else # 6.1.0+
35
- Sidekiq::BasicFetch.new(Sidekiq.options).bulk_requeue(*args)
42
+ Sidekiq::BasicFetch.new(config).bulk_requeue(*args)
36
43
  end
37
44
  end
38
45
 
39
46
  def redis_retryable
40
47
  yield
41
48
  rescue Redis::BaseConnectionError
42
- sleep 1
49
+ sleep TIMEOUT
43
50
  retry
51
+ rescue Redis::CommandError => error
52
+ # If Redis was restarted and is still loading its snapshot,
53
+ # then we should treat this as a temporary connection error too.
54
+ if error.message =~ /^LOADING/
55
+ sleep TIMEOUT
56
+ retry
57
+ else
58
+ raise
59
+ end
44
60
  end
45
61
 
46
62
  private
47
63
 
48
- TIMEOUT = Sidekiq::BasicFetch::TIMEOUT
64
+ def post_6_5?
65
+ @post_6_5 ||= Gem::Version.new(Sidekiq::VERSION) >= Gem::Version.new('6.5.0')
66
+ end
49
67
 
50
68
  def redis_brpop(queues)
51
69
  if queues.empty?
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'sidekiq-limit_fetch'
3
- gem.version = '4.0.0'
3
+ gem.version = '4.3.0'
4
4
  gem.license = 'MIT'
5
5
  gem.authors = ['Dean Perry', 'brainopia']
6
6
  gem.email = 'dean@deanpcmad.com'
@@ -8,6 +8,10 @@ Gem::Specification.new do |gem|
8
8
  gem.homepage = 'https://github.com/deanpcmad/sidekiq-limit_fetch'
9
9
  gem.description = "Sidekiq strategy to restrict number of workers which are able to run specified queues simultaneously."
10
10
 
11
+ gem.metadata["homepage_uri"] = gem.homepage
12
+ gem.metadata["source_code_uri"] = "https://github.com/deanpcmad/sidekiq-limit_fetch"
13
+ gem.metadata["changelog_uri"] = "https://github.com/deanpcmad/sidekiq-limit_fetch/blob/master/CHANGELOG.md"
14
+
11
15
  gem.files = `git ls-files`.split($/)
12
16
  gem.test_files = gem.files.grep %r{^spec/}
13
17
  gem.require_paths = %w(lib)
@@ -15,61 +15,72 @@ RSpec.describe Sidekiq::LimitFetch::Queues do
15
15
 
16
16
  before { subject.start options }
17
17
 
18
+ def in_thread(&block)
19
+ thr = Thread.new(&block)
20
+ thr.join
21
+ end
22
+
18
23
  it 'should acquire queues' do
19
- subject.acquire
24
+ in_thread { subject.acquire }
20
25
  expect(Sidekiq::Queue['queue1'].probed).to eq 1
21
26
  expect(Sidekiq::Queue['queue2'].probed).to eq 1
22
27
  end
23
28
 
24
29
  it 'should acquire dynamically blocking queues' do
25
- subject.acquire
30
+ in_thread { subject.acquire }
26
31
  expect(Sidekiq::Queue['queue1'].probed).to eq 1
27
32
  expect(Sidekiq::Queue['queue2'].probed).to eq 1
28
33
 
29
34
  Sidekiq::Queue['queue1'].block
30
35
 
31
- subject.acquire
36
+ in_thread { subject.acquire }
32
37
  expect(Sidekiq::Queue['queue1'].probed).to eq 2
33
38
  expect(Sidekiq::Queue['queue2'].probed).to eq 1
34
39
  end
35
40
 
36
41
  it 'should block except given queues' do
37
42
  Sidekiq::Queue['queue1'].block_except 'queue2'
38
- subject.acquire
43
+ in_thread { subject.acquire }
39
44
  expect(Sidekiq::Queue['queue1'].probed).to eq 1
40
45
  expect(Sidekiq::Queue['queue2'].probed).to eq 1
41
46
 
42
47
  Sidekiq::Queue['queue1'].block_except 'queue404'
43
- subject.acquire
48
+ in_thread { subject.acquire }
44
49
  expect(Sidekiq::Queue['queue1'].probed).to eq 2
45
50
  expect(Sidekiq::Queue['queue2'].probed).to eq 1
46
51
  end
47
52
 
48
53
  it 'should release queues' do
49
- subject.acquire
50
- subject.release_except nil
54
+ in_thread {
55
+ subject.acquire
56
+ subject.release_except nil
57
+ }
51
58
  expect(Sidekiq::Queue['queue1'].probed).to eq 0
52
59
  expect(Sidekiq::Queue['queue2'].probed).to eq 0
53
60
  end
54
61
 
55
62
  it 'should release queues except selected' do
56
- subject.acquire
57
- subject.release_except 'queue:queue1'
63
+ in_thread {
64
+ subject.acquire
65
+ subject.release_except 'queue:queue1'
66
+ }
58
67
  expect(Sidekiq::Queue['queue1'].probed).to eq 1
59
68
  expect(Sidekiq::Queue['queue2'].probed).to eq 0
60
69
  end
61
70
 
62
71
  it 'should release when no queues was acquired' do
63
72
  queues.each {|name| Sidekiq::Queue[name].pause }
64
- subject.acquire
65
- expect { subject.release_except nil }.not_to raise_exception
73
+ in_thread {
74
+ subject.acquire
75
+ expect { subject.release_except nil }.not_to raise_exception
76
+ }
66
77
  end
67
78
 
68
79
  context 'blocking' do
69
80
  let(:blocking) { %w(queue1) }
70
81
 
71
82
  it 'should acquire blocking queues' do
72
- 3.times { subject.acquire }
83
+ 3.times { in_thread { subject.acquire } }
73
84
  expect(Sidekiq::Queue['queue1'].probed).to eq 3
74
85
  expect(Sidekiq::Queue['queue2'].probed).to eq 1
75
86
  end
@@ -6,7 +6,7 @@ RSpec.describe Sidekiq::LimitFetch do
6
6
  let(:limits) {{ 'queue1' => 1, 'queue2' => 2 }}
7
7
 
8
8
  before do
9
- subject::Queues.start options
9
+ subject::Queues.start options
10
10
 
11
11
  Sidekiq.redis do |it|
12
12
  it.del 'queue:queue1'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-limit_fetch
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dean Perry
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-03-26 00:00:00.000000000 Z
12
+ date: 2022-08-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sidekiq
@@ -112,8 +112,9 @@ files:
112
112
  - ".gitignore"
113
113
  - ".rspec"
114
114
  - Appraisals
115
+ - CHANGELOG.md
115
116
  - Gemfile
116
- - LICENSE.txt
117
+ - LICENSE
117
118
  - README.md
118
119
  - Rakefile
119
120
  - bench/compare.rb
@@ -129,12 +130,6 @@ files:
129
130
  - demo/config/boot.rb
130
131
  - demo/config/environment.rb
131
132
  - demo/config/environments/development.rb
132
- - gemfiles/sidekiq_5.0.gemfile
133
- - gemfiles/sidekiq_5.0.gemfile.lock
134
- - gemfiles/sidekiq_5.1.gemfile
135
- - gemfiles/sidekiq_5.1.gemfile.lock
136
- - gemfiles/sidekiq_5.2.gemfile
137
- - gemfiles/sidekiq_5.2.gemfile.lock
138
133
  - gemfiles/sidekiq_6.0.gemfile
139
134
  - gemfiles/sidekiq_6.0.gemfile.lock
140
135
  - gemfiles/sidekiq_6.1.gemfile
@@ -145,6 +140,8 @@ files:
145
140
  - gemfiles/sidekiq_6.3.gemfile.lock
146
141
  - gemfiles/sidekiq_6.4.gemfile
147
142
  - gemfiles/sidekiq_6.4.gemfile.lock
143
+ - gemfiles/sidekiq_6.5.gemfile
144
+ - gemfiles/sidekiq_6.5.gemfile.lock
148
145
  - gemfiles/sidekiq_master.gemfile
149
146
  - gemfiles/sidekiq_master.gemfile.lock
150
147
  - lib/sidekiq-limit_fetch.rb
@@ -167,7 +164,10 @@ files:
167
164
  homepage: https://github.com/deanpcmad/sidekiq-limit_fetch
168
165
  licenses:
169
166
  - MIT
170
- metadata: {}
167
+ metadata:
168
+ homepage_uri: https://github.com/deanpcmad/sidekiq-limit_fetch
169
+ source_code_uri: https://github.com/deanpcmad/sidekiq-limit_fetch
170
+ changelog_uri: https://github.com/deanpcmad/sidekiq-limit_fetch/blob/master/CHANGELOG.md
171
171
  post_install_message:
172
172
  rdoc_options: []
173
173
  require_paths:
@@ -183,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
183
  - !ruby/object:Gem::Version
184
184
  version: '0'
185
185
  requirements: []
186
- rubygems_version: 3.1.6
186
+ rubygems_version: 3.3.7
187
187
  signing_key:
188
188
  specification_version: 4
189
189
  summary: Sidekiq strategy to support queue limits
data/LICENSE.txt DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2013 brainopia
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "sidekiq", "~> 5.0.0"
6
-
7
- gemspec path: "../"
@@ -1,57 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- sidekiq-limit_fetch (3.4.0)
5
- redis (>= 4.6.0)
6
- sidekiq (>= 4)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- appraisal (2.4.1)
12
- bundler
13
- rake
14
- thor (>= 0.14.0)
15
- concurrent-ruby (1.1.10)
16
- connection_pool (2.2.5)
17
- diff-lcs (1.5.0)
18
- rack (2.2.3)
19
- rack-protection (2.2.0)
20
- rack
21
- rake (13.0.6)
22
- redis (4.6.0)
23
- redis-namespace (1.8.2)
24
- redis (>= 3.0.4)
25
- rspec (3.11.0)
26
- rspec-core (~> 3.11.0)
27
- rspec-expectations (~> 3.11.0)
28
- rspec-mocks (~> 3.11.0)
29
- rspec-core (3.11.0)
30
- rspec-support (~> 3.11.0)
31
- rspec-expectations (3.11.0)
32
- diff-lcs (>= 1.2.0, < 2.0)
33
- rspec-support (~> 3.11.0)
34
- rspec-mocks (3.11.0)
35
- diff-lcs (>= 1.2.0, < 2.0)
36
- rspec-support (~> 3.11.0)
37
- rspec-support (3.11.0)
38
- sidekiq (5.0.5)
39
- concurrent-ruby (~> 1.0)
40
- connection_pool (~> 2.2, >= 2.2.0)
41
- rack-protection (>= 1.5.0)
42
- redis (>= 3.3.4, < 5)
43
- thor (1.2.1)
44
-
45
- PLATFORMS
46
- x86_64-linux
47
-
48
- DEPENDENCIES
49
- appraisal
50
- rake
51
- redis-namespace (~> 1.5, >= 1.5.2)
52
- rspec
53
- sidekiq (~> 5.0.0)
54
- sidekiq-limit_fetch!
55
-
56
- BUNDLED WITH
57
- 2.3.6
@@ -1,7 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "sidekiq", "~> 5.1.0"
6
-
7
- gemspec path: "../"
@@ -1,57 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- sidekiq-limit_fetch (3.4.0)
5
- redis (>= 4.6.0)
6
- sidekiq (>= 4)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- appraisal (2.4.1)
12
- bundler
13
- rake
14
- thor (>= 0.14.0)
15
- concurrent-ruby (1.1.10)
16
- connection_pool (2.2.5)
17
- diff-lcs (1.5.0)
18
- rack (2.2.3)
19
- rack-protection (2.2.0)
20
- rack
21
- rake (13.0.6)
22
- redis (4.6.0)
23
- redis-namespace (1.8.2)
24
- redis (>= 3.0.4)
25
- rspec (3.11.0)
26
- rspec-core (~> 3.11.0)
27
- rspec-expectations (~> 3.11.0)
28
- rspec-mocks (~> 3.11.0)
29
- rspec-core (3.11.0)
30
- rspec-support (~> 3.11.0)
31
- rspec-expectations (3.11.0)
32
- diff-lcs (>= 1.2.0, < 2.0)
33
- rspec-support (~> 3.11.0)
34
- rspec-mocks (3.11.0)
35
- diff-lcs (>= 1.2.0, < 2.0)
36
- rspec-support (~> 3.11.0)
37
- rspec-support (3.11.0)
38
- sidekiq (5.1.3)
39
- concurrent-ruby (~> 1.0)
40
- connection_pool (~> 2.2, >= 2.2.0)
41
- rack-protection (>= 1.5.0)
42
- redis (>= 3.3.5, < 5)
43
- thor (1.2.1)
44
-
45
- PLATFORMS
46
- x86_64-linux
47
-
48
- DEPENDENCIES
49
- appraisal
50
- rake
51
- redis-namespace (~> 1.5, >= 1.5.2)
52
- rspec
53
- sidekiq (~> 5.1.0)
54
- sidekiq-limit_fetch!
55
-
56
- BUNDLED WITH
57
- 2.3.6