asynchronic 0.2.2 → 0.2.3

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: 67da8d11aec50bb9ea82280266d58d88956219bf
4
- data.tar.gz: 2282a766bd3b31569414e2c5bea8b73f4f68fc38
3
+ metadata.gz: fa2c43c243d60d738f5467aa5e8a8dfff9dd18ed
4
+ data.tar.gz: 94cc6363b4dee324e49915cea455cf84fa496520
5
5
  SHA512:
6
- metadata.gz: a8b023257b64ece00babd316131c2f5b1eb6d30b6cf99e85b307e163f47785cc81f48ba96b633ea499d81d279dda3e7ac5de349bf1f00f386fbd7a7c39e1de9b
7
- data.tar.gz: e82d5c9f60e2891e3612a5675bafc2a5feff7360d72e12914361a45b0924aa38364e9b6c047109704b36988173b4ee231bc42cb6950e841e392dd110d5fbcd7c
6
+ metadata.gz: 2ae20696ec3c1d91692251b79be632219569c63d3eaae28c619cc08ff051db0df4149da9a1f50b9ebf0d7725601195f2d553986cde00ea873b9cc0ca7ab2a790
7
+ data.tar.gz: d81e1c116a0057cecd524cda9442e6b1649ad40fdf6090fbe0fcfc6c0ca052bd6dfd3a2261030358e920c8af9639b4ef967c964232720ae33617d3400a6bd627
data/lib/asynchronic.rb CHANGED
@@ -17,6 +17,8 @@ module Asynchronic
17
17
  attr_config :data_store, DataStore::InMemory.new
18
18
  attr_config :logger, Logger.new($stdout)
19
19
 
20
+ WAITING_TO_RETRY = 30
21
+
20
22
  def self.environment
21
23
  Environment.new queue_engine, data_store
22
24
  end
@@ -29,4 +31,15 @@ module Asynchronic
29
31
  environment.processes
30
32
  end
31
33
 
34
+ def self.retry_execution(a_class, message)
35
+ begin
36
+ result = yield
37
+ rescue Exception => ex
38
+ logger.info(a_class) { "Retrying #{message}. ERROR: #{ex.message}" }
39
+ sleep WAITING_TO_RETRY
40
+ retry
41
+ end
42
+ result
43
+ end
44
+
32
45
  end
@@ -79,7 +79,9 @@ module Asynchronic
79
79
 
80
80
  def execute
81
81
  run
82
- wakeup
82
+ Asynchronic.retry_execution(self.class, 'wakeup') do
83
+ wakeup
84
+ end
83
85
  end
84
86
 
85
87
  def wakeup
@@ -168,7 +170,9 @@ module Asynchronic
168
170
  rescue Exception => ex
169
171
  message = "Failed process #{type} (#{id})\n#{ex.class} #{ex.message}\n#{ex.backtrace.join("\n")}"
170
172
  Asynchronic.logger.error('Asynchronic') { message }
171
- abort! ex
173
+ Asynchronic.retry_execution(self.class, 'abort') do
174
+ abort! ex
175
+ end
172
176
  end
173
177
 
174
178
  def infer_dependencies(params)
@@ -63,7 +63,9 @@ module Asynchronic
63
63
 
64
64
  def listen(queue, &block)
65
65
  @current_queue = queue
66
- queue.each &block
66
+ Asynchronic.retry_execution(self.class, 'listen') do
67
+ queue.each &block
68
+ end
67
69
  end
68
70
 
69
71
  def stop
@@ -1,3 +1,3 @@
1
1
  module Asynchronic
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  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: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Naiman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-05 00:00:00.000000000 Z
11
+ date: 2015-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -241,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
241
  version: '0'
242
242
  requirements: []
243
243
  rubyforge_project:
244
- rubygems_version: 2.2.2
244
+ rubygems_version: 2.4.3
245
245
  signing_key:
246
246
  specification_version: 4
247
247
  summary: DSL for asynchronic pipeline using queues over Redis