asynchronic 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/lib/asynchronic.rb +0 -2
  2. data/lib/asynchronic/data_store/helper.rb +42 -0
  3. data/lib/asynchronic/data_store/in_memory.rb +18 -22
  4. data/lib/asynchronic/data_store/key.rb +19 -1
  5. data/lib/asynchronic/data_store/lazy_store.rb +17 -0
  6. data/lib/asynchronic/data_store/lazy_value.rb +34 -0
  7. data/lib/asynchronic/data_store/readonly_store.rb +17 -0
  8. data/lib/asynchronic/data_store/redis.rb +16 -27
  9. data/lib/asynchronic/data_store/scoped_store.rb +52 -0
  10. data/lib/asynchronic/environment.rb +7 -27
  11. data/lib/asynchronic/job.rb +15 -27
  12. data/lib/asynchronic/process.rb +105 -76
  13. data/lib/asynchronic/queue_engine/in_memory.rb +5 -1
  14. data/lib/asynchronic/queue_engine/ost.rb +5 -1
  15. data/lib/asynchronic/queue_engine/synchronic.rb +68 -0
  16. data/lib/asynchronic/transparent_proxy.rb +52 -0
  17. data/lib/asynchronic/version.rb +1 -1
  18. data/spec/data_store/data_store_examples.rb +48 -32
  19. data/spec/data_store/in_memory_spec.rb +5 -0
  20. data/spec/data_store/key_spec.rb +36 -12
  21. data/spec/data_store/lazy_value_examples.rb +38 -0
  22. data/spec/data_store/redis_spec.rb +17 -0
  23. data/spec/data_store/scoped_store_spec.rb +60 -0
  24. data/spec/expectations.rb +7 -7
  25. data/spec/facade_spec.rb +15 -13
  26. data/spec/jobs.rb +70 -49
  27. data/spec/minitest_helper.rb +11 -1
  28. data/spec/process/life_cycle_examples.rb +149 -135
  29. data/spec/queue_engine/synchronic_spec.rb +27 -0
  30. data/spec/transparent_proxy_spec.rb +36 -0
  31. data/spec/worker/worker_examples.rb +1 -1
  32. metadata +117 -79
  33. checksums.yaml +0 -7
  34. data/lib/asynchronic/data_store/lookup.rb +0 -27
  35. data/lib/asynchronic/hash.rb +0 -31
  36. data/lib/asynchronic/runtime.rb +0 -40
  37. data/spec/data_store/lookup_spec.rb +0 -92
@@ -0,0 +1,27 @@
1
+ require 'minitest_helper'
2
+
3
+ describe Asynchronic::QueueEngine::Synchronic do
4
+
5
+ before do
6
+ Asynchronic.configure do |config|
7
+ config.queue_engine = Asynchronic::QueueEngine::Synchronic.new
8
+ end
9
+ end
10
+
11
+ it 'Original job' do
12
+ pid = BasicJob.enqueue input: 1
13
+ process = Asynchronic[pid]
14
+ process.result.must_equal 2
15
+ end
16
+
17
+ it 'Stub job' do
18
+ Asynchronic.queue_engine.stub BasicJob do |process|
19
+ process.params[:input] + 19
20
+ end
21
+
22
+ pid = BasicJob.enqueue input: 1
23
+ process = Asynchronic[pid]
24
+ process.result.must_equal 20
25
+ end
26
+
27
+ end
@@ -0,0 +1,36 @@
1
+ require 'minitest_helper'
2
+
3
+ describe Asynchronic::TransparentProxy do
4
+
5
+ it 'Transparent' do
6
+ proxy = Asynchronic::TransparentProxy.new 1
7
+
8
+ proxy.must_equal 1
9
+ (proxy + 1).must_equal 2
10
+ proxy.class.must_equal Fixnum
11
+ proxy.inspect.must_equal 1.inspect
12
+ proxy.methods.must_equal proxy.proxy_methods | 1.methods
13
+ end
14
+
15
+ it 'Proxy methods' do
16
+ proxy = Asynchronic::TransparentProxy.new 1
17
+
18
+ proxy.must_be :proxy?
19
+ proxy.proxy_class.must_equal Asynchronic::TransparentProxy
20
+ proxy.proxy_inspect.must_match /#<Asynchronic::TransparentProxy @object=1>/
21
+ proxy.proxy_methods.must_include_all [:__send__, :object_id, :tap]
22
+ proxy.must_respond_to :proxy_respond_to?
23
+ end
24
+
25
+ it 'Subclass' do
26
+ class NumberProxy < Asynchronic::TransparentProxy
27
+ def to_letters
28
+ 'one'
29
+ end
30
+ end
31
+
32
+ proxy = NumberProxy.new 1
33
+ proxy.to_letters.must_equal 'one'
34
+ end
35
+
36
+ end
@@ -6,7 +6,7 @@ module WorkerExamples
6
6
 
