norad_beacon 0.1.6 → 0.1.7

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: 99ae90cc58a883071e41492b8446da7d1130a6e0
4
- data.tar.gz: 8ec70cfcde36e46f8529ef566f41e60d51983402
3
+ metadata.gz: 06a0d09aff0900b871ff00a2eeb25bdd35d72065
4
+ data.tar.gz: babfaa874a2af2162d46e0e7d72cdd80fcb64ab9
5
5
  SHA512:
6
- metadata.gz: 47e67ee1bc409641a34b17818c982e605a28b77f258895e4e4de5350c2771b6246a9dcc80ad5c3c88c8fe2c5dc0ea71e774b11fff0f0538f5056a456296e5b8d
7
- data.tar.gz: a209abe48d4e7114b02dad759413cf520f456a7b769b14b610652d69a769da7069dabe7fa856562fd2c258b1f7f149b3529bb58dfd1d9af5d21d540d4e34fc74
6
+ metadata.gz: 5286b79e17b95bd90585f66fc64ad447312cf2e348300cb1a5fb775f66ecf7db5e75f10301e85eb3dafe069755d81ffe4066ad388d8d4e01bebbdfefc76771ef
7
+ data.tar.gz: 24bc8699f52abe828566b8b280d93686ea08fb3dc3bbc39fb08ab70a904fd163a776efcd59f0fb210c4985aeb8d5719e6e93f44ff6cf1f8124b033e30f66dd8e
@@ -7,6 +7,8 @@ module NoradBeacon
7
7
  class NoradAPI
8
8
  include HTTParty
9
9
  @norad_root = ENV.fetch('NORAD_ROOT')
10
+ MAX_ATTEMPTS = 10
11
+ RETRY_BACKOFF = 2
10
12
 
11
13
  class << self
12
14
  def post_payload(http_payload)
@@ -25,8 +27,20 @@ module NoradBeacon
25
27
 
26
28
  private
27
29
 
30
+ def http_req_with_retry(verb, uri, payload)
31
+ retries ||= 0
32
+ send(verb, uri, payload)
33
+ rescue SystemCallError, EOFError, Timeout::Error, SocketError
34
+ sleep(RETRY_BACKOFF**retries) && retry if (retries += 1) < MAX_ATTEMPTS
35
+ raise
36
+ end
37
+
28
38
  def http_req(http_payload, verb)
29
- httpparty_response = send(verb, @norad_root + http_payload.url, http_req_options(http_payload))
39
+ httpparty_response = http_req_with_retry(
40
+ verb,
41
+ @norad_root + http_payload.url,
42
+ http_req_options(http_payload)
43
+ )
30
44
  error_msg = unsuccessful_http_response_msg(httpparty_response)
31
45
  puts error_msg if error_msg
32
46
  httpparty_response
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NoradBeacon
4
- VERSION = '0.1.6'
4
+ VERSION = '0.1.7'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: norad_beacon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Hitchcock
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2018-01-22 00:00:00.000000000 Z
13
+ date: 2018-05-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty