unimatrix 3.3.0 → 3.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ed5880f8656f790aa4c540868b4c7adfb1be559
4
- data.tar.gz: fa3cddf703111db8dced819489f477472682fbe9
3
+ metadata.gz: 855794135ee5becfbca9f3a05a06c2161d162f5f
4
+ data.tar.gz: c993f1bf6e5ec5e5f349acf426aedfbf054abd32
5
5
  SHA512:
6
- metadata.gz: 03e2c085c727f2d2d0743ff4a678650a1585f2524eb655964e2799426eaf2840f0b3a0164886cdce7b65207ef1ee2a822705b8f86de950e4e115b80947306397
7
- data.tar.gz: 945869eb78d4bb6f5ec66d30c53fd9af7e80c05619eec7e222e18f74d2e07a7696abfe87a13eeaf210a0dbdeb12cab07cf46e98e30b0a07900a851653e6b03bc
6
+ metadata.gz: b9ccc0ca311d3db7ddf1fb99f943fe0e2e26cfe5efc82f6552592385bd1504bed67474bdc35bf501a4bf5805c50f4b8a640b4440869cc7acbc5a200b15bd3e4d
7
+ data.tar.gz: b83ffd34ed213f719a7bbad2235d75a547b877186f7c111e0852df1431584bf642e448326dc2d649fbf40f33e0f92e4d6fbec828fe2859a6be3c2a7ac9e43312
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.3.0
1
+ 3.3.1
@@ -29,6 +29,7 @@ require 'unimatrix/forbidden_error'
29
29
  require 'unimatrix/malformed_parameter_error'
30
30
  require 'unimatrix/missing_parameter_error'
31
31
  require 'unimatrix/not_found_error'
32
+ require 'unimatrix/timeout_error'
32
33
 
33
34
  # activist
34
35
  require 'unimatrix/activist/task'
@@ -55,12 +55,16 @@ module Unimatrix
55
55
  response = nil
56
56
  Request.new.tap do | request |
57
57
  request.get( @path, @parameters ).tap do | response |
58
- result = response.resources
59
- if block_given?
60
- case block.arity
61
- when 0; yield
62
- when 1; yield result
63
- when 2; yield result, response
58
+ if response.is_a?( Error )
59
+ result = response
60
+ else
61
+ result = response.resources
62
+ if block_given?
63
+ case block.arity
64
+ when 0; yield
65
+ when 1; yield result
66
+ when 2; yield result, response
67
+ end
64
68
  end
65
69
  end
66
70
  end
@@ -8,6 +8,11 @@ module Unimatrix
8
8
  def initialize( default_parameters = {} )
9
9
  uri = URI( Unimatrix.configuration.url )
10
10
  @http = Net::HTTP.new( uri.host, uri.port )
11
+
12
+ timeout_limit = ( ENV[ 'TIMEOUT_LIMIT' ] || 60 ).to_i
13
+
14
+ @http.open_timeout = timeout_limit
15
+ @http.read_timeout = timeout_limit
11
16
 
12
17
  @http.use_ssl = ( uri.scheme == 'https' )
13
18
  @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
@@ -55,16 +60,24 @@ module Unimatrix
55
60
  begin
56
61
  yield
57
62
  rescue Timeout::Error => error
63
+ log_error( error.inspect )
64
+
58
65
  error
59
66
  end
60
67
 
61
- unless response.nil? || ( response.is_a?( Response ) && retry_codes.include?( response.code ) )
62
-
63
- response = nil if response.is_a?( Timeout::Error )
64
-
68
+ unless response.nil? ||
69
+ ( response.is_a?( Response ) && retry_codes.include?( response.code ) ) ||
70
+ response.is_a?( Timeout::Error )
71
+
65
72
  break
66
73
  end
67
74
  end
75
+
76
+ if response.is_a?( Timeout::Error )
77
+ response = Unimatrix::TimeoutError.new(
78
+ message: response.message
79
+ )
80
+ end
68
81
 
69
82
  response
70
83
  end
@@ -78,6 +91,14 @@ module Unimatrix
78
91
 
79
92
  addressable.to_s
80
93
  end
94
+
95
+ protected; def log_error( message )
96
+ if defined?( logger.error )
97
+ logger.error( message )
98
+ else
99
+ puts "Error: #{ message }"
100
+ end
101
+ end
81
102
 
82
103
  end
83
104
 
@@ -0,0 +1,6 @@
1
+ module Unimatrix
2
+
3
+ class TimeoutError < Error
4
+ end
5
+
6
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unimatrix
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jackson Souza
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-25 00:00:00.000000000 Z
11
+ date: 2018-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -180,6 +180,7 @@ files:
180
180
  - lib/unimatrix/resource.rb
181
181
  - lib/unimatrix/response.rb
182
182
  - lib/unimatrix/serializer.rb
183
+ - lib/unimatrix/timeout_error.rb
183
184
  - lib/unimatrix/version.rb
184
185
  - lib/unimatrix/zephyrus/conversion_output.rb
185
186
  - lib/unimatrix/zephyrus/input.rb
@@ -213,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
214
  version: '0'
214
215
  requirements: []
215
216
  rubyforge_project:
216
- rubygems_version: 2.6.14
217
+ rubygems_version: 2.4.8
217
218
  signing_key:
218
219
  specification_version: 4
219
220
  summary: Unimatrix is used to communicate with Unimatrix APIs.