Skip to content

Commit 0e7075a

Browse files
committed
Merge branch 'feature/sidekiq-6-5-compatibility' into 'master'
Sidekiq 6.5.6 compatibility See merge request strawberry-4/gems/sidekiq-queue-pause!3
2 parents c2d06b7 + 065268c commit 0e7075a

File tree

10 files changed

+361
-23
lines changed

10 files changed

+361
-23
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
doc
2+
.yardoc
3+
coverage

.rubocop.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require: standard
2+
inherit_gem:
3+
standard: config/base.yml
4+
AllCops:
5+
DisabledByDefault: true

.solargraph.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
include:
3+
- "**/*.rb"
4+
exclude:
5+
- test/**/*
6+
- vendor/**/*
7+
- ".bundle/**/*"
8+
require: []
9+
domains: []
10+
reporters:
11+
- standardrb
12+
- require_not_found
13+
require_paths: []
14+
plugins:
15+
- solargraph-standardrb
16+
max_files: 5000

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source 'https://rubygems.org'
2+
3+
gemspec

Gemfile.lock

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
PATH
2+
remote: .
3+
specs:
4+
sidekiq-queue-pause (0.1.0)
5+
sidekiq (>= 6.0, < 7.0)
6+
7+
GEM
8+
remote: https://rubygems.org/
9+
specs:
10+
addressable (2.8.1)
11+
public_suffix (>= 2.0.2, < 6.0)
12+
ast (2.4.2)
13+
backport (1.2.0)
14+
benchmark (0.2.1)
15+
coderay (1.1.3)
16+
connection_pool (2.3.0)
17+
diff-lcs (1.5.0)
18+
docile (1.4.0)
19+
e2mmap (0.1.0)
20+
faraday (2.7.4)
21+
faraday-net_http (>= 2.0, < 3.1)
22+
ruby2_keywords (>= 0.0.4)
23+
faraday-net_http (3.0.2)
24+
ffi (1.15.5)
25+
formatador (1.1.0)
26+
gitlab (4.19.0)
27+
httparty (~> 0.20)
28+
terminal-table (>= 1.5.1)
29+
guard (2.18.0)
30+
formatador (>= 0.2.4)
31+
listen (>= 2.7, < 4.0)
32+
lumberjack (>= 1.0.12, < 2.0)
33+
nenv (~> 0.1)
34+
notiffany (~> 0.0)
35+
pry (>= 0.13.0)
36+
shellany (~> 0.0)
37+
thor (>= 0.18.1)
38+
guard-compat (1.2.1)
39+
guard-rspec (4.7.3)
40+
guard (~> 2.1)
41+
guard-compat (~> 1.1)
42+
rspec (>= 2.99.0, < 4.0)
43+
httparty (0.21.0)
44+
mini_mime (>= 1.0.0)
45+
multi_xml (>= 0.5.2)
46+
jaro_winkler (1.5.4)
47+
json (2.6.3)
48+
kramdown (2.4.0)
49+
rexml
50+
kramdown-parser-gfm (1.1.0)
51+
kramdown (~> 2.0)
52+
language_server-protocol (3.17.0.2)
53+
listen (3.8.0)
54+
rb-fsevent (~> 0.10, >= 0.10.3)
55+
rb-inotify (~> 0.9, >= 0.9.10)
56+
lumberjack (1.2.8)
57+
method_source (1.0.0)
58+
mini_mime (1.1.2)
59+
multi_xml (0.6.0)
60+
nenv (0.3.0)
61+
nokogiri (1.14.0-x86_64-linux)
62+
racc (~> 1.4)
63+
notiffany (0.1.3)
64+
nenv (~> 0.1)
65+
shellany (~> 0.0)
66+
octokit (6.0.1)
67+
faraday (>= 1, < 3)
68+
sawyer (~> 0.9)
69+
parallel (1.22.1)
70+
parser (3.2.0.0)
71+
ast (~> 2.4.1)
72+
pronto (0.11.1)
73+
gitlab (>= 4.4.0, < 5.0)
74+
httparty (>= 0.13.7, < 1.0)
75+
octokit (>= 4.7.0, < 7.0)
76+
rainbow (>= 2.2, < 4.0)
77+
rexml (>= 3.2.5, < 4.0)
78+
rugged (>= 0.23.0, < 2.0)
79+
thor (>= 0.20.3, < 2.0)
80+
pronto-simplecov (0.11.0)
81+
pronto (~> 0.11.0)
82+
simplecov
83+
pronto-standardrb (0.1.2)
84+
pronto
85+
rubocop
86+
standard
87+
pry (0.14.2)
88+
coderay (~> 1.1)
89+
method_source (~> 1.0)
90+
public_suffix (5.0.1)
91+
racc (1.6.2)
92+
rack (2.2.6.2)
93+
rainbow (3.1.1)
94+
rb-fsevent (0.11.2)
95+
rb-inotify (0.10.1)
96+
ffi (~> 1.0)
97+
redis (4.8.0)
98+
regexp_parser (2.6.2)
99+
reverse_markdown (2.1.1)
100+
nokogiri
101+
rexml (3.2.5)
102+
rspec (3.12.0)
103+
rspec-core (~> 3.12.0)
104+
rspec-expectations (~> 3.12.0)
105+
rspec-mocks (~> 3.12.0)
106+
rspec-core (3.12.0)
107+
rspec-support (~> 3.12.0)
108+
rspec-expectations (3.12.2)
109+
diff-lcs (>= 1.2.0, < 2.0)
110+
rspec-support (~> 3.12.0)
111+
rspec-mocks (3.12.3)
112+
diff-lcs (>= 1.2.0, < 2.0)
113+
rspec-support (~> 3.12.0)
114+
rspec-support (3.12.0)
115+
rubocop (1.42.0)
116+
json (~> 2.3)
117+
parallel (~> 1.10)
118+
parser (>= 3.1.2.1)
119+
rainbow (>= 2.2.2, < 4.0)
120+
regexp_parser (>= 1.8, < 3.0)
121+
rexml (>= 3.2.5, < 4.0)
122+
rubocop-ast (>= 1.24.1, < 2.0)
123+
ruby-progressbar (~> 1.7)
124+
unicode-display_width (>= 1.4.0, < 3.0)
125+
rubocop-ast (1.24.1)
126+
parser (>= 3.1.1.0)
127+
rubocop-performance (1.15.2)
128+
rubocop (>= 1.7.0, < 2.0)
129+
rubocop-ast (>= 0.4.0)
130+
ruby-progressbar (1.11.0)
131+
ruby2_keywords (0.0.5)
132+
rugged (1.5.1)
133+
sawyer (0.9.2)
134+
addressable (>= 2.3.5)
135+
faraday (>= 0.17.3, < 3)
136+
shellany (0.0.1)
137+
sidekiq (6.5.8)
138+
connection_pool (>= 2.2.5, < 3)
139+
rack (~> 2.0)
140+
redis (>= 4.5.0, < 5)
141+
simplecov (0.22.0)
142+
docile (~> 1.1)
143+
simplecov-html (~> 0.11)
144+
simplecov_json_formatter (~> 0.1)
145+
simplecov-html (0.12.3)
146+
simplecov_json_formatter (0.1.4)
147+
solargraph (0.48.0)
148+
backport (~> 1.2)
149+
benchmark
150+
bundler (>= 1.17.2)
151+
diff-lcs (~> 1.4)
152+
e2mmap
153+
jaro_winkler (~> 1.5)
154+
kramdown (~> 2.3)
155+
kramdown-parser-gfm (~> 1.1)
156+
parser (~> 3.0)
157+
reverse_markdown (>= 1.0.5, < 3)
158+
rubocop (>= 0.52)
159+
thor (~> 1.0)
160+
tilt (~> 2.0)
161+
yard (~> 0.9, >= 0.9.24)
162+
solargraph-standardrb (0.0.4)
163+
solargraph (>= 0.39.1)
164+
standard (>= 0.4.1)
165+
standard (1.22.1)
166+
language_server-protocol (~> 3.17.0.2)
167+
rubocop (= 1.42.0)
168+
rubocop-performance (= 1.15.2)
169+
terminal-table (3.0.2)
170+
unicode-display_width (>= 1.1.1, < 3)
171+
thor (1.2.1)
172+
tilt (2.0.11)
173+
unicode-display_width (2.4.2)
174+
webrick (1.7.0)
175+
yard (0.9.28)
176+
webrick (~> 1.7.0)
177+
178+
PLATFORMS
179+
x86_64-linux
180+
181+
DEPENDENCIES
182+
guard (~> 2.18)
183+
guard-rspec (~> 4.7)
184+
pronto (~> 0.11)
185+
pronto-simplecov (~> 0.11)
186+
pronto-standardrb (~> 0.1)
187+
rspec (~> 3)
188+
sidekiq-queue-pause!
189+
simplecov (~> 0.21)
190+
solargraph (~> 0.44)
191+
solargraph-standardrb (~> 0.0.4)
192+
standard (~> 1.4)
193+
194+
BUNDLED WITH
195+
2.3.23

Guardfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# A sample Guardfile
2+
# More info at https://github.com/guard/guard#readme
3+
4+
## Uncomment and set this to only include directories you want to watch
5+
# directories %w(app lib config test spec features) \
6+
# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
7+
8+
## Note: if you are using the `directories` clause above and you are not
9+
## watching the project directory ('.'), then you will want to move
10+
## the Guardfile to a watched dir and symlink it back, e.g.
11+
#
12+
# $ mkdir config
13+
# $ mv Guardfile config/
14+
# $ ln -s config/Guardfile .
15+
#
16+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17+
18+
# Note: The cmd option is now required due to the increasing number of ways
19+
# rspec may be run, below are examples of the most common uses.
20+
# * bundler: 'bundle exec rspec'
21+
# * bundler binstubs: 'bin/rspec'
22+
# * spring: 'bin/rspec' (This will use spring if running and you have
23+
# installed the spring binstubs per the docs)
24+
# * zeus: 'zeus rspec' (requires the server to be started separately)
25+
# * 'just' rspec: 'rspec'
26+
27+
guard :rspec, cmd: "bundle exec rspec" do
28+
require "guard/rspec/dsl"
29+
dsl = Guard::RSpec::Dsl.new(self)
30+
31+
# Feel free to open issues for suggestions and improvements
32+
33+
# RSpec files
34+
rspec = dsl.rspec
35+
watch(rspec.spec_helper) { rspec.spec_dir }
36+
watch(rspec.spec_support) { rspec.spec_dir }
37+
watch(rspec.spec_files)
38+
39+
# Ruby files
40+
ruby = dsl.ruby
41+
dsl.watch_spec_files_for(ruby.lib_files)
42+
end

