sidekiq-apriori 0.0.3 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -3
- data/Gemfile +1 -1
- data/gemfiles/ruby_19.gemfile +5 -0
- data/gemfiles/ruby_2.gemfile +5 -0
- data/lib/sidekiq-apriori/middleware/prioritizer.rb +1 -1
- data/lib/sidekiq-apriori/version.rb +1 -1
- data/sidekiq-apriori.gemspec +1 -1
- data/spec/sidekiq-apriori/arb_spec.rb +4 -4
- data/spec/sidekiq-apriori/middleware/client_spec.rb +7 -6
- data/spec/sidekiq-apriori/middleware/prioritizer_spec.rb +16 -6
- data/spec/sidekiq-apriori/middleware/server_spec.rb +7 -6
- data/spec/sidekiq-apriori/worker_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +33 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8520828e777c87ddf510b8c80f6f5eaab0dcb80a
|
4
|
+
data.tar.gz: 66cd361fcb7de9e529b06db5b077eb4f26604a3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ddf4dd4d818c4197adc3f94f7e4983d449b16bf67b2bbcc8dac35cd6bc5276e72cc197a07153e7a29de92ca74fbbfad48da52b77ffa709ecdcac13781df2f7f
|
7
|
+
data.tar.gz: 95681152f904ea6a1711d7cbf8a1df9db5f3377a12bdd119aabd9bae964ba76698b4298fe03d84881fd496f68c4ec52b3684180df4532346ca6bf8ae589f98eb
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
source "
|
1
|
+
source "https://rubygems.org"
|
2
2
|
gemspec
|
@@ -2,7 +2,7 @@ require 'sidekiq-apriori/priorities'
|
|
2
2
|
|
3
3
|
module Sidekiq::Apriori
|
4
4
|
class Prioritizer
|
5
|
-
def call(worker, msg, queue)
|
5
|
+
def call(worker, msg, queue, redis_pool = nil)
|
6
6
|
options = msg["args"].last if msg["args"].respond_to?(:last)
|
7
7
|
priority = options[:priority] if options.is_a?(Hash) && options.has_key?(:priority)
|
8
8
|
|
data/sidekiq-apriori.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_development_dependency "fakeredis"
|
25
25
|
s.add_development_dependency "pry"
|
26
26
|
s.add_development_dependency "rake"
|
27
|
-
s.add_development_dependency "rspec"
|
27
|
+
s.add_development_dependency "rspec", "~>3.0"
|
28
28
|
s.add_development_dependency "simplecov"
|
29
29
|
s.add_development_dependency "simplecov-rcov"
|
30
30
|
s.add_development_dependency "sqlite3"
|
@@ -12,21 +12,21 @@ describe Sidekiq::Apriori::Arb do
|
|
12
12
|
|
13
13
|
it "should validate priorities" do
|
14
14
|
arb.priority = "none"
|
15
|
-
arb.
|
15
|
+
expect(arb).to be_invalid
|
16
16
|
|
17
17
|
Sidekiq::Apriori::PRIORITIES.each do |priority|
|
18
18
|
arb.priority = priority
|
19
|
-
arb.
|
19
|
+
expect(arb).to be_valid
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should attempt prioritization on creation with named prioritizer" do
|
24
|
-
using_method.
|
24
|
+
expect(using_method).to receive(:some_method)
|
25
25
|
using_method.save
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should attempt prioritization on creation with using a block" do
|
29
|
-
using_callable.
|
29
|
+
expect(using_callable).to receive(:some_other_method)
|
30
30
|
using_callable.save
|
31
31
|
end
|
32
32
|
end
|
@@ -3,7 +3,7 @@ require 'sidekiq-apriori/middleware/prioritizer'
|
|
3
3
|
|
4
4
|
describe Sidekiq::Apriori, 'client middleware' do
|
5
5
|
before do
|
6
|
-
Sidekiq.
|
6
|
+
allow(Sidekiq).to receive(:server?).and_return(false)
|
7
7
|
|
8
8
|
Sidekiq.configure_client do |config|
|
9
9
|
config.client_middleware do |chain|
|
@@ -14,12 +14,13 @@ describe Sidekiq::Apriori, 'client middleware' do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should include Sidekiq::Apriori::Prioritizer in client middleware" do
|
17
|
-
Sidekiq.client_middleware.entries.
|
17
|
+
expect(Sidekiq.client_middleware.entries).to be_empty
|
18
18
|
|
19
|
-
(require 'sidekiq-apriori/middleware/client').
|
19
|
+
expect(require 'sidekiq-apriori/middleware/client').to eq(true)
|
20
20
|
|
21
|
-
Sidekiq.client_middleware.entries.
|
22
|
-
Sidekiq.client_middleware.entries.map(&:klass).
|
23
|
-
|
21
|
+
expect(Sidekiq.client_middleware.entries).not_to be_empty
|
22
|
+
expect(Sidekiq.client_middleware.entries.map(&:klass)).to(
|
23
|
+
include(Sidekiq::Apriori::Prioritizer)
|
24
|
+
)
|
24
25
|
end
|
25
26
|
end
|
@@ -9,26 +9,36 @@ describe Sidekiq::Apriori::Prioritizer do
|
|
9
9
|
|
10
10
|
describe '#call' do
|
11
11
|
it 'should respond' do
|
12
|
-
middleware.respond_to
|
12
|
+
expect(middleware).to respond_to(:call)
|
13
13
|
end
|
14
14
|
|
15
|
-
it '
|
15
|
+
it 'rejects less than three arguments' do
|
16
16
|
expect { middleware.call }.
|
17
|
-
to raise_error( ArgumentError,
|
17
|
+
to raise_error( ArgumentError, /wrong number of arguments/ )
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'allows 3 arguments' do
|
21
|
+
expect { middleware.call(nil, message, queue) {} }.
|
22
|
+
not_to raise_error
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'allows for 4 arguments' do
|
26
|
+
expect { middleware.call(nil, message, queue, nil) {} }.
|
27
|
+
not_to raise_error
|
18
28
|
end
|
19
29
|
|
20
30
|
it 'should set priority queue' do
|
21
31
|
middleware.call(nil, message, queue) {}
|
22
|
-
message['queue'].
|
32
|
+
expect(message['queue']).to eq('foo_high')
|
23
33
|
end
|
24
34
|
|
25
35
|
it 'should allow only one priority suffix' do
|
26
36
|
message['queue'] = 'foo_low_high_immediate'
|
27
37
|
middleware.call(nil, message, queue) {}
|
28
|
-
message['queue'].
|
38
|
+
expect(message['queue']).to eq('foo_high')
|
29
39
|
|
30
40
|
middleware.call(nil, message, queue) {}
|
31
|
-
message['queue'].
|
41
|
+
expect(message['queue']).to eq('foo_high')
|
32
42
|
end
|
33
43
|
end
|
34
44
|
end
|
@@ -3,7 +3,7 @@ require 'sidekiq-apriori/middleware/prioritizer'
|
|
3
3
|
|
4
4
|
describe Sidekiq::Apriori, 'server middleware' do
|
5
5
|
before do
|
6
|
-
Sidekiq.
|
6
|
+
allow(Sidekiq).to receive(:server?).and_return(true)
|
7
7
|
|
8
8
|
Sidekiq.configure_server do |config|
|
9
9
|
config.client_middleware do |chain|
|
@@ -14,12 +14,13 @@ describe Sidekiq::Apriori, 'server middleware' do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should include Sidekiq::Apriori::Prioritizer in client middleware" do
|
17
|
-
Sidekiq.client_middleware.entries.
|
17
|
+
expect(Sidekiq.client_middleware.entries).to be_empty
|
18
18
|
|
19
|
-
(require 'sidekiq-apriori/middleware/server').
|
19
|
+
expect(require 'sidekiq-apriori/middleware/server').to eq(true)
|
20
20
|
|
21
|
-
Sidekiq.client_middleware.entries.
|
22
|
-
Sidekiq.client_middleware.entries.map(&:klass).
|
23
|
-
|
21
|
+
expect(Sidekiq.client_middleware.entries).not_to be_empty
|
22
|
+
expect(Sidekiq.client_middleware.entries.map(&:klass)).to(
|
23
|
+
include(Sidekiq::Apriori::Prioritizer)
|
24
|
+
)
|
24
25
|
end
|
25
26
|
end
|
@@ -15,7 +15,7 @@ describe Sidekiq::Apriori::Worker do
|
|
15
15
|
#
|
16
16
|
if ( RUBY_VERSION.split(/\./).map(&:to_i) rescue [] ).first > 1
|
17
17
|
it "redefines 'perform' to handle an extra argument when that argument has priority information" do
|
18
|
-
job.
|
18
|
+
expect(job).to be_an_instance_of(Job)
|
19
19
|
expect { job.perform(priority: "high") }.not_to raise_error
|
20
20
|
end
|
21
21
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-apriori
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Thomas
|
@@ -9,132 +9,132 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-05-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: fakeredis
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: pry
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rake
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: rspec
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '0'
|
76
|
+
version: '3.0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- -
|
81
|
+
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '0'
|
83
|
+
version: '3.0'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: simplecov
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- -
|
95
|
+
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: simplecov-rcov
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- -
|
102
|
+
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
type: :development
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- -
|
109
|
+
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: sqlite3
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- -
|
116
|
+
- - ">="
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: '0'
|
119
119
|
type: :development
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- -
|
123
|
+
- - ">="
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: sidekiq
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
|
-
- -
|
130
|
+
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
version: '0'
|
133
133
|
type: :runtime
|
134
134
|
prerelease: false
|
135
135
|
version_requirements: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
|
-
- -
|
137
|
+
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: '0'
|
140
140
|
description: Prioritization middleware for Sidekiq
|
@@ -144,15 +144,17 @@ executables: []
|
|
144
144
|
extensions: []
|
145
145
|
extra_rdoc_files: []
|
146
146
|
files:
|
147
|
-
- .gitignore
|
148
|
-
- .rspec
|
149
|
-
- .ruby-version
|
150
|
-
- .simplecov
|
151
|
-
- .travis.yml
|
147
|
+
- ".gitignore"
|
148
|
+
- ".rspec"
|
149
|
+
- ".ruby-version"
|
150
|
+
- ".simplecov"
|
151
|
+
- ".travis.yml"
|
152
152
|
- Gemfile
|
153
153
|
- LICENSE
|
154
154
|
- README.md
|
155
155
|
- Rakefile
|
156
|
+
- gemfiles/ruby_19.gemfile
|
157
|
+
- gemfiles/ruby_2.gemfile
|
156
158
|
- lib/sidekiq-apriori.rb
|
157
159
|
- lib/sidekiq-apriori/arb.rb
|
158
160
|
- lib/sidekiq-apriori/middleware.rb
|
@@ -180,17 +182,17 @@ require_paths:
|
|
180
182
|
- lib
|
181
183
|
required_ruby_version: !ruby/object:Gem::Requirement
|
182
184
|
requirements:
|
183
|
-
- -
|
185
|
+
- - ">="
|
184
186
|
- !ruby/object:Gem::Version
|
185
187
|
version: '0'
|
186
188
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
189
|
requirements:
|
188
|
-
- -
|
190
|
+
- - ">="
|
189
191
|
- !ruby/object:Gem::Version
|
190
192
|
version: '0'
|
191
193
|
requirements: []
|
192
194
|
rubyforge_project: nowarning
|
193
|
-
rubygems_version: 2.0.
|
195
|
+
rubygems_version: 2.0.14
|
194
196
|
signing_key:
|
195
197
|
specification_version: 4
|
196
198
|
summary: Prioritization Middleware for Sidekiq
|
@@ -202,3 +204,4 @@ test_files:
|
|
202
204
|
- spec/sidekiq-apriori/worker_spec.rb
|
203
205
|
- spec/spec_helper.rb
|
204
206
|
- spec/support/arb.rb
|
207
|
+
has_rdoc:
|