gitlab-sidekiq-fetcher 0.5.5 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +3 -0
- data/gitlab-sidekiq-fetcher.gemspec +1 -1
- data/lib/sidekiq/semi_reliable_fetch.rb +7 -3
- data/spec/semi_reliable_fetch_spec.rb +35 -0
- data/spec/spec_helper.rb +2 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 789f9e7424fe05ba56d1a5dc4aae2bd1cc750cb4c6ab3a0d87055876dec4ac63
|
4
|
+
data.tar.gz: c17bca12b0e63b47c3725000de1430f69cfdef6c4b5b791e40deacc0da0e2b33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9684d40185a5cd89a8ada02ae8563a0ae8a278866cfe59d11e5e2cc8cbcb610f29998dc4f9df0fc07720a723f6823c39e41f375542c0d9621fde87bbfccfb01c
|
7
|
+
data.tar.gz: 146e99c8e8fd388d56dbbd099658dceb8210101df31ab3d362eeeefa3fd52e75e469df24e1b06be5adae2231c9c978a84f2e0681b3a0bc91b8b5f5798c941f96
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -36,6 +36,8 @@ GEM
|
|
36
36
|
json (>= 1.8, < 3)
|
37
37
|
simplecov-html (~> 0.10.0)
|
38
38
|
simplecov-html (0.10.2)
|
39
|
+
stub_env (1.0.4)
|
40
|
+
rspec (>= 2.0, < 4.0)
|
39
41
|
|
40
42
|
PLATFORMS
|
41
43
|
ruby
|
@@ -45,6 +47,7 @@ DEPENDENCIES
|
|
45
47
|
rspec (~> 3)
|
46
48
|
sidekiq (~> 5.0)
|
47
49
|
simplecov
|
50
|
+
stub_env (~> 1.0)
|
48
51
|
|
49
52
|
BUNDLED WITH
|
50
53
|
1.17.1
|
@@ -5,14 +5,14 @@ module Sidekiq
|
|
5
5
|
# We want the fetch operation to timeout every few seconds so the thread
|
6
6
|
# can check if the process is shutting down. This constant is only used
|
7
7
|
# for semi-reliable fetch.
|
8
|
-
|
8
|
+
DEFAULT_SEMI_RELIABLE_FETCH_TIMEOUT = 2 # seconds
|
9
9
|
|
10
10
|
def initialize(options)
|
11
11
|
super
|
12
12
|
|
13
13
|
if strictly_ordered_queues
|
14
14
|
@queues = @queues.uniq
|
15
|
-
@queues <<
|
15
|
+
@queues << semi_reliable_fetch_timeout
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -36,9 +36,13 @@ module Sidekiq
|
|
36
36
|
@queues
|
37
37
|
else
|
38
38
|
queues = @queues.shuffle.uniq
|
39
|
-
queues <<
|
39
|
+
queues << semi_reliable_fetch_timeout
|
40
40
|
queues
|
41
41
|
end
|
42
42
|
end
|
43
|
+
|
44
|
+
def semi_reliable_fetch_timeout
|
45
|
+
@semi_reliable_fetch_timeout ||= ENV['SIDEKIQ_SEMI_RELIABLE_FETCH_TIMEOUT']&.to_i || DEFAULT_SEMI_RELIABLE_FETCH_TIMEOUT
|
46
|
+
end
|
43
47
|
end
|
44
48
|
end
|
@@ -5,4 +5,39 @@ require 'sidekiq/semi_reliable_fetch'
|
|
5
5
|
|
6
6
|
describe Sidekiq::SemiReliableFetch do
|
7
7
|
include_examples 'a Sidekiq fetcher'
|
8
|
+
|
9
|
+
describe '#retrieve_work' do
|
10
|
+
context 'timeout config' do
|
11
|
+
let(:queues) { ['stuff_to_do'] }
|
12
|
+
let(:fetcher) { described_class.new(queues: queues) }
|
13
|
+
|
14
|
+
before do
|
15
|
+
stub_env('SIDEKIQ_SEMI_RELIABLE_FETCH_TIMEOUT', timeout)
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when the timeout is not configured' do
|
19
|
+
let(:timeout) { nil }
|
20
|
+
|
21
|
+
it 'brpops with the default timeout timeout' do
|
22
|
+
Sidekiq.redis do |connection|
|
23
|
+
expect(connection).to receive(:brpop).with("queue:stuff_to_do", 2).once.and_call_original
|
24
|
+
|
25
|
+
fetcher.retrieve_work
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when the timeout is set in the env' do
|
31
|
+
let(:timeout) { '5' }
|
32
|
+
|
33
|
+
it 'brpops with the default timeout timeout' do
|
34
|
+
Sidekiq.redis do |connection|
|
35
|
+
expect(connection).to receive(:brpop).with("queue:stuff_to_do", 5).once.and_call_original
|
36
|
+
|
37
|
+
fetcher.retrieve_work
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
8
43
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,6 +3,7 @@ require 'sidekiq/util'
|
|
3
3
|
require 'sidekiq/api'
|
4
4
|
require 'pry'
|
5
5
|
require 'simplecov'
|
6
|
+
require 'stub_env'
|
6
7
|
|
7
8
|
SimpleCov.start
|
8
9
|
|
@@ -29,6 +30,7 @@ Sidekiq.logger.level = Logger::ERROR
|
|
29
30
|
#
|
30
31
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
31
32
|
RSpec.configure do |config|
|
33
|
+
config.include StubEnv::Helpers
|
32
34
|
# rspec-expectations config goes here. You can use an alternate
|
33
35
|
# assertion/expectation library such as wrong or the stdlib/minitest
|
34
36
|
# assertions if you prefer.
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-sidekiq-fetcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TEA
|
8
8
|
- GitLab
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-03-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sidekiq
|
@@ -63,7 +63,7 @@ homepage: https://gitlab.com/gitlab-org/sidekiq-reliable-fetch/
|
|
63
63
|
licenses:
|
64
64
|
- LGPL-3.0
|
65
65
|
metadata: {}
|
66
|
-
post_install_message:
|
66
|
+
post_install_message:
|
67
67
|
rdoc_options: []
|
68
68
|
require_paths:
|
69
69
|
- lib
|
@@ -78,8 +78,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
78
|
- !ruby/object:Gem::Version
|
79
79
|
version: '0'
|
80
80
|
requirements: []
|
81
|
-
rubygems_version: 3.
|
82
|
-
signing_key:
|
81
|
+
rubygems_version: 3.0.3
|
82
|
+
signing_key:
|
83
83
|
specification_version: 4
|
84
84
|
summary: Reliable fetch extension for Sidekiq
|
85
85
|
test_files: []
|