enviroblyd 0.4.1 → 0.4.2

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
  SHA256:
3
- metadata.gz: 05071a7be6ad5145537f06b8466841984969e4c89759ea929ee0f1a28a6457cf
4
- data.tar.gz: 79c5c57647395378dddd409ae90075e888e7e1999c997efd1c1e736b6a871fbb
3
+ metadata.gz: 28e33b71b8d370a6ea6239748afe9e0bbb6023325cd3f46ae070e2e8433531f3
4
+ data.tar.gz: 3485336ad0bff70f3bb983d9487ad650c8b18f5afce4a45e2ec4a2ef167815f8
5
5
  SHA512:
6
- metadata.gz: 54cdd680ffb67c14da0795fee35ef925e44795fc91876917377b8c7be8e6719b4ecb6c8cb826ad3d941d6856680a7aff6700f7a0de284ec0847e026bc60e1acf
7
- data.tar.gz: a71d5071c3bb1001f6f35ef5603a617b88aec4d1a54c338945afd1df43e6a764ce441b2324cc3a932f2b97df5ee5947221136ad86694bd7bae78922b10a5bd9c
6
+ metadata.gz: 3c303fba4a8693104fe31b69fd6af04a8d4c1899a51c9c8f949bec21dd8f378fefcc9fb81161db793b4344f9eceffe3d160e0e0bb04709e8dcbc9c555ce7f163
7
+ data.tar.gz: dd2b1d9035182ec8a18ed9f3b2cff027afe017f7c37f3b2d31b142b1ae92a783461c716d7804d2daf4a109bad334eae3ce47d09f9dc0efdc0574ffce2583a707
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Enviroblyd
4
- VERSION = "0.4.1"
4
+ VERSION = "0.4.2"
5
5
  end
@@ -22,7 +22,7 @@ class Enviroblyd::Web
22
22
  else
23
23
  init_url = ENV.fetch "ENVIROBLYD_INIT_URL"
24
24
  puts "Init URL: #{init_url}"
25
- response = http(init_url, type: Net::HTTP::Put, retry_interval: 3, retries: 10, backoff: :exponential)
25
+ response = http(init_url, type: Net::HTTP::Put)
26
26
  puts "Init response code: #{response.code}"
27
27
 
28
28
  if response.code.to_i == 200
@@ -32,7 +32,7 @@ class Enviroblyd::Web
32
32
  end
33
33
  end
34
34
 
35
- def http(url, type: Net::HTTP::Get, headers: {}, retry_interval: 2, retries: 30, backoff: false, tries: 1, params: nil)
35
+ def http(url, type: Net::HTTP::Get, params: nil, headers: {}, retry_interval: 3, retries: 10, backoff: :exponential, tries: 1)
36
36
  if retries <= tries
37
37
  $stderr.puts "Retried #{tries} times. Aborting."
38
38
  exit 1
@@ -41,15 +41,12 @@ class Enviroblyd::Web
41
41
  uri = URI(url)
42
42
  http = Net::HTTP.new uri.host, uri.port
43
43
  http.use_ssl = true if uri.scheme == "https"
44
- http.open_timeout = 5
45
- http.read_timeout = 5
44
+ http.open_timeout = 10
45
+ http.read_timeout = 10
46
46
 
47
47
  request = type.new(uri, default_headers.merge(headers))
48
48
  request.content_type = CONTENT_TYPE
49
-
50
- unless params.nil?
51
- request.body = JSON.dump params
52
- end
49
+ request.body = JSON.dump(params) unless params.nil?
53
50
 
54
51
  response =
55
52
  begin
@@ -58,12 +55,11 @@ class Enviroblyd::Web
58
55
  :retry
59
56
  end
60
57
 
61
- # https://developers.cloudflare.com/support/troubleshooting/cloudflare-errors/troubleshooting-cloudflare-1xxx-errors/
62
58
  if response == :retry || (500..599).include?(response.code.to_i)
63
59
  sleep_time = (backoff == :exponential) ? (retry_interval * tries) : retry_interval
64
60
  $stderr.puts "Retry #{uri} in #{sleep_time}s"
65
61
  sleep sleep_time
66
- http(url, type:, retry_interval:, retries:, backoff:, tries: (tries + 1))
62
+ http(url, type:, params:, retry_interval:, retries:, backoff:, tries: (tries + 1))
67
63
  else
68
64
  response
69
65
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enviroblyd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Starsi