asynchronic 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c233ba42d14f9cd01205b836b977bbb421967a86
4
- data.tar.gz: 3981749bcf400e7a357a5f966faa1a22262d177b
3
+ metadata.gz: 823dcc2c35bf1f7df17c20f250353123fa85c205
4
+ data.tar.gz: c6f9507f48e4cb8b4e17051dcf30333bb1747b0b
5
5
  SHA512:
6
- metadata.gz: 5ee6f44da055f4d10cdc4119bca30f4dd87db2230a16e47a7158871695ef66f9556cbb50233897406fb58ff2761c95817b0b641c1f4d66dcf3b7f6235617272a
7
- data.tar.gz: fa2f7b3269ada65f0b0c756bef8de2f5e10a33b50b37c0cc6d144b26ce765a3752ccdfdb8036c9e53ff0da448a6fb2629de297d9dd2a0b87368957fa05da31cd
6
+ metadata.gz: 30d4424ab6e16190dbcd2404259bfa0720db02e092d6998f3fd8c1129e0e1d4b47064aed4a4a571dd85a5f3ab871a8a11091ca22c2a9d9d5d759e568c6efda8d
7
+ data.tar.gz: deb0672e6e9d1e4bf01017a8db5775cf6c2b57dc5e65257c333f7e8dd1fbb60e0562ff9dbe9533ec57bb5f74adc891967d48a2d80bcefd658b163a1a95f49d3e
@@ -1 +1 @@
1
- ruby 2.0
1
+ ruby-2.3.0
@@ -1,9 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 1.9.3
3
4
  - 2.0
4
5
  - 2.1
5
6
  - 2.2
6
7
  - 2.3.0
8
+ - 2.4.0
7
9
  - jruby
8
10
  services:
