sidekiq-merger 0.0.5 → 0.0.6

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: 2333d3953e27f0ba0d3f0efc23a8bc48747b2a6d
4
- data.tar.gz: ed6230c813938f38f4092ee9a27589a774c55029
3
+ metadata.gz: fe6c788a720ff09719c0c646767a82102ee0c858
4
+ data.tar.gz: f7e3afc43bd8a75e0dfebbbf31425b97949328aa
5
5
  SHA512:
6
- metadata.gz: 271adc650104013b83c9fa5b99672c995c10b7e2d3518485daa9b5f2d62a9fc14333cd29014d8024f0e17a7b6bcfea393010d544f1ca899bab876a9a14647f7d
7
- data.tar.gz: 1e647aa5449188f1649bd57a84fb34629f348996991e28085aa19a83139cd31eaa2ec089aebb82f6e6cfcd4ec57ffc0738eb52118a07498d72c851d8aeefb9a0
6
+ metadata.gz: b45ec5e708f89daf1dbebbfd1c9b32648e2478d89cc38c68f4ffa53fd8d46c050b3aa9c84451488af955615dd213aefb5542a677de752f535e32d2c2482627e7
7
+ data.tar.gz: a13ed626974a75bfbb12d1763b3cf944f0fd353f3de17b63e0a2e2416ec76b1912fd687259a9d8da77bc688143b45738f44221238d18fb7a9edc860f4971aa61
data/README.md CHANGED
@@ -18,11 +18,11 @@ gem 'sidekiq-merger'
18
18
 
19
19
  And then execute:
20
20
 
21
- $ bundle
21
+ $ bundle
22
22
 
23
23
  Or install it yourself as:
24
24
 
25
- $ gem install sidekiq-merger
25
+ $ gem install sidekiq-merger
26
26
 
27
27
  ## Usage
28
28
 
@@ -65,6 +65,14 @@ SomeWorker.perform_async 5
65
65
 
66
66
  In this case, `SomeWorker` will be executed 3 times with args of `[4]`, `[3]` and `[5]`.
67
67
 
68
+ ### Quick Check
69
+
70
+ Run docker containers to check the behavior of this gem.
71
+
72
+ $ docker-compose up
73
+
74
+ Then, open `http://localhost:3000/`. You can push jobs from the UI and see what happens in the sidekiq console.
75
+
68
76
  ## Options
69
77
 
70
78
  ### `key` (optional, default: `nil`)
@@ -72,6 +80,7 @@ In this case, `SomeWorker` will be executed 3 times with args of `[4]`, `[3]` an
72
80
  Defines merge key so different arguments can be merged.
73
81
 
74
82
  Format: `String` or `Proc`
83
+
75
84
  e.g. `sidekiq_options merger: { key: -> (args) { args[0..1] } }`
76
85
 
77
86
  ### `unique` (optional, default: `false`)
@@ -79,6 +88,7 @@ e.g. `sidekiq_options merger: { key: -> (args) { args[0..1] } }`
79
88
  Prevents enqueue of jobs with identical arguments.
80
89
 
81
90
  Format: `Boolean`
91
+
82
92
  e.g. `true`
83
93
 
84
94
  ## Web UI
@@ -93,19 +103,13 @@ require "sidekiq/merger/web"
93
103
 
94
104
  ## Test
95
105
 
96
- $ bundle exec rspec
106
+ $ bundle exec rspec
97
107
 
98
108
  The test coverage is available at `./coverage/index.html`.
99
109
 
100
- To check the behavior of this plugin, you can run docker containers.
101
-
102
- $ docker-compose up
103
-
104
- Then, open `http://localhost:3000/`.
105
-
106
110
  ## Lint
107
111
 
108
- $ bundle exec rubocop
112
+ $ bundle exec rubocop
109
113
 
110
114
  ## Contributing
111
115
 
@@ -7,6 +7,8 @@ require_relative "merger/flusher"
7
7
  require_relative "merger/logging_observer"
8
8
 
9
9
  module Sidekiq::Merger
10
+ LOGGER_TAG = self.name.freeze
11
+
10
12
  class << self
11
13
  attr_accessor :logger
12
14
 
@@ -19,7 +21,7 @@ module Sidekiq::Merger
19
21
  ) { flusher.flush }
20
22
  task.add_observer(observer)
21
23
  logger.info(
22
- "[Sidekiq::Merger] Started polling merges every #{interval} seconds"
24
+ "[#{Sidekiq::Merger::LOGGER_TAG}] Started polling merges every #{interval} seconds"
23
25
  )
24
26
  task.execute
25
27
  end
@@ -6,11 +6,11 @@ class Sidekiq::Merger::LoggingObserver
6
6
  def update(time, _result, ex)
7
7
  if ex.is_a?(Concurrent::TimeoutError)
8
8
  @logger.error(
9
- "[Sidekiq::Grouping] (#{time}) Execution timed out\n"
9
+ "[#{Sidekiq::Merger::LOGGER_TAG}] Execution timed out\n"
10
10
  )
11
11
  elsif ex.present?
12
12
  @logger.error(
13
- "[Sidekiq::Grouping] Execution failed with error #{ex}\n"
13
+ "[#{Sidekiq::Merger::LOGGER_TAG}] Execution failed with error #{ex}\n"
14
14
  )
15
15
  end
16
16
  end
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Merger
3
- VERSION = "0.0.5".freeze
3
+ VERSION = "0.0.6".freeze
4
4
  end
5
5
  end
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+
3
+ describe Sidekiq::Merger::LoggingObserver do
4
+ subject { described_class.new(logger) }
5
+ let(:logger) { Logger.new("/dev/null") }
6
+ let(:now) { Time.now }
7
+ before { Timecop.freeze(now) }
8
+
9
+ describe "#update" do
10
+ it "logs a timeout" do
11
+ expect(logger).to receive(:error).with("[Sidekiq::Merger] Execution timed out\n")
12
+ subject.update(now, nil, Concurrent::TimeoutError.new)
13
+ end
14
+ it "logs an error" do
15
+ expect(logger).to receive(:error).with("[Sidekiq::Merger] Execution failed with error foo\n")
16
+ subject.update(now, nil, "foo")
17
+ end
18
+ end
19
+ 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.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - dtaniwaki
@@ -201,6 +201,7 @@ files:
201
201
  - misc/web_ui.png
202
202
  - sidekiq-merger.gemspec
203
203
  - spec/sidekiq/merger/flusher_spec.rb
204
+ - spec/sidekiq/merger/logging_observer_spec.rb
204
205
  - spec/sidekiq/merger/merge_spec.rb
205
206
  - spec/sidekiq/merger/middleware_spec.rb
206
207
  - spec/sidekiq/merger/redis_spec.rb
@@ -236,6 +237,7 @@ specification_version: 4
236
237
  summary: Sidekiq merger plugin
237
238
  test_files:
238
239
  - spec/sidekiq/merger/flusher_spec.rb
240
+ - spec/sidekiq/merger/logging_observer_spec.rb
239
241
  - spec/sidekiq/merger/merge_spec.rb
240
242
  - spec/sidekiq/merger/middleware_spec.rb
241
243
  - spec/sidekiq/merger/redis_spec.rb