asynchronic 2.0.1 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +7 -10
- data/README.md +1 -2
- data/asynchronic.gemspec +3 -2
- data/lib/asynchronic.rb +13 -3
- data/lib/asynchronic/data_store/in_memory.rb +17 -15
- data/lib/asynchronic/data_store/key.rb +3 -3
- data/lib/asynchronic/data_store/lazy_value.rb +5 -3
- data/lib/asynchronic/data_store/redis.rb +22 -14
- data/lib/asynchronic/data_store/scoped_store.rb +18 -19
- data/lib/asynchronic/environment.rb +6 -6
- data/lib/asynchronic/error.rb +2 -3
- data/lib/asynchronic/garbage_collector.rb +2 -0
- data/lib/asynchronic/job.rb +12 -12
- data/lib/asynchronic/notifier/broadcaster.rb +34 -0
- data/lib/asynchronic/notifier/in_memory.rb +33 -0
- data/lib/asynchronic/process.rb +52 -38
- data/lib/asynchronic/queue_engine/in_memory.rb +17 -11
- data/lib/asynchronic/queue_engine/ost.rb +15 -12
- data/lib/asynchronic/queue_engine/synchronic.rb +19 -7
- data/lib/asynchronic/version.rb +1 -1
- data/lib/asynchronic/worker.rb +7 -10
- data/spec/data_store/data_store_examples.rb +17 -9
- data/spec/data_store/in_memory_spec.rb +0 -2
- data/spec/data_store/key_spec.rb +1 -1
- data/spec/data_store/lazy_value_examples.rb +7 -6
- data/spec/data_store/redis_spec.rb +4 -10
- data/spec/expectations.rb +2 -2
- data/spec/facade_spec.rb +5 -5
- data/spec/jobs.rb +12 -12
- data/spec/minitest_helper.rb +6 -12
- data/spec/process/life_cycle_examples.rb +111 -64
- data/spec/process/life_cycle_in_memory_spec.rb +1 -1
- data/spec/process/life_cycle_redis_spec.rb +1 -1
- data/spec/queue_engine/in_memory_spec.rb +1 -3
- data/spec/queue_engine/ost_spec.rb +1 -7
- data/spec/queue_engine/queue_engine_examples.rb +17 -9
- data/spec/queue_engine/synchronic_spec.rb +1 -1
- data/spec/worker/in_memory_spec.rb +2 -2
- data/spec/worker/redis_spec.rb +1 -6
- data/spec/worker/worker_examples.rb +7 -5
- metadata +38 -17
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'minitest_helper'
|
2
|
-
require_relative './life_cycle_examples.rb'
|
3
2
|
|
4
3
|
describe Asynchronic::Process, 'Life cycle - InMemory' do
|
5
4
|
|
6
5
|
let(:queue_engine) { Asynchronic::QueueEngine::InMemory.new }
|
7
6
|
let(:data_store) { Asynchronic::DataStore::InMemory.new }
|
7
|
+
let(:notifier) { Asynchronic::Notifier::InMemory.new }
|
8
8
|
|
9
9
|
include LifeCycleExamples
|
10
10
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'minitest_helper'
|
2
|
-
require_relative './life_cycle_examples.rb'
|
3
2
|
|
4
3
|
describe Asynchronic::Process, 'Life cycle - Redis' do
|
5
4
|
|
6
5
|
let(:queue_engine) { Asynchronic::QueueEngine::Ost.new }
|
7
6
|
let(:data_store) { Asynchronic::DataStore::Redis.new :asynchronic_test }
|
7
|
+
let(:notifier) { Asynchronic::Notifier::Broadcaster.new }
|
8
8
|
|
9
9
|
include LifeCycleExamples
|
10
10
|
|
@@ -1,11 +1,9 @@
|
|
1
1
|
require 'minitest_helper'
|
2
|
-
require_relative './queue_engine_examples'
|
3
2
|
|
4
3
|
describe Asynchronic::QueueEngine::InMemory do
|
5
4
|
|
6
5
|
let(:engine) { Asynchronic::QueueEngine::InMemory.new }
|
7
|
-
let(:listener) { Asynchronic::QueueEngine::InMemory::Listener.new }
|
8
6
|
|
9
7
|
include QueueEngineExamples
|
10
|
-
|
8
|
+
|
11
9
|
end
|
@@ -1,19 +1,13 @@
|
|
1
1
|
require 'minitest_helper'
|
2
|
-
require_relative './queue_engine_examples'
|
3
2
|
|
4
3
|
describe Asynchronic::QueueEngine::Ost do
|
5
4
|
|
6
5
|
let(:engine) { Asynchronic::QueueEngine::Ost.new }
|
7
|
-
let(:listener) { Asynchronic::QueueEngine::Ost::Listener.new }
|
8
6
|
|
9
|
-
before do
|
10
|
-
engine.clear
|
11
|
-
end
|
12
|
-
|
13
7
|
include QueueEngineExamples
|
14
8
|
|
15
9
|
it 'Engine and queues use same redis connection' do
|
16
10
|
engine.redis.must_equal queue.redis
|
17
11
|
end
|
18
|
-
|
12
|
+
|
19
13
|
end
|
@@ -1,26 +1,34 @@
|
|
1
1
|
module QueueEngineExamples
|
2
|
-
|
2
|
+
|
3
|
+
extend Minitest::Spec::DSL
|
4
|
+
|
3
5
|
let(:queue) { engine[:test_queue] }
|
4
6
|
|
7
|
+
let(:listener) { engine.listener }
|
8
|
+
|
9
|
+
after do
|
10
|
+
engine.clear
|
11
|
+
end
|
12
|
+
|
5
13
|
it 'Engine' do
|
6
|
-
engine.
|
7
|
-
|
14
|
+
engine.queue_names.must_be_empty
|
15
|
+
|
8
16
|
queue = engine[:test_engine]
|
9
17
|
queue.must_be_instance_of engine.class.const_get(:Queue)
|
10
|
-
engine.
|
11
|
-
|
18
|
+
engine.queue_names.must_equal [:test_engine]
|
19
|
+
|
12
20
|
engine[:test_engine].must_equal queue
|
13
|
-
|
21
|
+
|
14
22
|
engine.clear
|
15
|
-
engine.
|
23
|
+
engine.queue_names.must_be_empty
|
16
24
|
end
|
17
25
|
|
18
26
|
it 'Queue (push/pop)' do
|
19
27
|
queue.must_be_empty
|
20
|
-
|
28
|
+
|
21
29
|
queue.push 'msg_1'
|
22
30
|
queue.push 'msg_2'
|
23
|
-
|
31
|
+
|
24
32
|
queue.size.must_equal 2
|
25
33
|
queue.to_a.must_equal %w(msg_1 msg_2)
|
26
34
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'minitest_helper'
|
2
|
-
require_relative './worker_examples'
|
3
2
|
|
4
3
|
describe Asynchronic::Worker, 'InMemory' do
|
5
4
|
|
6
5
|
let(:queue_engine) { Asynchronic::QueueEngine::InMemory.new }
|
7
6
|
let(:data_store) { Asynchronic::DataStore::InMemory.new }
|
7
|
+
let(:notifier) { Asynchronic::Notifier::InMemory.new }
|
8
8
|
|
9
9
|
include WorkerExamples
|
10
|
-
|
10
|
+
|
11
11
|
end
|
data/spec/worker/redis_spec.rb
CHANGED
@@ -1,15 +1,10 @@
|
|
1
1
|
require 'minitest_helper'
|
2
|
-
require_relative './worker_examples'
|
3
2
|
|
4
3
|
describe Asynchronic::Worker, 'Redis' do
|
5
4
|
|
6
5
|
let(:queue_engine) { Asynchronic::QueueEngine::Ost.new }
|
7
6
|
let(:data_store) { Asynchronic::DataStore::Redis.new :asynchronic_test}
|
8
|
-
|
9
|
-
after do
|
10
|
-
data_store.clear
|
11
|
-
queue_engine.clear
|
12
|
-
end
|
7
|
+
let(:notifier) { Asynchronic::Notifier::Broadcaster.new }
|
13
8
|
|
14
9
|
include WorkerExamples
|
15
10
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module WorkerExamples
|
2
2
|
|
3
|
-
|
3
|
+
extend Minitest::Spec::DSL
|
4
|
+
|
5
|
+
let(:env) { Asynchronic::Environment.new queue_engine, data_store, notifier }
|
4
6
|
let(:queue_name) { :test_worker }
|
5
7
|
let(:queue) { env.queue queue_name }
|
6
8
|
|
@@ -27,7 +29,7 @@ module WorkerExamples
|
|
27
29
|
|
28
30
|
Thread.new do
|
29
31
|
loop { break if queue.empty? }
|
30
|
-
worker.stop
|
32
|
+
worker.stop
|
31
33
|
end
|
32
34
|
|
33
35
|
worker.start
|
@@ -45,10 +47,10 @@ module WorkerExamples
|
|
45
47
|
|
46
48
|
Asynchronic::Worker.start :test_worker do |worker|
|
47
49
|
loop { break if worker.queue.empty? }
|
48
|
-
worker.stop
|
50
|
+
worker.stop
|
49
51
|
end
|
50
|
-
|
51
|
-
processes.each { |p| p.must_be :completed? }
|
52
|
+
|
53
|
+
processes.each { |p| p.must_be :completed? }
|
52
54
|
end
|
53
55
|
|
54
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asynchronic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Naiman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ost
|
@@ -25,21 +25,27 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: broadcaster
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1.0'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.0.2
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
41
|
- - "~>"
|
39
42
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
43
|
+
version: '1.0'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.0.2
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
48
|
+
name: class_config
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
51
|
- - "~>"
|
@@ -53,47 +59,47 @@ dependencies:
|
|
53
59
|
- !ruby/object:Gem::Version
|
54
60
|
version: '0.0'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
62
|
+
name: transparent_proxy
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
65
|
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
67
|
+
version: '0.0'
|
62
68
|
type: :runtime
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
72
|
- - "~>"
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
74
|
+
version: '0.0'
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
76
|
+
name: multi_require
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
72
78
|
requirements:
|
73
79
|
- - "~>"
|
74
80
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
76
|
-
type: :
|
81
|
+
version: '1.0'
|
82
|
+
type: :runtime
|
77
83
|
prerelease: false
|
78
84
|
version_requirements: !ruby/object:Gem::Requirement
|
79
85
|
requirements:
|
80
86
|
- - "~>"
|
81
87
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
88
|
+
version: '1.0'
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
90
|
name: rake
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
86
92
|
requirements:
|
87
93
|
- - "~>"
|
88
94
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
95
|
+
version: '12.0'
|
90
96
|
type: :development
|
91
97
|
prerelease: false
|
92
98
|
version_requirements: !ruby/object:Gem::Requirement
|
93
99
|
requirements:
|
94
100
|
- - "~>"
|
95
101
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
102
|
+
version: '12.0'
|
97
103
|
- !ruby/object:Gem::Dependency
|
98
104
|
name: minitest
|
99
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,6 +134,20 @@ dependencies:
|
|
128
134
|
- - "~>"
|
129
135
|
- !ruby/object:Gem::Version
|
130
136
|
version: '0.0'
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: minitest-stub_any_instance
|
139
|
+
requirement: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - "~>"
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '1.0'
|
144
|
+
type: :development
|
145
|
+
prerelease: false
|
146
|
+
version_requirements: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - "~>"
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '1.0'
|
131
151
|
- !ruby/object:Gem::Dependency
|
132
152
|
name: minitest-colorin
|
133
153
|
requirement: !ruby/object:Gem::Requirement
|
@@ -229,6 +249,8 @@ files:
|
|
229
249
|
- lib/asynchronic/error.rb
|
230
250
|
- lib/asynchronic/garbage_collector.rb
|
231
251
|
- lib/asynchronic/job.rb
|
252
|
+
- lib/asynchronic/notifier/broadcaster.rb
|
253
|
+
- lib/asynchronic/notifier/in_memory.rb
|
232
254
|
- lib/asynchronic/process.rb
|
233
255
|
- lib/asynchronic/queue_engine/in_memory.rb
|
234
256
|
- lib/asynchronic/queue_engine/ost.rb
|
@@ -275,8 +297,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
275
297
|
- !ruby/object:Gem::Version
|
276
298
|
version: '0'
|
277
299
|
requirements: []
|
278
|
-
|
279
|
-
rubygems_version: 2.6.8
|
300
|
+
rubygems_version: 3.0.8
|
280
301
|
signing_key:
|
281
302
|
specification_version: 4
|
282
303
|
summary: DSL for asynchronic pipeline using queues over Redis
|