chewy_kiqqer 0.2.2 → 0.2.3

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: 69fa520fad10a08f620c667e91f1b133ac7e8adf
4
- data.tar.gz: 6d8ab912f3eb918570395081cc4e89720e286b7e
3
+ metadata.gz: b91b694c61a6898e20ac484811ce3ca4634028e0
4
+ data.tar.gz: a5aa154c0a8f35df90c25d138e4db11d0951aa0d
5
5
  SHA512:
6
- metadata.gz: 7459fef7cf824e5d833636876c4e09c6ad3c44ebb26e2c99e9bf7e96e775eff5845076f2ba55d4574cd75cb6b235190504e93b6547612fa204c1bc6bebbf56f1
7
- data.tar.gz: fdf22831d0609f93fa8fc23b1d69ded783baf684af20507b708867784ae9003800db5352bc58a77e08cf7a1254a9dcc3ee17474cd914b8cc1c2b78cc1bcef0ae
6
+ metadata.gz: 96a02ad4c2ecd1ef0867396b66ca485c2e73fc0606b559b0b977861cbef20bdf66ca372840f50846a0431ebba2afd9b942df501a0dad6f8e6635bd54a189b3bf
7
+ data.tar.gz: 433ae9028d1f6721d75192450b7e7ab713a08b80948e8af1b2d20c1351f5915a4e34be3dfbf9fdc96fc1f3b7ec91c5384faf3f84daa92503222695866c236f3c
data/lib/chewy_kiqqer.rb CHANGED
@@ -5,7 +5,7 @@ require "chewy_kiqqer/version"
5
5
  require "chewy_kiqqer/mixin"
6
6
  require "chewy_kiqqer/worker"
7
7
  require "chewy_kiqqer/index"
8
- require "chewy_kiqqer/logger"
8
+ require "chewy_kiqqer/config"
9
9
  require "chewy_kiqqer/log_subscriber"
10
10
 
11
11
 
@@ -0,0 +1,23 @@
1
+ require 'logger'
2
+
3
+ module ChewyKiqqer
4
+
5
+ def self.logger
6
+ @logger
7
+ end
8
+
9
+ def self.logger=(value)
10
+ @logger = value
11
+ end
12
+
13
+ # Locking scope for redis locks. Only necessary if
14
+ # one redis instances locks more than one application
15
+ def self.locking_scope=(value)
16
+ @locking_scope = value
17
+ end
18
+
19
+ def self.locking_scope
20
+ @locking_scope || 'default'
21
+ end
22
+
23
+ end
@@ -1,3 +1,3 @@
1
1
  module ChewyKiqqer
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -17,7 +17,7 @@ module ChewyKiqqer
17
17
 
18
18
  def with_lock(index_name, ids)
19
19
  Sidekiq.redis do |redis|
20
- lock_name = "#{index_name}-#{ids.join('-')}"
20
+ lock_name = "chewy-kiqqer:#{ChewyKiqqer.locking_scope}:#{index_name}-#{ids.join('-')}"
21
21
  redis.lock(lock_name, life: 60, acquire: 5) { index(index_name, ids) }
22
22
  end
23
23
  end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'config' do
4
+ context '#logger' do
5
+
6
+ after(:each) { ChewyKiqqer.logger = nil }
7
+
8
+ it 'can be set from the outside' do
9
+ ChewyKiqqer.logger = :nolog
10
+ expect(ChewyKiqqer.logger).to eq(:nolog)
11
+ end
12
+
13
+ end
14
+
15
+ context '#locking_scope' do
16
+
17
+ after(:each) { ChewyKiqqer.locking_scope = nil }
18
+
19
+ it 'can be set from the outside' do
20
+ ChewyKiqqer.locking_scope = '42'
21
+ expect(ChewyKiqqer.locking_scope).to eq('42')
22
+ end
23
+
24
+ it 'has a default' do
25
+ expect(ChewyKiqqer.locking_scope).to eq('default')
26
+ end
27
+
28
+ end
29
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chewy_kiqqer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Hahn
@@ -151,15 +151,15 @@ files:
151
151
  - Rakefile
152
152
  - chewy_kiqqer.gemspec
153
153
  - lib/chewy_kiqqer.rb
154
+ - lib/chewy_kiqqer/config.rb
154
155
  - lib/chewy_kiqqer/index.rb
155
156
  - lib/chewy_kiqqer/log_subscriber.rb
156
- - lib/chewy_kiqqer/logger.rb
157
157
  - lib/chewy_kiqqer/mixin.rb
158
158
  - lib/chewy_kiqqer/version.rb
159
159
  - lib/chewy_kiqqer/worker.rb
160
+ - spec/config_spec.rb
160
161
  - spec/index_spec.rb
161
162
  - spec/log_subscriber_spec.rb
162
- - spec/logger_spec.rb
163
163
  - spec/mixin_spec.rb
164
164
  - spec/spec_helper.rb
165
165
  - spec/worker_spec.rb
@@ -189,9 +189,9 @@ specification_version: 4
189
189
  summary: Small helper gem that allows you to automatically run all chewy index updates
190
190
  in sidekiq
191
191
  test_files:
192
+ - spec/config_spec.rb
192
193
  - spec/index_spec.rb
193
194
  - spec/log_subscriber_spec.rb
194
- - spec/logger_spec.rb
195
195
  - spec/mixin_spec.rb
196
196
  - spec/spec_helper.rb
197
197
  - spec/worker_spec.rb
@@ -1,13 +0,0 @@
1
- require 'logger'
2
-
3
- module ChewyKiqqer
4
-
5
- def self.logger
6
- @logger
7
- end
8
-
9
- def self.logger=(value)
10
- @logger = value
11
- end
12
-
13
- end
data/spec/logger_spec.rb DELETED
@@ -1,14 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe '#logger' do
4
-
5
-
6
- after(:each) { ChewyKiqqer.logger = nil }
7
-
8
- it 'can be set from the outside' do
9
- ChewyKiqqer.logger = :nolog
10
- expect(ChewyKiqqer.logger).to eq(:nolog)
11
- end
12
-
13
-
14
- end