9
11
  - redis-server
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Asynchronic
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/asynchronic.png)](https://rubygems.org/gems/asynchronic)
4
- [![Build Status](https://travis-ci.org/gabynaiman/asynchronic.png?branch=master)](https://travis-ci.org/gabynaiman/asynchronic)
5
- [![Coverage Status](https://coveralls.io/repos/gabynaiman/asynchronic/badge.png?branch=master)](https://coveralls.io/r/gabynaiman/asynchronic?branch=master)
6
- [![Code Climate](https://codeclimate.com/github/gabynaiman/asynchronic.png)](https://codeclimate.com/github/gabynaiman/asynchronic)
7
- [![Dependency Status](https://gemnasium.com/gabynaiman/asynchronic.png)](https://gemnasium.com/gabynaiman/asynchronic)
3
+ [![Gem Version](https://badge.fury.io/rb/asynchronic.svg)](https://rubygems.org/gems/asynchronic)
4
+ [![Build Status](https://travis-ci.org/gabynaiman/asynchronic.svg?branch=master)](https://travis-ci.org/gabynaiman/asynchronic)
5
+ [![Coverage Status](https://coveralls.io/repos/gabynaiman/asynchronic/badge.svg?branch=master)](https://coveralls.io/r/gabynaiman/asynchronic?branch=master)
6
+ [![Code Climate](https://codeclimate.com/github/gabynaiman/asynchronic.svg)](https://codeclimate.com/github/gabynaiman/asynchronic)
7
+ [![Dependency Status](https://gemnasium.com/gabynaiman/asynchronic.svg)](https://gemnasium.com/gabynaiman/asynchronic)
8
8
 
9
9
  DSL for asynchronic pipeline using queues over Redis
10
10
 
@@ -30,6 +30,10 @@ module Asynchronic
30
30
  nil
31
31
  end
32
32
 
33
+ def set(key, value)
34
+ @process.set key, value
35
+ end
36
+
33
37
  def retry_when(exceptions, interval=1)
34
38
  yield
35
39
  rescue *exceptions => ex
@@ -4,14 +4,14 @@ module Asynchronic
4
4
  STATUSES = [:pending, :queued, :running, :waiting, :completed, :aborted]
5
5
 
6
6
  TIME_TRACKING_MAP = {
7
- pending: :created_at,
8
- queued: :queued_at,
9
- running: :started_at,
7
+ pending: :created_at,
8
+ queued: :queued_at,
9
+ running: :started_at,
10
10
  completed: :finalized_at,
11
- aborted: :finalized_at
11
+ aborted: :finalized_at
12
12
  }
13
13
 
14
- ATTRIBUTE_NAMES = [:type, :name, :queue, :status, :dependencies, :result, :error] | TIME_TRACKING_MAP.values.uniq
14
+ ATTRIBUTE_NAMES = [:type, :name, :queue, :status, :dependencies, :data, :result, :error] | TIME_TRACKING_MAP.values.uniq
15
15
 
16
16
  attr_reader :id
17
17
 
@@ -104,6 +104,10 @@ module Asynchronic
104
104
  self.class.create @environment, type, params.merge(id: id[:processes][processes.count])
105
105
  end
106
106
 
107
+ def set(key, value)
108
+ self.data = self.data.merge key => value
109
+ end
110
+
107
111
  def self.create(environment, type, params={})
108
112
  id = params.delete(:id) || SecureRandom.uuid
109
113
 
@@ -115,6 +119,7 @@ module Asynchronic
115
119
  self.queue = params.delete(:queue) || type.queue || parent_queue
116
120
  self.dependencies = Array(params.delete(:dependencies)) | Array(params.delete(:dependency)) | infer_dependencies(params)
117
121
  self.params = params
122
+ self.data = {}
118
123
  pending!
119
124
  end
120
125
  end
@@ -1,3 +1,3 @@
1
1
  module Asynchronic
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -168,6 +168,7 @@ class WorkerJob < Asynchronic::Job
168
168
  end
169
169
  end
170
170
 
171
+
171
172
  class ForwardReferenceJob < Asynchronic::Job
172
173
  def call
173
174
  async BuildReferenceJob
@@ -195,6 +196,7 @@ class ForwardReferenceJob < Asynchronic::Job
195
196
  end
196
197
  end
197
198
 
199
+
198
200
  class WithRetriesJob < Asynchronic::Job
199
201
  def call
200
202
  @counter = 0
@@ -206,7 +208,8 @@ class WithRetriesJob < Asynchronic::Job
206
208
  end
207
209
  end
208
210
 
209
- class NestedJobWithDifferentsQueues < Asynchronic::Job
211
+
212
+ class NestedJobWithDifferentsQueuesJob < Asynchronic::Job
210
213
  def call
211
214
  async Level1, input: params[:input]
212
215
  result Level1
@@ -225,4 +228,13 @@ class NestedJobWithDifferentsQueues < Asynchronic::Job
225
228
  end
226
229
  end
227
230
  end
231
+ end
232
+
233
+
234
+ class DataJob < Asynchronic::Job
235
+ def call
236
+ set :text, "Input was #{params[:input]}"
237
+ set :value, params[:input]
238
+ nil
239
+ end
228
240
  end
@@ -437,7 +437,7 @@ module LifeCycleExamples
437
437
  end
438
438
 
439
439
  it 'Inheritance of queues in processes. Redefine queue in job class' do
440
- process = create NestedJobWithDifferentsQueues, input: 100, queue: :test_queue
440
+ process = create NestedJobWithDifferentsQueuesJob, input: 100, queue: :test_queue
441
441
 
442
442
  process.queue.must_equal :test_queue
443
443
 
@@ -451,4 +451,15 @@ module LifeCycleExamples
451
451
  execute queue_engine[:other_queue]
452
452
  end
453
453
 
454
+ it 'Data' do
455
+ process = create DataJob, input: 1
456
+
457
+ process.enqueue
458
+ execute queue
459
+
460
+ process.must_be_completed
461
+ process.result.must_be_nil
462
+ process.data.must_equal text: 'Input was 1', value: 1
463
+ end
464
+
454
465
  end
metadata CHANGED
@@ -1,195 +1,195 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asynchronic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.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: 2016-12-23 00:00:00.000000000 Z
11
+ date: 2017-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ost
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: class_config
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: transparent_proxy
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0.0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1.12'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.12'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '11.0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '11.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: minitest
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '5.0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '5.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: minitest-great_expectations
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0.0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: minitest-colorin
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ~>
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0.1'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ~>
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0.1'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: minitest-line
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ~>
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0.6'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ~>
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0.6'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: simplecov
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ~>
157
+ - - "~>"
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0.12'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ~>
164
+ - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0.12'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: coveralls
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - ~>
171
+ - - "~>"
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0.8'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - ~>
178
+ - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0.8'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: pry-nav
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ~>
185
+ - - "~>"
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0.2'
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - ~>
192
+ - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0.2'
195
195
  description: DSL for asynchronic pipeline
@@ -199,11 +199,11 @@ executables: []
199
199
  extensions: []
200
200
  extra_rdoc_files: []
201
201
  files:
202
- - .coveralls.yml
203
- - .gitignore
204
- - .ruby-gemset
205
- - .ruby-version
206
- - .travis.yml
202
+ - ".coveralls.yml"
203
+ - ".gitignore"
204
+ - ".ruby-gemset"
205
+ - ".ruby-version"
206
+ - ".travis.yml"
207
207
  - Gemfile
208
208
  - LICENSE.txt
209
209
  - README.md
@@ -259,17 +259,17 @@ require_paths:
259
259
  - lib
260
260
  required_ruby_version: !ruby/object:Gem::Requirement
261
261
  requirements:
262
- - - '>='
262
+ - - ">="
263
263
  - !ruby/object:Gem::Version
264
264
  version: '0'
265
265
  required_rubygems_version: !ruby/object:Gem::Requirement
266
266
  requirements:
267
- - - '>='
267
+ - - ">="
268
268
  - !ruby/object:Gem::Version
269
269
  version: '0'
270
270
  requirements: []
271
271
  rubyforge_project:
272
- rubygems_version: 2.4.8
272
+ rubygems_version: 2.5.1
273
273
  signing_key:
274
274
  specification_version: 4
275
275
  summary: DSL for asynchronic pipeline using queues over Redis