lib/sidekiq-queue-pause.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
1-
begin
2-
require 'celluloid'
3-
rescue LoadError
4-
# Sidekiq 4.2+
5-
end
6-
require 'sidekiq'
7-
require 'sidekiq/fetch'
1+
require "sidekiq"
2+
require "sidekiq/fetch"
83

94
module Sidekiq
105
module QueuePause
11-
PREFIX = 'queue_pause'
6+
PREFIX = "queue_pause"
127

138
class << self
149
attr_accessor :retry_after
15-
attr_writer :process_key
10+
attr_writer :process_key
1611

1712
def process_key(&block)
18-
if block_given?
13+
if block
1914
@process_key = block
2015
else
2116
@process_key.is_a?(Proc) ? @process_key.call : @process_key
@@ -62,11 +57,16 @@ def retrieve_work_for_queues(qcmd)
6257
UnitOfWork.new(*work) if work
6358
end
6459

60+
# Returns the list of unpause queue names.
61+
#
62+
# @return [Array<String>] The list of unpaused queue names.
6563
def unpaused_queues_cmd
6664
queues = queues_cmd
6765
queues.reject do |q|
68-
q != Sidekiq::BasicFetch::TIMEOUT &&
69-
Sidekiq::QueuePause.paused?(q.gsub('queue:', ''), Sidekiq::QueuePause.process_key)
66+
next if q.is_a?(Integer)
67+
next if q.is_a?(Hash)
68+
69+
Sidekiq::QueuePause.paused?(q.gsub("queue:", ""), Sidekiq::QueuePause.process_key)
7070
end
7171
end
7272
end

