sidekiq-merger 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +2 -1
- data/.gitignore +2 -1
- data/Rakefile +3 -1
- data/app/Gemfile.lock +54 -0
- data/app/sidekiq.rb +2 -2
- data/app/{some_worker.rb → workers/some_worker.rb} +0 -0
- data/app/{unique_worker.rb → workers/unique_worker.rb} +0 -0
- data/lib/sidekiq/merger/middleware.rb +3 -1
- data/lib/sidekiq/merger/version.rb +1 -1
- data/spec/sidekiq/merger/middleware_spec.rb +10 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 764a83e3da41cbfaa54d2d8a0abbdcddcb42c289
|
4
|
+
data.tar.gz: 40793d538fcd693873fb53aa657cbbbb82ad20a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e43782390e487179771cce40af1edefb40f493236629147fcdc44a595ae35d739a35d5c2aa2eca007975a19e69df9f0e56344f21f8a426cedccd617fbb029ad0
|
7
|
+
data.tar.gz: 9e34d46fea2b98e272f29d68f0e554d9f9c93299156fc7d986a9e29f54a7464949a270e8ae8613319e0c9a5ef6cd7708f9e7a15154913c460baa8b53bf6641a1
|
data/.dockerignore
CHANGED
data/.gitignore
CHANGED
data/Rakefile
CHANGED
data/app/Gemfile.lock
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
sidekiq-merger (0.0.6)
|
5
|
+
activesupport (>= 3.2, < 6)
|
6
|
+
concurrent-ruby (~> 1.0)
|
7
|
+
sidekiq (>= 3.4, < 5)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activesupport (5.0.1)
|
13
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
+
i18n (~> 0.7)
|
15
|
+
minitest (~> 5.1)
|
16
|
+
tzinfo (~> 1.1)
|
17
|
+
concurrent-ruby (1.0.4)
|
18
|
+
connection_pool (2.2.1)
|
19
|
+
i18n (0.7.0)
|
20
|
+
minitest (5.10.1)
|
21
|
+
rack (1.6.5)
|
22
|
+
rack-flash3 (1.0.5)
|
23
|
+
rack
|
24
|
+
rack-protection (1.5.3)
|
25
|
+
rack
|
26
|
+
redis (3.3.3)
|
27
|
+
sidekiq (4.2.9)
|
28
|
+
concurrent-ruby (~> 1.0)
|
29
|
+
connection_pool (~> 2.2, >= 2.2.0)
|
30
|
+
rack-protection (>= 1.5.0)
|
31
|
+
redis (~> 3.2, >= 3.2.1)
|
32
|
+
sidekiq-status (0.6.0)
|
33
|
+
sidekiq (>= 2.7)
|
34
|
+
sinatra (1.4.8)
|
35
|
+
rack (~> 1.5)
|
36
|
+
rack-protection (~> 1.4)
|
37
|
+
tilt (>= 1.3, < 3)
|
38
|
+
thread_safe (0.3.5)
|
39
|
+
tilt (2.0.6)
|
40
|
+
tzinfo (1.2.2)
|
41
|
+
thread_safe (~> 0.1)
|
42
|
+
|
43
|
+
PLATFORMS
|
44
|
+
ruby
|
45
|
+
|
46
|
+
DEPENDENCIES
|
47
|
+
rack-flash3
|
48
|
+
sidekiq
|
49
|
+
sidekiq-merger!
|
50
|
+
sidekiq-status
|
51
|
+
sinatra
|
52
|
+
|
53
|
+
BUNDLED WITH
|
54
|
+
1.13.6
|
data/app/sidekiq.rb
CHANGED
@@ -2,8 +2,8 @@ require "active_support/core_ext/numeric/time"
|
|
2
2
|
require "sidekiq"
|
3
3
|
require "sidekiq-status"
|
4
4
|
require "sidekiq-merger"
|
5
|
-
require_relative "
|
6
|
-
require_relative "
|
5
|
+
require_relative "workers/some_worker"
|
6
|
+
require_relative "workers/unique_worker"
|
7
7
|
|
8
8
|
expiration = 30.minutes
|
9
9
|
|
File without changes
|
File without changes
|
@@ -7,7 +7,9 @@ class Sidekiq::Merger::Middleware
|
|
7
7
|
worker_class = worker_class.camelize.constantize if worker_class.is_a?(String)
|
8
8
|
options = worker_class.get_sidekiq_options
|
9
9
|
|
10
|
-
|
10
|
+
merger_enabled = options.key?("merger")
|
11
|
+
|
12
|
+
if merger_enabled && !msg["at"].nil? && msg["at"].to_f > Time.now.to_f
|
11
13
|
Sidekiq::Merger::Merge
|
12
14
|
.initialize_with_args(worker_class, queue, msg["args"])
|
13
15
|
.add(msg["args"], msg["at"])
|
@@ -23,12 +23,13 @@ describe Sidekiq::Merger::Middleware do
|
|
23
23
|
end
|
24
24
|
before :example do
|
25
25
|
allow(Object).to receive(:const_get).with("Name").and_return worker_class
|
26
|
+
Timecop.freeze(now)
|
26
27
|
end
|
27
28
|
|
28
29
|
describe "#call" do
|
29
30
|
it "adds the args to the merge" do
|
30
|
-
subject.call(worker_class, { "args" => [1, 2, 3], "at" => now + 10.seconds }, queue) {}
|
31
|
-
subject.call(worker_class, { "args" => [2, 3, 4], "at" => now + 15.seconds }, queue) {}
|
31
|
+
subject.call(worker_class, { "args" => [1, 2, 3], "at" => (now + 10.seconds).to_f }, queue) {}
|
32
|
+
subject.call(worker_class, { "args" => [2, 3, 4], "at" => (now + 15.seconds).to_f }, queue) {}
|
32
33
|
flusher.flush
|
33
34
|
expect(worker_class.jobs.size).to eq 0
|
34
35
|
Timecop.travel(10.seconds)
|
@@ -52,5 +53,12 @@ describe Sidekiq::Merger::Middleware do
|
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
56
|
+
context "at is before current time" do
|
57
|
+
it "peforms now" do
|
58
|
+
expect { |b| subject.call(worker_class, { "args" => [1, 2, 3], "at" => now.to_f }, queue, &b) }.to yield_with_args(worker_class, { "args" => [[1, 2, 3]], "at" => now.to_f }, queue, anything)
|
59
|
+
flusher.flush
|
60
|
+
expect(worker_class.jobs.size).to eq 0
|
61
|
+
end
|
62
|
+
end
|
55
63
|
end
|
56
64
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-merger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dtaniwaki
|
@@ -179,12 +179,13 @@ files:
|
|
179
179
|
- README.md
|
180
180
|
- Rakefile
|
181
181
|
- app/Gemfile
|
182
|
+
- app/Gemfile.lock
|
182
183
|
- app/app.rb
|
183
184
|
- app/config.ru
|
184
185
|
- app/sidekiq.rb
|
185
|
-
- app/some_worker.rb
|
186
|
-
- app/unique_worker.rb
|
187
186
|
- app/views/index.erb
|
187
|
+
- app/workers/some_worker.rb
|
188
|
+
- app/workers/unique_worker.rb
|
188
189
|
- docker-compose-common.yml
|
189
190
|
- docker-compose.yml
|
190
191
|
- lib/sidekiq-merger.rb
|