7
7
  def enqueue_processes
8
8
  processes = 5.times.map do
9
- env.build_process(WorkerJob, queue: :test_worker).tap(&:enqueue)
9
+ env.create_process(WorkerJob, queue: :test_worker).tap(&:enqueue)
10
10
  end
11
11
 
12
12
  queue.must_enqueued processes
metadata CHANGED
@@ -1,155 +1,176 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asynchronic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ prerelease:
5
+ version: 0.2.0
5
6
  platform: ruby
6
7
  authors:
7
8
  - Gabriel Naiman
8
- autorequire:
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-03-06 00:00:00.000000000 Z
12
+ date: 2014-04-09 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: redis
15
- requirement: !ruby/object:Gem::Requirement
16
+ version_requirements: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - "~>"
18
+ - - ~>
18
19
  - !ruby/object:Gem::Version
19
20
  version: '3.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
21
+ none: false
22
+ requirement: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.0'
27
+ none: false
28
+ prerelease: false
29
+ type: :runtime
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: ost
29
- requirement: !ruby/object:Gem::Requirement
32
+ version_requirements: !ruby/object:Gem::Requirement
30
33
  requirements:
31
- - - "~>"
34
+ - - ~>
32
35
  - !ruby/object:Gem::Version
33
36
  version: '0.1'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirement: !ruby/object:Gem::Requirement
37
39
  requirements:
38
- - - "~>"
40
+ - - ~>
39
41
  - !ruby/object:Gem::Version
40
42
  version: '0.1'
43
+ none: false
44
+ prerelease: false
45
+ type: :runtime
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: class_config
43
- requirement: !ruby/object:Gem::Requirement
48
+ version_requirements: !ruby/object:Gem::Requirement
44
49
  requirements:
45
- - - "~>"
50
+ - - ~>
46
51
  - !ruby/object:Gem::Version
47
52
  version: '0.0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirement: !ruby/object:Gem::Requirement
51
55
  requirements:
52
- - - "~>"
56
+ - - ~>
53
57
  - !ruby/object:Gem::Version
54
58
  version: '0.0'
59
+ none: false
60
+ prerelease: false
61
+ type: :runtime
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: bundler
57
- requirement: !ruby/object:Gem::Requirement
64
+ version_requirements: !ruby/object:Gem::Requirement
58
65
  requirements:
59
- - - "~>"
66
+ - - ~>
60
67
  - !ruby/object:Gem::Version
61
68
  version: '1.3'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirement: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - "~>"
72
+ - - ~>
67
73
  - !ruby/object:Gem::Version
68
74
  version: '1.3'
75
+ none: false
76
+ prerelease: false
77
+ type: :development
69
78
  - !ruby/object:Gem::Dependency
70
79
  name: rake
71
- requirement: !ruby/object:Gem::Requirement
80
+ version_requirements: !ruby/object:Gem::Requirement
72
81
  requirements:
73
- - - ">="
82
+ - - '>='
74
83
  - !ruby/object:Gem::Version
75
84
  version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirement: !ruby/object:Gem::Requirement
79
87
  requirements:
80
- - - ">="
88
+ - - '>='
81
89
  - !ruby/object:Gem::Version
82
90
  version: '0'
91
+ none: false
92
+ prerelease: false
93
+ type: :development
83
94
  - !ruby/object:Gem::Dependency
84
95
  name: minitest
85
- requirement: !ruby/object:Gem::Requirement
96
+ version_requirements: !ruby/object:Gem::Requirement
86
97
  requirements:
87
- - - "~>"
98
+ - - ~>
88
99
  - !ruby/object:Gem::Version
89
100
  version: '4.7'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirement: !ruby/object:Gem::Requirement
93
103
  requirements:
94
- - - "~>"
104
+ - - ~>
95
105
  - !ruby/object:Gem::Version
96
106
  version: '4.7'
107
+ none: false
108
+ prerelease: false
109
+ type: :development
97
110
  - !ruby/object:Gem::Dependency
98
111
  name: minitest-great_expectations
99
- requirement: !ruby/object:Gem::Requirement
112
+ version_requirements: !ruby/object:Gem::Requirement
100
113
  requirements:
