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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe6c788a720ff09719c0c646767a82102ee0c858
4
- data.tar.gz: f7e3afc43bd8a75e0dfebbbf31425b97949328aa
3
+ metadata.gz: 764a83e3da41cbfaa54d2d8a0abbdcddcb42c289
4
+ data.tar.gz: 40793d538fcd693873fb53aa657cbbbb82ad20a8
5
5
  SHA512:
6
- metadata.gz: b45ec5e708f89daf1dbebbfd1c9b32648e2478d89cc38c68f4ffa53fd8d46c050b3aa9c84451488af955615dd213aefb5542a677de752f535e32d2c2482627e7
7
- data.tar.gz: a13ed626974a75bfbb12d1763b3cf944f0fd353f3de17b63e0a2e2416ec76b1912fd687259a9d8da77bc688143b45738f44221238d18fb7a9edc860f4971aa61
6
+ metadata.gz: e43782390e487179771cce40af1edefb40f493236629147fcdc44a595ae35d739a35d5c2aa2eca007975a19e69df9f0e56344f21f8a426cedccd617fbb029ad0
7
+ data.tar.gz: 9e34d46fea2b98e272f29d68f0e554d9f9c93299156fc7d986a9e29f54a7464949a270e8ae8613319e0c9a5ef6cd7708f9e7a15154913c460baa8b53bf6641a1
data/.dockerignore CHANGED
@@ -1,6 +1,5 @@
1
1
  .bundle/
2
2
  .yardoc
3
- Gemfile.lock
4
3
  _yardoc/
5
4
  coverage/
6
5
  doc/
@@ -9,6 +8,8 @@ spec/reports/
9
8
  tmp/
10
9
  rdoc/
11
10
 
11
+ /Gemfile.lock
12
+
12
13
  *.gem
13
14
  *.rbc
14
15
 
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  .bundle/
2
2
  .yardoc
3
- Gemfile.lock
4
3
  _yardoc/
5
4
  coverage/
6
5
  doc/
@@ -9,6 +8,8 @@ spec/reports/
9
8
  tmp/
10
9
  rdoc/
11
10
 
11
+ /Gemfile.lock
12
+
12
13
  *.gem
13
14
  *.rbc
14
15
 
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
+ require "rubocop/rake_task"
3
4
 
4
5
  RSpec::Core::RakeTask.new(:spec)
6
+ RuboCop::RakeTask.new(:rubocop)
5
7
 
6
- task default: :spec
8
+ task default: [:rubocop, :spec]
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 "./some_worker"
6
- require_relative "./unique_worker"
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
- if !msg["at"].nil? && options.key?("merger")
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"])
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Merger
3
- VERSION = "0.0.6".freeze
3
+ VERSION = "0.0.7".freeze
4
4
  end
5
5
  end
@@ -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.6
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