liveqa 1.9.0 → 1.9.1
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/lib/liveqa/processor/async.rb +12 -16
- data/lib/liveqa/processor/worker.rb +11 -7
- data/lib/liveqa/version.rb +1 -1
- data/lib/liveqa.rb +1 -0
- data/liveqa.gemspec +3 -1
- data/spec/lib/liveqa/processor/worker_spec.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cf621fc23d38f66505dc4983cff2e0c6fcf26b5
|
4
|
+
data.tar.gz: bdf797cb4b4934154630b44ad2efb05ef01cb14e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af70e6014944593db250372db0f2941654d1bdb33d5814ba2b419dcca048625ea46ed707bc02cb45ee1d98c208aa5b6ae798f757dd1bd93cd7b63143c6091615
|
7
|
+
data.tar.gz: b34ea34441bd718e033b2220d68670266efb4f073e850d8f8c1af765b672459873f17531653e975395f01182df2676fcbe423eb5ba4984960841cb6c6ee6bb55
|
@@ -4,12 +4,14 @@ module LiveQA
|
|
4
4
|
|
5
5
|
def initialize
|
6
6
|
@max_queue_size = 10_000
|
7
|
-
@queue =
|
8
|
-
@worker = Worker.new(@queue)
|
9
|
-
@worker_mutex = Mutex.new
|
7
|
+
@queue = Concurrent::Array.new
|
8
|
+
@worker = Worker.new(@queue, executor)
|
10
9
|
|
11
10
|
at_exit do
|
12
|
-
|
11
|
+
unless worker_running?
|
12
|
+
executor.shutdown
|
13
|
+
executor.wait_for_termination
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
@@ -22,25 +24,19 @@ module LiveQA
|
|
22
24
|
true
|
23
25
|
end
|
24
26
|
|
25
|
-
def flush
|
26
|
-
while !@queue.empty? || @worker.is_requesting?
|
27
|
-
ensure_worker_running
|
28
|
-
sleep(0.1)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
27
|
private
|
33
28
|
|
29
|
+
def executor
|
30
|
+
@executor ||= Concurrent.global_io_executor
|
31
|
+
end
|
32
|
+
|
34
33
|
def ensure_worker_running
|
35
34
|
return if worker_running?
|
36
|
-
@
|
37
|
-
return if worker_running?
|
38
|
-
@worker_thread = Thread.new { @worker.run }
|
39
|
-
end
|
35
|
+
@worker_thread = Concurrent::Future.execute { @worker.run }
|
40
36
|
end
|
41
37
|
|
42
38
|
def worker_running?
|
43
|
-
@worker_thread && @worker_thread.
|
39
|
+
@worker_thread && @worker_thread.incomplete?
|
44
40
|
end
|
45
41
|
|
46
42
|
end
|
@@ -5,17 +5,18 @@ module LiveQA
|
|
5
5
|
DEFAULT_WAIT_TIME = 2
|
6
6
|
|
7
7
|
attr_reader :queue
|
8
|
-
attr_reader :lock
|
9
8
|
attr_reader :batches
|
9
|
+
attr_reader :executor
|
10
10
|
|
11
|
-
def initialize(queue)
|
11
|
+
def initialize(queue, executor)
|
12
12
|
@queue = queue
|
13
|
-
@lock = Mutex.new
|
14
13
|
@batches = []
|
14
|
+
|
15
|
+
@executor = executor
|
15
16
|
end
|
16
17
|
|
17
18
|
def run
|
18
|
-
|
19
|
+
while running?
|
19
20
|
return if queue.empty? && batches.empty?
|
20
21
|
|
21
22
|
sleep(DEFAULT_WAIT_TIME) if queue.empty?
|
@@ -28,11 +29,14 @@ module LiveQA
|
|
28
29
|
|
29
30
|
private
|
30
31
|
|
32
|
+
def running?
|
33
|
+
return true if !queue.empty? || !batches.empty?
|
34
|
+
executor.running?
|
35
|
+
end
|
36
|
+
|
31
37
|
def create_new_batch
|
32
38
|
batch = Batch.new
|
33
|
-
|
34
|
-
batch << queue.pop until batch.full? || queue.empty?
|
35
|
-
end
|
39
|
+
batch << queue.pop until batch.full? || queue.empty?
|
36
40
|
batches.push(batch)
|
37
41
|
end
|
38
42
|
|
data/lib/liveqa/version.rb
CHANGED
data/lib/liveqa.rb
CHANGED
data/liveqa.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
10
|
s.authors = ['LiveQA']
|
11
11
|
s.email = ['support@liveqa.io']
|
12
|
-
s.homepage = 'https://github.com/
|
12
|
+
s.homepage = 'https://github.com/LiveQA/liveqa-ruby'
|
13
13
|
s.summary = 'LiveQA ruby integration'
|
14
14
|
s.description = 'LiveQA ruby integration'
|
15
15
|
|
@@ -18,6 +18,8 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.files = `git ls-files`.split("\n")
|
19
19
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
20
20
|
|
21
|
+
s.add_dependency 'concurrent-ruby', '~> 1.0.5'
|
22
|
+
|
21
23
|
s.add_development_dependency 'faker', '~> 1.8.4'
|
22
24
|
s.add_development_dependency 'pry'
|
23
25
|
s.add_development_dependency 'rake', '>= 0.9.0'
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe LiveQA::Processor::Worker do
|
4
4
|
let(:queue) { Queue.new }
|
5
|
-
let(:worker) { LiveQA::Processor::Worker.new(queue) }
|
5
|
+
let(:worker) { LiveQA::Processor::Worker.new(queue, Concurrent.global_io_executor) }
|
6
6
|
|
7
7
|
context 'do nothing' do
|
8
8
|
before do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liveqa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LiveQA
|
@@ -10,6 +10,20 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2018-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: concurrent-ruby
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.5
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: faker
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,7 +165,7 @@ files:
|
|
151
165
|
- spec/lib/liveqa_spec.rb
|
152
166
|
- spec/spec_helper.rb
|
153
167
|
- spec/support/rack_app.rb
|
154
|
-
homepage: https://github.com/
|
168
|
+
homepage: https://github.com/LiveQA/liveqa-ruby
|
155
169
|
licenses:
|
156
170
|
- MIT
|
157
171
|
metadata: {}
|