nne_client 0.0.5 → 0.0.6

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.
data/README.md CHANGED
@@ -66,6 +66,16 @@ Additionally further information can be fetched through the methods:
66
66
  subsidiaries
67
67
  finances
68
68
 
69
+ ## Retry
70
+
71
+ As NNE can sometimes be flaky it is possible to retry requests:
72
+
73
+ NNEClient.retry_timeouts(3) do
74
+ ...
75
+ end
76
+
77
+ This will retry the block up to 3 times when timeouts occur.
78
+
69
79
  ## Configuration
70
80
 
71
81
  NNEClient is based on Savon and HTTPI. You may use these libraries to control
@@ -79,6 +89,12 @@ logging. For example:
79
89
  config.logger = Rails.logger # using the Rails logger
80
90
  end
81
91
 
92
+ To set a 5 second expiration on reads from NNE do:
93
+
94
+ NNEClient.configure do |config|
95
+ config.http_read_timeout = 5
96
+ end
97
+
82
98
  ## Contributing
83
99
 
84
100
  1. Fork it
@@ -12,13 +12,7 @@ module NNEClient
12
12
  end
13
13
 
14
14
  def result_set(&block)
15
- retries = 3
16
- begin
17
- ResultSet.new(perform_request(&block))
18
- rescue Net::HTTPRequestTimeOut => e
19
- retries -= 1
20
- retry if retries > 0
21
- end
15
+ ResultSet.new(perform_request(&block))
22
16
  end
23
17
 
24
18
  private
@@ -49,6 +43,8 @@ module NNEClient
49
43
  @client ||= Savon::Client.new do
50
44
  wsdl.document = File.expand_path("../../../wsdl/nne.wsdl", __FILE__)
51
45
  end
46
+ @client.http.read_timeout = NNEClient.config.http_read_timeout
47
+ @client
52
48
  end
53
49
  end
54
50
  end
@@ -1,3 +1,3 @@
1
1
  module NNEClient
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/nne_client.rb CHANGED
@@ -22,6 +22,7 @@ module NNEClient
22
22
  class CompanyMissing < RuntimeError; end
23
23
 
24
24
  config :access_key
25
+ config :http_read_timeout
25
26
 
26
27
  # Where users start the interaction with the library.
27
28
  #
@@ -38,4 +39,14 @@ module NNEClient
38
39
  def search(query)
39
40
  NNEClient::Search.new(query).result_set
40
41
  end
42
+
43
+ def retry_timeouts(count, &block)
44
+ retries = 3
45
+ begin
46
+ yield
47
+ rescue Timeout::Error => e
48
+ retries -= 1
49
+ retry if retries > 0
50
+ end
51
+ end
41
52
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nne_client
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jacob Atzen
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-10-23 00:00:00 Z
18
+ date: 2012-12-10 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: savon