sidekiq-queue-pause.gemspec

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
Gem::Specification.new do |s|
2-
s.name = 'sidekiq-queue-pause'
3-
s.version = '0.1.0'
4-
s.summary = 'Pause a Sidekiq queue'
5-
s.description = 'Let\'s you pause/unpause individual sidekiq queues.'
6-
s.license = 'MIT'
7-
s.authors = ['Projective Technology GmbH']
8-
s.email = 'technology@projective.io'
9-
s.homepage = 'https://github.com/projectivetech/sidekiq-queue-pause'
2+
s.name = "sidekiq-queue-pause"
3+
s.version = "0.1.0"
4+
s.summary = "Pause a Sidekiq queue"
5+
s.description = "Let's you pause/unpause individual sidekiq queues."
6+
s.license = "MIT"
7+
s.authors = ["Projective Technology GmbH"]
8+
s.email = "technology@projective.io"
9+
s.homepage = "https://github.com/projectivetech/sidekiq-queue-pause"
1010

11-
s.require_paths = ['lib']
12-
s.files = Dir['lib/**/*rb']
11+
s.require_paths = ["lib"]
12+
s.files = Dir["lib/**/*rb"]
1313

14-
s.add_dependency 'sidekiq', '>= 6.0', '< 7.0'
14+
s.add_dependency "sidekiq", ">= 6.0", "< 7.0"
15+
16+
s.add_development_dependency "rspec", "~> 3"
17+
s.add_development_dependency "simplecov", "~> 0.21"
18+
s.add_development_dependency "solargraph", "~> 0.44"
19+
s.add_development_dependency "solargraph-standardrb", "~> 0.0.4"
20+
s.add_development_dependency "standard", "~> 1.4"
21+
s.add_development_dependency "guard", "~> 2.18"
22+
s.add_development_dependency "guard-rspec", "~> 4.7"
23+
s.add_development_dependency "pronto", "~> 0.11"
24+
s.add_development_dependency "pronto-standardrb", "~> 0.1"
25+
s.add_development_dependency "pronto-simplecov", "~> 0.11"
1526
end

spec/sidekiq-queue-pause_spec.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
require "spec_helper"
2+
3+
describe Sidekiq::QueuePause do
4+
describe Sidekiq::QueuePause::PausingFetch do
5+
describe "#unpause_queues_cmd" do
6+
let(:queuename) { "some_queue" }
7+
let(:config) { {queues: [queuename], strict: true} }
8+
let(:pausing_fetch) { described_class.new(config) }
9+
10+
context "with Sidekiq > 6.5.6 the queues list can contain Hashes" do
11+
let(:queue_list) { ["queue:#{queuename}", {timeout: 2}] }
12+
13+
before { allow(pausing_fetch).to receive(:queues_cmd).and_return(queue_list) }
14+
15+
it "does not checked whether the Hash is paused" do
16+
expect(Sidekiq::QueuePause).to receive(:paused?).with(queuename, Sidekiq::QueuePause.process_key).and_return(false)
17+
18+
expect(pausing_fetch.unpaused_queues_cmd).to match_array(queue_list)
19+
end
20+
end
21+
22+
context "with Sidekiq < 6.5.6 the queues list can contain an Integer" do
23+
let(:queue_list) { ["queue:#{queuename}", 2] }
24+
25+
before { allow(pausing_fetch).to receive(:queues_cmd).and_return(queue_list) }
26+
27+
it "does not check whether the Integer is paused" do
28+
expect(Sidekiq::QueuePause).to receive(:paused?).with(queuename, Sidekiq::QueuePause.process_key).and_return(false)
29+
30+
expect(pausing_fetch.unpaused_queues_cmd).to match_array(queue_list)
31+
end
32+
end
33+
end
34+
end
35+
end

0 commit comments

Comments
 (0)