101
- - - "~>"
114
+ - - ~>
102
115
  - !ruby/object:Gem::Version
103
116
  version: '0.0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirement: !ruby/object:Gem::Requirement
107
119
  requirements:
108
- - - "~>"
120
+ - - ~>
109
121
  - !ruby/object:Gem::Version
110
122
  version: '0.0'
123
+ none: false
124
+ prerelease: false
125
+ type: :development
111
126
  - !ruby/object:Gem::Dependency
112
127
  name: turn
113
- requirement: !ruby/object:Gem::Requirement
128
+ version_requirements: !ruby/object:Gem::Requirement
114
129
  requirements:
115
- - - "~>"
130
+ - - ~>
116
131
  - !ruby/object:Gem::Version
117
132
  version: '0.9'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirement: !ruby/object:Gem::Requirement
121
135
  requirements:
122
- - - "~>"
136
+ - - ~>
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0.9'
139
+ none: false
140
+ prerelease: false
141
+ type: :development
125
142
  - !ruby/object:Gem::Dependency
126
143
  name: simplecov
127
- requirement: !ruby/object:Gem::Requirement
144
+ version_requirements: !ruby/object:Gem::Requirement
128
145
  requirements:
129
- - - ">="
146
+ - - '>='
130
147
  - !ruby/object:Gem::Version
131
148
  version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirement: !ruby/object:Gem::Requirement
135
151
  requirements:
136
- - - ">="
152
+ - - '>='
137
153
  - !ruby/object:Gem::Version
138
154
  version: '0'
155
+ none: false
156
+ prerelease: false
157
+ type: :development
139
158
  - !ruby/object:Gem::Dependency
140
159
  name: pry
141
- requirement: !ruby/object:Gem::Requirement
160
+ version_requirements: !ruby/object:Gem::Requirement
142
161
  requirements:
143
- - - ">="
162
+ - - '>='
144
163
  - !ruby/object:Gem::Version
145
164
  version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
165
+ none: false
166
+ requirement: !ruby/object:Gem::Requirement
149
167
  requirements:
150
- - - ">="
168
+ - - '>='
151
169
  - !ruby/object:Gem::Version
152
170
  version: '0'
171
+ none: false
172
+ prerelease: false
173
+ type: :development
153
174
  description: DSL for asynchronic pipeline
154
175
  email:
155
176
  - gabynaiman@gmail.com
@@ -157,35 +178,40 @@ executables: []
157
178
  extensions: []
158
179
  extra_rdoc_files: []
159
180
  files:
160
- - ".coveralls.yml"
161
- - ".gitignore"
162
- - ".travis.yml"
181
+ - .coveralls.yml
182
+ - .gitignore
183
+ - .travis.yml
163
184
  - Gemfile
164
185
  - LICENSE.txt
165
186
  - README.md
166
187
  - Rakefile
167
188
  - asynchronic.gemspec
168
189
  - lib/asynchronic.rb
190
+ - lib/asynchronic/data_store/helper.rb
169
191
  - lib/asynchronic/data_store/in_memory.rb
170
192
  - lib/asynchronic/data_store/key.rb
171
- - lib/asynchronic/data_store/lookup.rb
193
+ - lib/asynchronic/data_store/lazy_store.rb
194
+ - lib/asynchronic/data_store/lazy_value.rb
195
+ - lib/asynchronic/data_store/readonly_store.rb
172
196
  - lib/asynchronic/data_store/redis.rb
197
+ - lib/asynchronic/data_store/scoped_store.rb
173
198
  - lib/asynchronic/environment.rb
174
199
  - lib/asynchronic/error.rb
175
- - lib/asynchronic/hash.rb
176
200
  - lib/asynchronic/job.rb
177
201
  - lib/asynchronic/process.rb
178
202
  - lib/asynchronic/queue_engine/in_memory.rb
179
203
  - lib/asynchronic/queue_engine/ost.rb
180
- - lib/asynchronic/runtime.rb
204
+ - lib/asynchronic/queue_engine/synchronic.rb
205
+ - lib/asynchronic/transparent_proxy.rb
181
206
  - lib/asynchronic/version.rb
182
207
  - lib/asynchronic/worker.rb
183
208
  - spec/coverage_helper.rb
184
209
  - spec/data_store/data_store_examples.rb
185
210
  - spec/data_store/in_memory_spec.rb
186
211
  - spec/data_store/key_spec.rb
187
- - spec/data_store/lookup_spec.rb
212
+ - spec/data_store/lazy_value_examples.rb
188
213
  - spec/data_store/redis_spec.rb
