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 +4 -4
- data/lib/chewy_kiqqer.rb +1 -1
- data/lib/chewy_kiqqer/config.rb +23 -0
- data/lib/chewy_kiqqer/version.rb +1 -1
- data/lib/chewy_kiqqer/worker.rb +1 -1
- data/spec/config_spec.rb +29 -0
- metadata +4 -4
- data/lib/chewy_kiqqer/logger.rb +0 -13
- data/spec/logger_spec.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b91b694c61a6898e20ac484811ce3ca4634028e0
|
4
|
+
data.tar.gz: a5aa154c0a8f35df90c25d138e4db11d0951aa0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96a02ad4c2ecd1ef0867396b66ca485c2e73fc0606b559b0b977861cbef20bdf66ca372840f50846a0431ebba2afd9b942df501a0dad6f8e6635bd54a189b3bf
|
7
|
+
data.tar.gz: 433ae9028d1f6721d75192450b7e7ab713a08b80948e8af1b2d20c1351f5915a4e34be3dfbf9fdc96fc1f3b7ec91c5384faf3f84daa92503222695866c236f3c
|
data/lib/chewy_kiqqer.rb
CHANGED
@@ -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
|
data/lib/chewy_kiqqer/version.rb
CHANGED
data/lib/chewy_kiqqer/worker.rb
CHANGED
@@ -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 = "
|
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
|
data/spec/config_spec.rb
ADDED
@@ -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.
|
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
|
data/lib/chewy_kiqqer/logger.rb
DELETED
data/spec/logger_spec.rb
DELETED