214
+ - spec/data_store/scoped_store_spec.rb
189
215
  - spec/expectations.rb
190
216
  - spec/facade_spec.rb
191
217
  - spec/jobs.rb
@@ -196,40 +222,50 @@ files:
196
222
  - spec/queue_engine/in_memory_spec.rb
197
223
  - spec/queue_engine/ost_spec.rb
198
224
  - spec/queue_engine/queue_engine_examples.rb
225
+ - spec/queue_engine/synchronic_spec.rb
226
+ - spec/transparent_proxy_spec.rb
199
227
  - spec/worker/in_memory_spec.rb
200
228
  - spec/worker/redis_spec.rb
201
229
  - spec/worker/worker_examples.rb
202
230
  homepage: https://github.com/gabynaiman/asynchronic
203
231
  licenses:
204
232
  - MIT
205
- metadata: {}
206
- post_install_message:
233
+ post_install_message:
207
234
  rdoc_options: []
208
235
  require_paths:
209
236
  - lib
210
237
  required_ruby_version: !ruby/object:Gem::Requirement
211
238
  requirements:
212
- - - ">="
239
+ - - '>='
213
240
  - !ruby/object:Gem::Version
241
+ segments:
242
+ - 0
243
+ hash: 2
214
244
  version: '0'
245
+ none: false
215
246
  required_rubygems_version: !ruby/object:Gem::Requirement
216
247
  requirements:
217
- - - ">="
248
+ - - '>='
218
249
  - !ruby/object:Gem::Version
250
+ segments:
251
+ - 0
252
+ hash: 2
219
253
  version: '0'
254
+ none: false
220
255
  requirements: []
221
- rubyforge_project:
222
- rubygems_version: 2.2.2
223
- signing_key:
224
- specification_version: 4
256
+ rubyforge_project:
257
+ rubygems_version: 1.8.24
258
+ signing_key:
259
+ specification_version: 3
225
260
  summary: DSL for asynchronic pipeline using queues over Redis
226
261
  test_files:
227
262
  - spec/coverage_helper.rb
228
263
  - spec/data_store/data_store_examples.rb
229
264
  - spec/data_store/in_memory_spec.rb
230
265
  - spec/data_store/key_spec.rb
231
- - spec/data_store/lookup_spec.rb
266
+ - spec/data_store/lazy_value_examples.rb
232
267
  - spec/data_store/redis_spec.rb
268
+ - spec/data_store/scoped_store_spec.rb
233
269
  - spec/expectations.rb
234
270
  - spec/facade_spec.rb
235
271
  - spec/jobs.rb
@@ -240,6 +276,8 @@ test_files:
240
276
  - spec/queue_engine/in_memory_spec.rb
241
277
  - spec/queue_engine/ost_spec.rb
242
278
  - spec/queue_engine/queue_engine_examples.rb
279
+ - spec/queue_engine/synchronic_spec.rb
280
+ - spec/transparent_proxy_spec.rb
243
281
  - spec/worker/in_memory_spec.rb
244
282
  - spec/worker/redis_spec.rb
245
283
  - spec/worker/worker_examples.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 15caa715564ca133dd45cad9dce01db2de3cf7a6
4
- data.tar.gz: 006fe0ebb38821c8cd1842e4b8060e14779d71c5
5
- SHA512:
6
- metadata.gz: c41cf2f761f07c3b17a0c05099361bbe90f2f33506bb29a349074f079827bd1ee588e12319158a1c59e399bbd0f641c616579b401f4aac2a82175be59916e73e
7
- data.tar.gz: a64a7b0e1a5422bee3fa8a465d166ef37342ef5294865c24208a211423aed838f9f031b0320755cfde35788c2e6d34691b1fc762173af33bd3ed430359ffa112
@@ -1,27 +0,0 @@
1
- module Asynchronic
2
- module DataStore
3
- class Lookup
4
-
5
- KEYS = [:status, :data, :jobs, :error, :created_at, :queued_at, :started_at, :finalized_at]
6
-
7
- def initialize(job)
8
- @job = job
9
- end
10
-
11
- def id
12
- if @job.parent
13
- DataStore::Key.new(@job.parent)[:jobs][@job.id]
14
- else
15
- DataStore::Key.new(:job)[@job.id]
16
- end
17
- end
18
-
19
- KEYS.each do |key|
20
- define_method key do
21
- id[key]
22
- end
23
- end
24
-
25
- end
26
- end
27
- end